Skip to content

Commit f61ba6e

Browse files
committed
front: redesign top left of the scenario page
Signed-off-by: theocrsb <[email protected]>
1 parent 81bb69a commit f61ba6e

File tree

8 files changed

+198
-133
lines changed

8 files changed

+198
-133
lines changed

front/public/locales/en/operationalStudies/scenario.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@
1515
"filterPlaceholder": "Filter, tags",
1616
"advancedFiltersPlaceholder": "Filter by family, serie, detail",
1717
"infraLoadingState": "{{step}}/7",
18-
"macroscopic": "Macroscopic",
19-
"microscopic": "Microscopic",
18+
"infrastructure": "Infrastructure",
19+
"macroscopic": "MACRO",
20+
"microscopic": "MICRO",
2021
"modifyScenario": "Modify scenario",
2122
"noElectricalProfileSet": "No electrical profile",
2223
"scenarioCancel": "Cancel",

front/public/locales/fr/operationalStudies/scenario.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@
1414
},
1515
"filterPlaceholder": "Filtre, étiquettes",
1616
"infraLoadingState": "{{step}}/7",
17-
"macroscopic": "Macroscopique",
18-
"microscopic": "Microscopique",
17+
"infrastructure": "Infrastructure",
18+
"macroscopic": "MACRO",
19+
"microscopic": "MICRO",
1920
"modifyScenario": "Modifier le scénario",
2021
"noElectricalProfileSet": "Pas de profil électrique",
2122
"scenarioCancel": "Annuler",

