Skip to content

Commit

Permalink
front: add logo when train is projected
Browse files Browse the repository at this point in the history
Signed-off-by: theocrsb <theo_crosbie@yahoo.fr>
  • Loading branch information
theocrsb committed Oct 14, 2024
1 parent 3ac680e commit fe79549
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ import { useMemo, useState } from 'react';
import cx from 'classnames';
import { compact } from 'lodash';
import { useTranslation } from 'react-i18next';
import { useSelector } from 'react-redux';

import { MANAGE_TRAIN_SCHEDULE_TYPES } from 'applications/operationalStudies/consts';
import type { Conflict, InfraState, TrainScheduleResult } from 'common/api/osrdEditoastApi';
import ConflictsList from 'modules/conflict/components/ConflictsList';
import { updateSelectedTrainId } from 'reducers/simulationResults';
import { getTrainIdUsedForProjection } from 'reducers/simulationResults/selectors';
import { useAppDispatch } from 'store';
import { distributedIntervalsFromArrayOfValues } from 'utils/numbers';

Expand Down Expand Up @@ -48,6 +50,7 @@ const Timetable = ({
const [conflictsListExpanded, setConflictsListExpanded] = useState(false);
const [selectedTrainIds, setSelectedTrainIds] = useState<number[]>([]);
const [showTrainDetails, setShowTrainDetails] = useState(false);
const trainIdUsedForProjection = useSelector(getTrainIdUsedForProjection);
const dispatch = useAppDispatch();

const trainsDurationsIntervals = useMemo(
Expand Down Expand Up @@ -143,6 +146,9 @@ const Timetable = ({
upsertTrainSchedules={upsertTrainSchedules}
setTrainIdToEdit={setTrainIdToEdit}
removeTrains={removeAndUnselectTrains}
projectionPathIsUsed={
infraState === 'CACHED' && trainIdUsedForProjection === train.id
}
/>
))}
<div
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';

import { Checkbox } from '@osrd-project/ui-core';
import { Duplicate, Pencil, Trash, Clock, Flame, Moon } from '@osrd-project/ui-icons';
import { Duplicate, Pencil, Trash, Clock, Flame, Moon, Manchette } from '@osrd-project/ui-icons';
import cx from 'classnames';
import dayjs from 'dayjs';
import { omit } from 'lodash';
Expand Down Expand Up @@ -31,6 +31,7 @@ type TimetableTrainCardProps = {
upsertTrainSchedules: (trainSchedules: TrainScheduleResult[]) => void;
setTrainIdToEdit: (trainIdToEdit?: number) => void;
removeTrains: (trainIds: number[]) => void;
projectionPathIsUsed: boolean;
};

const TimetableTrainCard = ({
Expand All @@ -43,6 +44,7 @@ const TimetableTrainCard = ({
upsertTrainSchedules,
setTrainIdToEdit,
removeTrains,
projectionPathIsUsed,
}: TimetableTrainCardProps) => {
const { t } = useTranslation(['operationalStudies/scenario']);
const dispatch = useAppDispatch();
Expand Down Expand Up @@ -168,6 +170,11 @@ const TimetableTrainCard = ({
/>
</div>
<div title={train.trainName} className="checkbox-label">
{projectionPathIsUsed && (
<div className="train-projected">
<Manchette iconColor="var(--white100)" />
</div>
)}
{train.trainName}
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,22 @@
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
display: flex;
align-items: center;
.train-projected {
height: 1.25rem;
width: 1.25rem;
margin-right: 0.375rem;
background-color: var(--info30);
border-radius: 0.25rem;
position: relative;
svg {
position: absolute;
top: 0;
left: 0;
transform: translate(0.125rem, 0.125rem);
}
}
}

.scenario-timetable-toolbar {
Expand Down

0 comments on commit fe79549

Please sign in to comment.