Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

front: redesigned top of scenario page #8861

Merged
merged 1 commit into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions front/public/locales/en/operationalStudies/scenario.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
"filterPlaceholder": "Filter, tags",
"advancedFiltersPlaceholder": "Filter by family, serie, detail",
"infraLoadingState": "{{step}}/7",
"infrastructure": "Infrastructure",
"lessDetails": "less details",
"macroscopic": "Macroscopic",
"microscopic": "Microscopic",
"macroscopic": "MACRO",
"microscopic": "MICRO",
"modifyScenario": "Modify scenario",
"moreDetails": "more details",
"noElectricalProfileSet": "No electrical profile",
Expand Down
5 changes: 3 additions & 2 deletions front/public/locales/fr/operationalStudies/scenario.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
},
"filterPlaceholder": "Filtre, étiquettes",
"infraLoadingState": "{{step}}/7",
"infrastructure": "Infrastructure",
"lessDetails": "moins de détails",
"macroscopic": "Macroscopique",
"microscopic": "Microscopique",
"macroscopic": "MACRO",
"microscopic": "MICRO",
"modifyScenario": "Modifier le scénario",
"moreDetails": "plus de détails",
"noElectricalProfileSet": "Pas de profil électrique",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,24 @@ type MicroMacroSwitchProps = {
const MicroMacroSwitch = ({ isMacro, setIsMacro }: MicroMacroSwitchProps) => {
const { t } = useTranslation('operationalStudies/scenario');
return (
<div className="tabs-container">
<div className="tabs">
<div
className={cx('tab', { active: !isMacro })}
role="button"
tabIndex={0}
onClick={() => setIsMacro(false)}
>
{t('microscopic')}
</div>
<div
className={cx('tab', { active: isMacro })}
role="button"
tabIndex={0}
onClick={() => setIsMacro(true)}
>
{t('macroscopic')}
</div>
</div>
<div className="micro-macro-buttons">
<button
type="button"
className={cx('micro-button', { active: !isMacro })}
tabIndex={0}
onClick={() => setIsMacro(false)}
>
{t('microscopic')}
</button>
<div className="micro-macro-separator" />
<button
type="button"
className={cx('macro-button', { active: isMacro })}
tabIndex={0}
onClick={() => setIsMacro(true)}
>
{t('macroscopic')}
</button>
</div>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default function InfraLoadingState({ infra }: Props) {
title={infra.state}
>
{infra.state && infra.state === 'CACHED' ? (
<span>•</span>
<span className="infra-loaded" />
) : (
<>
<span className="infra-loader">•</span>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { ChevronLeft, Pencil } from '@osrd-project/ui-icons';
import { Blocked, ChevronLeft, Pencil } from '@osrd-project/ui-icons';
import { useTranslation } from 'react-i18next';
import { GiElectric } from 'react-icons/gi';

import InfraLoadingState from 'applications/operationalStudies/components/Scenario/InfraLoadingState';
import infraLogo from 'assets/pictures/components/tracks.svg';
import type { InfraWithState, ScenarioResponse } from 'common/api/osrdEditoastApi';
import { useModal } from 'common/BootstrapSNCF/ModalSNCF';
import AddAndEditScenarioModal from 'modules/scenario/components/AddOrEditScenarioModal';

import InfraLoadingState from './InfraLoadingState';

type ScenarioDescriptionProps = {
scenario: ScenarioResponse;
infra?: InfraWithState;
Expand All @@ -25,14 +24,30 @@ const ScenarioDescription = ({
const { openModal } = useModal();

return (
<div className="scenario-details">
<div>
<div className="scenario-details-name">
<span className="flex-grow-1 scenario-name text-truncate" title={scenario.name}>
{scenario.name}
</span>
</div>

<div className="scenario-description">
{scenario.description && (
<div className="scenario-details-description">{scenario.description}</div>
)}
<div className="flex justify-end">
<button
type="button"
className="scenario-collapse-button"
aria-label={t('toggleTimetable')}
onClick={() => collapseTimetable()}
>
<ChevronLeft />
</button>
</div>
<button
data-testid="editScenario"
className="scenario-details-modify-button"
className="update-scenario"
type="button"
aria-label={t('editScenario')}
onClick={() =>
Expand All @@ -46,50 +61,41 @@ const ScenarioDescription = ({
>
<Pencil />
</button>
<button
type="button"
className="scenario-details-modify-button"
aria-label={t('toggleTimetable')}
onClick={() => collapseTimetable()}
>
<ChevronLeft />
</button>
</div>
<div className="row">
<div className="col-md-6">
<div className="scenario-details-infra-name">
<img src={infraLogo} alt="Infra logo" className="infra-logo mr-2" />
{infra && <InfraLoadingState infra={infra} />}
<span className="scenario-infra-name">{scenario.infra_name}</span>
<small className="ml-auto text-muted">ID {scenario.infra_id}</small>
</div>
</div>
<div className="col-md-6">
<div className="scenario-details-electrical-profile-set">
<span className="mr-2">
<GiElectric />
</span>
{scenario.electrical_profile_set_id
? scenario.electrical_profile_set_id
: t('noElectricalProfileSet')}
</div>
</div>
<div className="scenario-details-electrical-profile-set">
{scenario.electrical_profile_set_id
? scenario.electrical_profile_set_id
: t('noElectricalProfileSet')}
</div>

<div className="scenario-details-infra-name">
{t('infrastructure')} :&nbsp;
{infra && <InfraLoadingState infra={infra} />}
&nbsp;
<span className="scenario-infra-name">{scenario.infra_name}</span>&nbsp;| ID
{scenario.infra_id}
</div>
{infra &&
infra.state === 'TRANSIENT_ERROR' &&
(infraReloadCount <= 5 ? (
<div className="scenario-details-infra-error mt-1">
{t('errorMessages.unableToLoadInfra', { infraReloadCount })}
<div className="scenario-details-infra-error">
<Blocked variant="fill" />
<span className="error-description">
{t('errorMessages.unableToLoadInfra', { infraReloadCount })}
</span>
</div>
) : (
<div className="scenario-details-infra-error mt-1">
{t('errorMessages.softErrorInfra')}
<div className="scenario-details-infra-error">
<Blocked variant="fill" />
<span className="error-description">{t('errorMessages.softErrorInfra')}</span>
</div>
))}
{infra && infra.state === 'ERROR' && (
<div className="scenario-details-infra-error mt-1">{t('errorMessages.hardErrorInfra')}</div>
<div className="scenario-details-infra-error">
<Blocked variant="fill" />
<span className="error-description">{t('errorMessages.hardErrorInfra')}</span>
</div>
)}
<div className="scenario-details-description">{scenario.description}</div>
</div>
);
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { useMemo, useState } from 'react';

import { Download, Plus } from '@osrd-project/ui-icons';
import cx from 'classnames';
import { compact } from 'lodash';
import { useTranslation } from 'react-i18next';
Expand Down Expand Up @@ -98,34 +97,25 @@ const Timetable = ({
<div className="scenario-timetable">
<div className="scenario-timetable-addtrains-buttons">
<button
className="btn btn-secondary btn-sm"
type="button"
data-testid="scenarios-import-train-schedule-button"
onClick={() => setDisplayTrainScheduleManagement(MANAGE_TRAIN_SCHEDULE_TYPES.import)}
>
<span className="mr-2">
<Download />
</span>
{t('timetable.importTrainSchedule')}
</button>
<button
className="btn btn-primary btn-sm"
type="button"
data-testid="scenarios-add-train-schedule-button"
onClick={() => {
setDisplayTrainScheduleManagement(MANAGE_TRAIN_SCHEDULE_TYPES.add);
}}
>
<span className="mr-2">
<Plus />
</span>
{t('timetable.addTrainSchedule')}
</button>
<button
type="button"
data-testid="scenarios-import-train-schedule-button"
onClick={() => setDisplayTrainScheduleManagement(MANAGE_TRAIN_SCHEDULE_TYPES.import)}
>
{t('timetable.importTrainSchedule')}
</button>
</div>
<div
className={cx('scenario-timetable-trains', {
expanded: conflictsListExpanded,
'with-details': showTrainDetails,
})}
>
<TimetableToolbar
Expand Down
13 changes: 13 additions & 0 deletions front/src/styles/scss/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,28 @@ $colors: (
'ambiantB5': #faf9f5,
'ambiantB10': #f7f6ee,
'ambiantB15': #f2f0e4,
'black5': rgba(0, 0, 0, 0.05),
'black10': rgba(0, 0, 0, 0.1),
'black100': #000000,
'error5': #ffeeed,
'error60': #d91c1c,
'error80': #6b0000,
'grey20': #d3d1cf,
'grey30': #b6b2af,
'grey40': #94918e,
'grey50': #797671,
'grey60': #5c5955,
'grey90': #1f1b17,
'grey80': #312e2b,
'info5': #e6f7ff,
'info30': #70c1e5,
'info60': #216482,
'info80': #053348,
'primary50': #256afa,
'primary60': #1844ef,
'primary80': #1f0f96,
'selection20': #fff2b3,
'success30': #3cca80,
'warning5': #fdf5e1,
'warning30': #eaa72b,
'warning60': #7d521e,
Expand Down
Loading
Loading