front/src/applications/operationalStudies/components/MicroMacroSwitch.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,18 @@ type MicroMacroSwitchProps = {
99
const MicroMacroSwitch = ({ isMacro, setIsMacro }: MicroMacroSwitchProps) => {
1010
const { t } = useTranslation('operationalStudies/scenario');
1111
return (
12-
<div className="tabs-container">
13-
<div className="tabs">
12+
<div className="micro-macro-container">
13+
<div className="micro-macro-buttons">
1414
<div
15-
className={cx('tab', { active: !isMacro })}
15+
className={cx('micro-button', { active: !isMacro })}
1616
role="button"
1717
tabIndex={0}
1818
onClick={() => setIsMacro(false)}
1919
>
2020
{t('microscopic')}
2121
</div>
2222
<div
23-
className={cx('tab', { active: isMacro })}
23+
className={cx('macro-button', { active: isMacro })}
2424
role="button"
2525
tabIndex={0}
2626
onClick={() => setIsMacro(true)}

front/src/applications/operationalStudies/components/Scenario/ScenarioContent.tsx

-4
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ const ScenarioContent = ({
5252
const [displayTrainScheduleManagement, setDisplayTrainScheduleManagement] = useState<string>(
5353
MANAGE_TRAIN_SCHEDULE_TYPES.none
5454
);
55-
const [showTrainDetails, setShowTrainDetails] = useState(false);
5655
const [collapsedTimetable, setCollapsedTimetable] = useState(false);
5756
const [trainIdToEdit, setTrainIdToEdit] = useState<number>();
5857
const [isMacro, setIsMacro] = useState(false);
@@ -138,8 +137,6 @@ const ScenarioContent = ({
138137
scenario={scenario}
139138
infra={infra}
140139
infraReloadCount={reloadCount}
141-
showTrainDetails={showTrainDetails}
142-
toggleTrainDetails={() => setShowTrainDetails(!showTrainDetails)}
143140
collapseTimetable={() => setCollapsedTimetable(true)}
144141
/>
145142
<MicroMacroSwitch isMacro={isMacro} setIsMacro={toggleMicroMacroButton} />
@@ -157,7 +154,6 @@ const ScenarioContent = ({
157154
)}
158155
<Timetable
159156
setDisplayTrainScheduleManagement={setDisplayTrainScheduleManagement}
160-
trainsWithDetails={showTrainDetails}
161157
infraState={infra.state}
162158
trainIds={timetable.train_ids}
163159
selectedTrainId={selectedTrainId}

front/src/applications/operationalStudies/components/Scenario/ScenarioDescription.tsx

+28-45
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
import { ChevronLeft, Eye, EyeClosed, Pencil } from '@osrd-project/ui-icons';
1+
import { ChevronLeft, Pencil } from '@osrd-project/ui-icons';
22
import { useTranslation } from 'react-i18next';
3-
import { GiElectric } from 'react-icons/gi';
43

54
import InfraLoadingState from 'applications/operationalStudies/components/Scenario/InfraLoadingState';
6-
import infraLogo from 'assets/pictures/components/tracks.svg';
75
import type { InfraWithState, ScenarioResponse } from 'common/api/osrdEditoastApi';
86
import { useModal } from 'common/BootstrapSNCF/ModalSNCF';
97
import AddAndEditScenarioModal from 'modules/scenario/components/AddOrEditScenarioModal';
@@ -12,31 +10,43 @@ type ScenarioDescriptionProps = {
1210
scenario: ScenarioResponse;
1311
infra?: InfraWithState;
1412
infraReloadCount: number;
15-
showTrainDetails: boolean;
16-
toggleTrainDetails: () => void;
1713
collapseTimetable: () => void;
1814
};
1915

2016
const ScenarioDescription = ({
2117
scenario,
2218
infra,
2319
infraReloadCount,
24-
showTrainDetails,
25-
toggleTrainDetails,
2620
collapseTimetable,
2721
}: ScenarioDescriptionProps) => {
2822
const { t } = useTranslation('operationalStudies/scenario');
2923
const { openModal } = useModal();
3024

3125
return (
32-
<div className="scenario-details">
26+
<div>
3327
<div className="scenario-details-name">
3428
<span className="flex-grow-1 scenario-name text-truncate" title={scenario.name}>
3529
{scenario.name}
3630
</span>
31+
</div>
32+
33+
<div className="scenario-description">
34+
{scenario.description && (
35+
<div className="scenario-details-description">{scenario.description}</div>
36+
)}
37+
<div className="flex justify-end">
38+
<button
39+
type="button"
40+
className="scenario-collapse-button"
41+
aria-label={t('toggleTimetable')}
42+
onClick={() => collapseTimetable()}
43+
>
44+
<ChevronLeft />
45+
</button>
46+
</div>
3747
<button
3848
data-testid="editScenario"
39-
className="scenario-details-modify-button"
49+
className="update-scenario"
4050
type="button"
4151
aria-label={t('editScenario')}
4252
onClick={() =>
@@ -50,42 +60,16 @@ const ScenarioDescription = ({
5060
>
5161
<Pencil />
5262
</button>
53-
<button
54-
type="button"
55-
className="scenario-details-modify-button"
56-
onClick={toggleTrainDetails}
57-
title={t('displayTrainsWithDetails')}
58-
>
59-
{showTrainDetails ? <EyeClosed /> : <Eye />}
60-
</button>
61-
<button
62-
type="button"
63-
className="scenario-details-modify-button"
64-
aria-label={t('toggleTimetable')}
65-
onClick={() => collapseTimetable()}
66-
>
67-
<ChevronLeft />
68-
</button>
6963
</div>
70-
<div className="row">
71-
<div className="col-md-6">
72-
<div className="scenario-details-infra-name">
73-
<img src={infraLogo} alt="Infra logo" className="infra-logo mr-2" />
74-
{infra && <InfraLoadingState infra={infra} />}
75-
<span className="scenario-infra-name">{scenario.infra_name}</span>
76-
<small className="ml-auto text-muted">ID {scenario.infra_id}</small>
77-
</div>
78-
</div>
79-
<div className="col-md-6">
80-
<div className="scenario-details-electrical-profile-set">
81-
<span className="mr-2">
82-
<GiElectric />
83-
</span>
84-
{scenario.electrical_profile_set_id
85-
? scenario.electrical_profile_set_id
86-
: t('noElectricalProfileSet')}
87-
</div>
88-
</div>
64+
<div className="scenario-details-electrical-profile-set">
65+
{scenario.electrical_profile_set_id
66+
? scenario.electrical_profile_set_id
67+
: t('noElectricalProfileSet')}
68+
</div>
69+
70+
<div className="scenario-details-infra-name">
71+
{t('infrastructure')} :&nbsp;{infra && <InfraLoadingState infra={infra} />}
72+
{scenario.infra_name} | ID {scenario.infra_id}
8973
</div>
9074
{infra &&
9175
infra.state === 'TRANSIENT_ERROR' &&
@@ -101,7 +85,6 @@ const ScenarioDescription = ({
10185
{infra && infra.state === 'ERROR' && (
10286
<div className="scenario-details-infra-error mt-1">{t('errorMessages.hardErrorInfra')}</div>
10387
)}
104-
<div className="scenario-details-description">{scenario.description}</div>
10588
</div>
10689
);
10790
};

front/src/modules/trainschedule/components/Timetable/Timetable.tsx

+8-19
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useEffect, useMemo, useState } from 'react';
22

3-
import { Alert, Download, Plus } from '@osrd-project/ui-icons';
3+
import { Alert } from '@osrd-project/ui-icons';
44
import cx from 'classnames';
55
import { compact } from 'lodash';
66
import { useTranslation } from 'react-i18next';
@@ -21,7 +21,6 @@ import { timetableHasInvalidTrain } from './utils';
2121

2222
type TimetableProps = {
2323
setDisplayTrainScheduleManagement: (mode: string) => void;
24-
trainsWithDetails: boolean;
2524
infraState: InfraState;
2625
trainIds: number[];
2726
selectedTrainId?: number;
@@ -36,7 +35,6 @@ type TimetableProps = {
3635

3736
const Timetable = ({
3837
setDisplayTrainScheduleManagement,
39-
trainsWithDetails,
4038
infraState,
4139
trainIds,
4240
selectedTrainId,
@@ -107,29 +105,21 @@ const Timetable = ({
107105
<div className="scenario-timetable">
108106
<div className="scenario-timetable-addtrains-buttons">
109107
<button
110-
className="btn btn-secondary btn-sm"
111-
type="button"
112-
data-testid="scenarios-import-train-schedule-button"
113-
onClick={() => setDisplayTrainScheduleManagement(MANAGE_TRAIN_SCHEDULE_TYPES.import)}
114-
>
115-
<span className="mr-2">
116-
<Download />
117-
</span>
118-
{t('timetable.importTrainSchedule')}
119-
</button>
120-
<button
121-
className="btn btn-primary btn-sm"
122108
type="button"
123109
data-testid="scenarios-add-train-schedule-button"
124110
onClick={() => {
125111
setDisplayTrainScheduleManagement(MANAGE_TRAIN_SCHEDULE_TYPES.add);
126112
}}
127113
>
128-
<span className="mr-2">
129-
<Plus />
130-
</span>
131114
{t('timetable.addTrainSchedule')}
132115
</button>
116+
<button
117+
type="button"
118+
data-testid="scenarios-import-train-schedule-button"
119+
onClick={() => setDisplayTrainScheduleManagement(MANAGE_TRAIN_SCHEDULE_TYPES.import)}
120+
>
121+
{t('timetable.importTrainSchedule')}
122+
</button>
133123
</div>
134124
<TimetableToolbar
135125
trainSchedulesWithDetails={trainSchedulesWithDetails}
@@ -146,7 +136,6 @@ const Timetable = ({
146136
<div
147137
className={cx('scenario-timetable-trains', {
148138
expanded: conflictsListExpanded,
149-
'with-details': trainsWithDetails,
150139
})}
151140
>
152141
{trainsDurationsIntervals &&

front/src/styles/scss/_variables.scss

+7
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@ $colors: (
3232
'coolgray5': #b9b9b9,
3333
'coolgray3': #d7d7d7,
3434
'coolgray1': #f2f2f2,
35+
'primary60': #1844ef,
36+
'grey20': #d3d1cf,
37+
'grey40': #94918e,
38+
'grey50': #797671,
39+
'grey60': #5c5955,
40+
'grey90': #1f1b17,
41+
'ambientB10': #f7f6ee,
3542
);
3643

3744
:root {

0 commit comments

Comments
 (0)