From bc00cf2de62d7477765fc3841493906ae7cd9974 Mon Sep 17 00:00:00 2001 From: SharglutDev Date: Thu, 5 Sep 2024 22:07:37 +0200 Subject: [PATCH] front: rename v2 components It does not handle stdcmV2 renaming as it still coexists with stdcm debug Signed-off-by: SharglutDev --- .../__tests__/sampleData.ts | 6 +- .../helpers/formatTrainScheduleSummaries.ts | 2 +- .../hooks/useLazyLoadTrains.ts | 4 +- .../hooks/useSetupItineraryForTrainUpdate.ts | 5 +- .../hooks/useSimulationResults.ts | 4 +- .../applications/operationalStudies/types.ts | 12 ++-- .../applications/operationalStudies/utils.ts | 6 +- ...ScheduleV2.tsx => ImportTrainSchedule.tsx} | 12 ++-- ...ScheduleV2.tsx => ManageTrainSchedule.tsx} | 20 +++--- .../operationalStudies/views/Project.tsx | 4 +- .../views/{v2/ScenarioV2.tsx => Scenario.tsx} | 22 +++--- ...ionResultsV2.tsx => SimulationResults.tsx} | 39 ++++++----- .../operationalStudies/views/Study.tsx | 10 +-- ...tSheetV2.tsx => SimulationReportSheet.tsx} | 8 +-- .../stdcm/utils/formatStdcmConfV2.ts | 5 +- .../applications/stdcm/views/StdcmConfig.tsx | 16 ++--- .../stdcm/views/StdcmResultsV2.tsx | 10 ++- .../stdcmV2/components/StdcmConfig.tsx | 10 +-- .../stdcmV2/components/StdcmDestination.tsx | 4 +- .../stdcmV2/components/StdcmOrigin.tsx | 8 +-- .../components/StdcmResults/StdcmResults.tsx | 4 +- .../stdcmV2/components/StdcmVias.tsx | 6 +- .../Map/WarpedMap/SimulationWarpedMap.tsx | 6 +- .../Map/components/TrainOnMap/TrainOnMap.tsx | 2 - front/src/common/api/osrdEditoastApi.ts | 8 +-- front/src/main/app.jsx | 2 +- .../{ConflictCardV2.tsx => ConflictCard.tsx} | 4 +- ...{ConflictsListV2.tsx => ConflictsList.tsx} | 14 ++-- front/src/modules/conflict/utils.ts | 2 +- .../InfraSelectorModalBodyStandard.tsx | 4 +- .../{v2/DestinationV2.tsx => Destination.tsx} | 12 ++-- .../{v2/OriginV2.tsx => Origin.tsx} | 13 ++-- .../{v2 => }/ViaStopDurationSelector.tsx | 4 +- .../{v2/ViasV2.tsx => Vias.tsx} | 14 ++-- .../{ItineraryV2.tsx => Itinerary.tsx} | 37 +++++----- .../Itinerary/ModalSuggestedVias.tsx | 10 +-- .../{PathfindingV2.tsx => Pathfinding.tsx} | 10 +-- .../{TypeAndPathV2.tsx => TypeAndPath.tsx} | 6 +- ...hfindingV2.spec.ts => Pathfinding.spec.ts} | 16 ++--- .../pathfinding/hooks/usePathfinding.ts | 24 +++---- front/src/modules/pathfinding/types.ts | 2 +- ...orV2.tsx => PowerRestrictionsSelector.tsx} | 4 +- .../helpers/formatPowerRestrictions.ts | 6 +- .../helpers/getRestrictionsToResize.ts | 14 ++-- .../helpers/powerRestrictionWarnings.ts | 8 +-- .../usePowerRestrictionSelectorBehaviours.ts | 18 ++--- .../hooks/usePowerRestrictionSelectorData.ts | 4 +- .../RollingStockCardButtons.tsx | 8 +-- .../useStoreDataForRollingStockSelector.ts | 4 +- .../components/AddOrEditScenarioModal.tsx | 4 +- .../ScenarioExplorer/ScenarioExplorer.tsx | 6 +- .../components/ChartHelpers/ChartHelpers.ts | 9 ++- .../ChartHelpers/enableInteractivity.tsx | 10 +-- .../ChartHelpers/getScaleDomainFromValues.ts | 2 +- ...SynchronizerV2.ts => ChartSynchronizer.ts} | 14 ++-- .../components/ChartSynchronizer/index.ts | 2 +- .../components/ChartSynchronizer/utils.ts | 6 +- .../SimulationResultsMap.tsx} | 16 ++--- .../TrainHoverPosition.tsx | 2 - ...rvesSlopesV2.tsx => SpaceCurvesSlopes.tsx} | 28 ++++---- .../components/SpaceCurvesSlopes/utils.ts | 9 +-- ...artV2.tsx => SpeedSpaceChartContainer.tsx} | 8 +-- .../SpeedSpaceChart/useSpeedSpaceChart.ts | 4 +- .../components/TimeButtons.tsx | 11 ++- .../{TrainDetailsV2.tsx => TrainDetails.tsx} | 10 +-- front/src/modules/simulationResult/types.ts | 2 +- .../modules/timesStops/TimesStopsOutput.tsx | 2 +- .../timesStops/helpers/computeMargins.ts | 4 +- front/src/modules/timesStops/helpers/utils.ts | 2 +- .../timesStops/hooks/useOutputTableData.ts | 2 +- .../DriverTrainSchedule.tsx} | 16 ++--- .../DriverTrainScheduleHeader.tsx} | 12 ++-- .../DriverTrainScheduleStop.tsx} | 8 +-- .../DriverTrainScheduleStopList.tsx} | 12 ++-- .../__tests__/utils.spec.ts | 0 .../consts.ts | 0 .../exportDriverScheduleCSV.ts | 8 +-- .../types.ts | 0 .../utils.ts | 0 ...igV2.tsx => ImportTrainScheduleConfig.tsx} | 4 +- ....tsx => ImportTrainScheduleTrainsList.tsx} | 12 ++-- .../generateTrainSchedulesPayloads.ts | 2 +- .../components/ImportTrainSchedule/index.ts | 2 +- ...2Button.tsx => AddTrainScheduleButton.tsx} | 8 +-- .../ManageTrainScheduleMap/ItineraryLayer.tsx | 6 +- ...raryMarkersV2.tsx => ItineraryMarkers.tsx} | 0 .../ManageTrainScheduleMap/RenderPopup.tsx | 16 ++--- .../ManageTrainScheduleMap/setPointIti.ts | 10 +-- .../components/ManageTrainSchedule/Map.tsx | 4 +- ...2.tsx => TimetableManageTrainSchedule.tsx} | 8 +-- .../helpers/adjustConfWithTrainToModify.ts | 6 +- .../helpers/checkCurrentConfig.ts | 9 ++- .../FilterPanel.tsx | 0 .../Timetable.tsx} | 16 ++--- .../TimetableToolbar.tsx | 0 .../TimetableTrainCard.tsx} | 6 +- .../{TimetableV2 => Timetable}/consts.ts | 0 .../{TimetableV2 => Timetable}/types.ts | 0 .../useFilterTrainSchedules.ts | 0 .../{TimetableV2 => Timetable}/utils.ts | 0 .../useFormattedOperationalPoints.ts | 6 +- .../powerRestrictionReducer.ts | 69 +++++++++---------- .../osrdconf/operationalStudiesConf/utils.ts | 18 ++--- .../osrdConfCommon/__tests__/utils.ts | 44 ++++++------ .../reducers/osrdconf/osrdConfCommon/index.ts | 46 ++++++------- .../osrdconf/osrdConfCommon/selectors.ts | 14 ++-- .../stdcmConf/stdcmConfReducers.spec.ts | 4 +- front/src/reducers/osrdconf/types.ts | 6 +- .../operationalStudies/_scenario.scss | 5 +- front/src/utils/date.ts | 14 +--- front/tests/pages/home-page-model.ts | 3 - 111 files changed, 486 insertions(+), 534 deletions(-) rename front/src/applications/operationalStudies/views/{v2/ImportTrainScheduleV2.tsx => ImportTrainSchedule.tsx} (79%) rename front/src/applications/operationalStudies/views/{v2/ManageTrainScheduleV2.tsx => ManageTrainSchedule.tsx} (90%) rename front/src/applications/operationalStudies/views/{v2/ScenarioV2.tsx => Scenario.tsx} (94%) rename front/src/applications/operationalStudies/views/{v2/SimulationResultsV2.tsx => SimulationResults.tsx} (89%) rename front/src/applications/stdcm/components/{SimulationReportSheetV2.tsx => SimulationReportSheet.tsx} (98%) rename front/src/modules/conflict/components/{ConflictCardV2.tsx => ConflictCard.tsx} (95%) rename front/src/modules/conflict/components/{ConflictsListV2.tsx => ConflictsList.tsx} (87%) rename front/src/modules/pathfinding/components/Itinerary/DisplayItinerary/{v2/DestinationV2.tsx => Destination.tsx} (86%) rename front/src/modules/pathfinding/components/Itinerary/DisplayItinerary/{v2/OriginV2.tsx => Origin.tsx} (94%) rename front/src/modules/pathfinding/components/Itinerary/DisplayItinerary/{v2 => }/ViaStopDurationSelector.tsx (93%) rename front/src/modules/pathfinding/components/Itinerary/DisplayItinerary/{v2/ViasV2.tsx => Vias.tsx} (91%) rename front/src/modules/pathfinding/components/Itinerary/{ItineraryV2.tsx => Itinerary.tsx} (84%) rename front/src/modules/pathfinding/components/Pathfinding/{PathfindingV2.tsx => Pathfinding.tsx} (93%) rename front/src/modules/pathfinding/components/Pathfinding/{TypeAndPathV2.tsx => TypeAndPath.tsx} (98%) rename front/src/modules/pathfinding/components/Pathfinding/__tests__/{PathfindingV2.spec.ts => Pathfinding.spec.ts} (94%) rename front/src/modules/powerRestriction/components/{PowerRestrictionsSelectorV2.tsx => PowerRestrictionsSelector.tsx} (98%) rename front/src/modules/simulationResult/components/ChartSynchronizer/{ChartSynchronizerV2.ts => ChartSynchronizer.ts} (89%) rename front/src/modules/simulationResult/components/{SimulationResultsMapV2.tsx => SimulationResultsMap/SimulationResultsMap.tsx} (96%) rename front/src/modules/simulationResult/components/SpaceCurvesSlopes/{SpaceCurvesSlopesV2.tsx => SpaceCurvesSlopes.tsx} (91%) rename front/src/modules/simulationResult/components/SpeedSpaceChart/{SpeedSpaceChartV2.tsx => SpeedSpaceChartContainer.tsx} (96%) rename front/src/modules/simulationResult/components/{TrainDetailsV2.tsx => TrainDetails.tsx} (95%) rename front/src/modules/trainschedule/components/{DriverTrainScheduleV2/DriverTrainScheduleV2.tsx => DriverTrainSchedule/DriverTrainSchedule.tsx} (84%) rename front/src/modules/trainschedule/components/{DriverTrainScheduleV2/DriverTrainScheduleHeaderV2.tsx => DriverTrainSchedule/DriverTrainScheduleHeader.tsx} (94%) rename front/src/modules/trainschedule/components/{DriverTrainScheduleV2/DriverTrainScheduleStopV2.tsx => DriverTrainSchedule/DriverTrainScheduleStop.tsx} (95%) rename front/src/modules/trainschedule/components/{DriverTrainScheduleV2/DriverTrainScheduleStopListV2.tsx => DriverTrainSchedule/DriverTrainScheduleStopList.tsx} (92%) rename front/src/modules/trainschedule/components/{DriverTrainScheduleV2 => DriverTrainSchedule}/__tests__/utils.spec.ts (100%) rename front/src/modules/trainschedule/components/{DriverTrainScheduleV2 => DriverTrainSchedule}/consts.ts (100%) rename front/src/modules/trainschedule/components/{DriverTrainScheduleV2 => DriverTrainSchedule}/exportDriverScheduleCSV.ts (97%) rename front/src/modules/trainschedule/components/{DriverTrainScheduleV2 => DriverTrainSchedule}/types.ts (100%) rename front/src/modules/trainschedule/components/{DriverTrainScheduleV2 => DriverTrainSchedule}/utils.ts (100%) rename front/src/modules/trainschedule/components/ImportTrainSchedule/{ImportTrainScheduleConfigV2.tsx => ImportTrainScheduleConfig.tsx} (99%) rename front/src/modules/trainschedule/components/ImportTrainSchedule/{ImportTrainScheduleTrainsListV2.tsx => ImportTrainScheduleTrainsList.tsx} (92%) rename front/src/modules/trainschedule/components/ManageTrainSchedule/{AddTrainScheduleV2Button.tsx => AddTrainScheduleButton.tsx} (95%) rename front/src/modules/trainschedule/components/ManageTrainSchedule/ManageTrainScheduleMap/{ItineraryMarkersV2.tsx => ItineraryMarkers.tsx} (100%) rename front/src/modules/trainschedule/components/ManageTrainSchedule/{TimetableManageTrainScheduleV2.tsx => TimetableManageTrainSchedule.tsx} (94%) rename front/src/modules/trainschedule/components/{TimetableV2 => Timetable}/FilterPanel.tsx (100%) rename front/src/modules/trainschedule/components/{TimetableV2/TimetableV2.tsx => Timetable/Timetable.tsx} (95%) rename front/src/modules/trainschedule/components/{TimetableV2 => Timetable}/TimetableToolbar.tsx (100%) rename front/src/modules/trainschedule/components/{TimetableV2/TimetableTrainCardV2.tsx => Timetable/TimetableTrainCard.tsx} (98%) rename front/src/modules/trainschedule/components/{TimetableV2 => Timetable}/consts.ts (100%) rename front/src/modules/trainschedule/components/{TimetableV2 => Timetable}/types.ts (100%) rename front/src/modules/trainschedule/components/{TimetableV2 => Timetable}/useFilterTrainSchedules.ts (100%) rename front/src/modules/trainschedule/components/{TimetableV2 => Timetable}/utils.ts (100%) diff --git a/front/src/applications/operationalStudies/__tests__/sampleData.ts b/front/src/applications/operationalStudies/__tests__/sampleData.ts index 8f7558ead1f..c7b890678cc 100644 --- a/front/src/applications/operationalStudies/__tests__/sampleData.ts +++ b/front/src/applications/operationalStudies/__tests__/sampleData.ts @@ -3,7 +3,7 @@ import type { ElectricalBoundariesData, ElectricalProfileValue, ElectricalRangesData, - ElectrificationRangeV2, + ElectrificationRange, ElectrificationValue, PositionData, } from 'applications/operationalStudies/types'; @@ -242,7 +242,7 @@ export const electricalProfileRangesDataShort: ElectricalRangesData const stepWithoutSecondaryCode = omit(step, ['secondary_code']); - // TODO DROP V1: we should store the offset in mm in the store if ('track' in stepWithoutSecondaryCode) { stepWithoutSecondaryCode.offset = mmToM(stepWithoutSecondaryCode.offset!); } @@ -259,7 +258,7 @@ const useSetupItineraryForTrainUpdate = ( } } - adjustConfWithTrainToModifyV2( + adjustConfWithTrainToModify( trainSchedule, pathSteps || computeBasePathSteps(trainSchedule), rollingStock?.id, diff --git a/front/src/applications/operationalStudies/hooks/useSimulationResults.ts b/front/src/applications/operationalStudies/hooks/useSimulationResults.ts index fd7005ad22f..960c24a61ab 100644 --- a/front/src/applications/operationalStudies/hooks/useSimulationResults.ts +++ b/front/src/applications/operationalStudies/hooks/useSimulationResults.ts @@ -5,12 +5,12 @@ import { useInfraID, useOsrdConfSelectors } from 'common/osrdContext'; import useSpeedSpaceChart from 'modules/simulationResult/components/SpeedSpaceChart/useSpeedSpaceChart'; import { getSelectedTrainId } from 'reducers/osrdsimulation/selectors'; -import type { SimulationResults } from '../types'; +import type { SimulationResultsData } from '../types'; /** * Prepare data to be used in simulation results */ -const useSimulationResults = (): SimulationResults => { +const useSimulationResults = (): SimulationResultsData => { const infraId = useInfraID(); const { getElectricalProfileSetId } = useOsrdConfSelectors(); const electricalProfileSetId = useSelector(getElectricalProfileSetId); diff --git a/front/src/applications/operationalStudies/types.ts b/front/src/applications/operationalStudies/types.ts index d36ba4678fa..77d08859eee 100644 --- a/front/src/applications/operationalStudies/types.ts +++ b/front/src/applications/operationalStudies/types.ts @@ -75,13 +75,13 @@ export type PositionData = { }; /** Start and stop are in meters */ -export type ElectrificationRangeV2 = { - electrificationUsage: ElectrificationUsageV2; +export type ElectrificationRange = { + electrificationUsage: ElectrificationUsage; start: number; stop: number; }; -type ElectrificationUsageV2 = ElectrificationValue & +type ElectrificationUsage = ElectrificationValue & SimulationResponseSuccess['electrical_profiles']['values'][number]; export type BoundariesData = { @@ -114,7 +114,7 @@ export type ElectricalProfileValue = Extract< /** Electrifications start and stop are in meters */ export type PathPropertiesFormatted = { - electrifications: ElectrificationRangeV2[]; + electrifications: ElectrificationRange[]; curves: PositionData<'radius'>[]; slopes: PositionData<'gradient'>[]; operationalPoints: NonNullable; @@ -122,7 +122,7 @@ export type PathPropertiesFormatted = { voltages: RangedValue[]; }; -export type PowerRestrictionV2 = ArrayElement; +export type PowerRestriction = ArrayElement; export type SimulationResponseSuccess = Extract; @@ -131,7 +131,7 @@ export type ElectrificationVoltage = { voltage?: string; }; -export type SimulationResults = { +export type SimulationResultsData = { selectedTrainSchedule?: TrainScheduleResult; selectedTrainRollingStock?: RollingStockWithLiveries; selectedTrainPowerRestrictions: LayerData[]; diff --git a/front/src/applications/operationalStudies/utils.ts b/front/src/applications/operationalStudies/utils.ts index 102fab66d09..518c74ead93 100644 --- a/front/src/applications/operationalStudies/utils.ts +++ b/front/src/applications/operationalStudies/utils.ts @@ -17,7 +17,7 @@ import type { ElectricalBoundariesData, ElectricalProfileValue, ElectricalRangesData, - ElectrificationRangeV2, + ElectrificationRange, ElectrificationValue, PathPropertiesFormatted, PositionData, @@ -77,7 +77,7 @@ export const transformBoundariesDataToRangesData = < boundariesData: ElectricalBoundariesData, pathLength: number ): ElectricalRangesData[] => { - // TODO DROP V1 : remove electrical profiles + // TODO : remove electrical profiles const formatedData = boundariesData.boundaries.map((boundary, index) => ({ start: index === 0 ? 0 : mmToM(boundariesData.boundaries[index - 1]), stop: mmToM(boundary), @@ -99,7 +99,7 @@ export const transformBoundariesDataToRangesData = < export const formatElectrificationRanges = ( electrifications: ElectricalRangesData[], electricalProfiles: ElectricalRangesData[] -): ElectrificationRangeV2[] => +): ElectrificationRange[] => // Electrifications can be of three types, electricalProfiles only two, so we know electrifications // will always be at least as long as electricalProfiles so we can use it as the main array electrifications.map((currentElectrification, index) => { diff --git a/front/src/applications/operationalStudies/views/v2/ImportTrainScheduleV2.tsx b/front/src/applications/operationalStudies/views/ImportTrainSchedule.tsx similarity index 79% rename from front/src/applications/operationalStudies/views/v2/ImportTrainScheduleV2.tsx rename to front/src/applications/operationalStudies/views/ImportTrainSchedule.tsx index f01a5cecf06..2e86b2cc56c 100644 --- a/front/src/applications/operationalStudies/views/v2/ImportTrainScheduleV2.tsx +++ b/front/src/applications/operationalStudies/views/ImportTrainSchedule.tsx @@ -6,12 +6,12 @@ import type { ImportedTrainSchedule } from 'applications/operationalStudies/type import { osrdEditoastApi } from 'common/api/osrdEditoastApi'; import type { TrainScheduleBase } from 'common/api/osrdEditoastApi'; import { Loader } from 'common/Loaders'; -import { ImportTrainScheduleConfigV2 } from 'modules/trainschedule/components/ImportTrainSchedule'; -import ImportTrainScheduleTrainsListV2 from 'modules/trainschedule/components/ImportTrainSchedule/ImportTrainScheduleTrainsListV2'; +import { ImportTrainScheduleConfig } from 'modules/trainschedule/components/ImportTrainSchedule'; +import ImportTrainScheduleTrainsList from 'modules/trainschedule/components/ImportTrainSchedule/ImportTrainScheduleTrainsList'; import { setFailure } from 'reducers/main'; import { useAppDispatch } from 'store'; -const ImportTrainScheduleV2 = ({ timetableId }: { timetableId: number }) => { +const ImportTrainSchedule = ({ timetableId }: { timetableId: number }) => { const dispatch = useAppDispatch(); const { t } = useTranslation(['rollingstock']); const [trainsList, setTrainsList] = useState([]); @@ -36,12 +36,12 @@ const ImportTrainScheduleV2 = ({ timetableId }: { timetableId: number }) => { return rollingStocks ? (
- - { ); }; -export default ImportTrainScheduleV2; +export default ImportTrainSchedule; diff --git a/front/src/applications/operationalStudies/views/v2/ManageTrainScheduleV2.tsx b/front/src/applications/operationalStudies/views/ManageTrainSchedule.tsx similarity index 90% rename from front/src/applications/operationalStudies/views/v2/ManageTrainScheduleV2.tsx rename to front/src/applications/operationalStudies/views/ManageTrainSchedule.tsx index a750a3d5730..2901edc1660 100644 --- a/front/src/applications/operationalStudies/views/v2/ManageTrainScheduleV2.tsx +++ b/front/src/applications/operationalStudies/views/ManageTrainSchedule.tsx @@ -14,10 +14,10 @@ import { useOsrdConfSelectors } from 'common/osrdContext'; import { useStoreDataForSpeedLimitByTagSelector } from 'common/SpeedLimitByTagSelector/useStoreDataForSpeedLimitByTagSelector'; import Tabs from 'common/Tabs'; import IncompatibleConstraints from 'modules/pathfinding/components/IncompatibleConstraints'; -import ItineraryV2 from 'modules/pathfinding/components/Itinerary/ItineraryV2'; +import Itinerary from 'modules/pathfinding/components/Itinerary/Itinerary'; import getPathVoltages from 'modules/pathfinding/helpers/getPathVoltages'; import { upsertPathStepsInOPs } from 'modules/pathfinding/utils'; -import PowerRestrictionsSelectorV2 from 'modules/powerRestriction/components/PowerRestrictionsSelectorV2'; +import PowerRestrictionsSelector from 'modules/powerRestriction/components/PowerRestrictionsSelector'; import RollingStock2Img from 'modules/rollingStock/components/RollingStock2Img'; import { RollingStockSelector } from 'modules/rollingStock/components/RollingStockSelector'; import { useStoreDataForRollingStockSelector } from 'modules/rollingStock/components/RollingStockSelector/useStoreDataForRollingStockSelector'; @@ -28,16 +28,16 @@ import SimulationSettings from 'modules/trainschedule/components/ManageTrainSche import TrainSettings from 'modules/trainschedule/components/ManageTrainSchedule/TrainSettings'; import { formatKmValue } from 'utils/strings'; -type ManageTrainScheduleV2Props = { +type ManageTrainScheduleProps = { trainIdToEdit?: number; }; -const ManageTrainScheduleV2 = ({ trainIdToEdit }: ManageTrainScheduleV2Props) => { +const ManageTrainSchedule = ({ trainIdToEdit }: ManageTrainScheduleProps) => { const { t } = useTranslation(['operationalStudies/manageTrainSchedule']); - const { getOriginV2, getDestinationV2, getPathSteps, getConstraintDistribution, getStartTime } = + const { getOrigin, getDestination, getPathSteps, getConstraintDistribution, getStartTime } = useOsrdConfSelectors(); - const origin = useSelector(getOriginV2); - const destination = useSelector(getDestinationV2); + const origin = useSelector(getOrigin); + const destination = useSelector(getDestination); const pathSteps = useSelector(getPathSteps); const constraintDistribution = useSelector(getConstraintDistribution); const startTime = useSelector(getStartTime); @@ -117,7 +117,7 @@ const ManageTrainScheduleV2 = ({ trainIdToEdit }: ManageTrainScheduleV2Props) => content: (
- +
@@ -163,7 +163,7 @@ const ManageTrainScheduleV2 = ({ trainIdToEdit }: ManageTrainScheduleV2Props) => constraintDistribution={constraintDistribution} /> {rollingStock && isElectric(rollingStock.effort_curves.modes) && pathProperties && ( - ); }; -export default ManageTrainScheduleV2; +export default ManageTrainSchedule; diff --git a/front/src/applications/operationalStudies/views/Project.tsx b/front/src/applications/operationalStudies/views/Project.tsx index 9a46135ff7c..1c9f4953479 100644 --- a/front/src/applications/operationalStudies/views/Project.tsx +++ b/front/src/applications/operationalStudies/views/Project.tsx @@ -50,7 +50,7 @@ export default function Project() { const [isLoading, setIsLoading] = useState(true); const { projectId: urlProjectId } = useParams() as ProjectParams; - const [deleteStudyV2] = + const [deleteStudy] = osrdEditoastApi.endpoints.deleteProjectsByProjectIdStudiesAndStudyId.useMutation(); const [postSearch] = osrdEditoastApi.endpoints.postSearch.useMutation(); @@ -69,7 +69,7 @@ export default function Project() { toggleSelection: toggleStudySelection, deleteItems, } = useMultiSelection((studyId) => { - deleteStudyV2({ projectId: projectId!, studyId }); + deleteStudy({ projectId: projectId!, studyId }); }); const handleDeleteStudy = () => { diff --git a/front/src/applications/operationalStudies/views/v2/ScenarioV2.tsx b/front/src/applications/operationalStudies/views/Scenario.tsx similarity index 94% rename from front/src/applications/operationalStudies/views/v2/ScenarioV2.tsx rename to front/src/applications/operationalStudies/views/Scenario.tsx index 5971906ae93..9e45c1c06df 100644 --- a/front/src/applications/operationalStudies/views/v2/ScenarioV2.tsx +++ b/front/src/applications/operationalStudies/views/Scenario.tsx @@ -20,16 +20,16 @@ import { useModal } from 'common/BootstrapSNCF/ModalSNCF'; import NavBarSNCF from 'common/BootstrapSNCF/NavBarSNCF'; import AddAndEditScenarioModal from 'modules/scenario/components/AddOrEditScenarioModal'; import ScenarioLoaderMessage from 'modules/scenario/components/ScenarioLoaderMessage'; -import TimetableManageTrainScheduleV2 from 'modules/trainschedule/components/ManageTrainSchedule/TimetableManageTrainScheduleV2'; -import TimetableV2 from 'modules/trainschedule/components/TimetableV2/TimetableV2'; +import TimetableManageTrainSchedule from 'modules/trainschedule/components/ManageTrainSchedule/TimetableManageTrainSchedule'; +import Timetable from 'modules/trainschedule/components/Timetable/Timetable'; import type { RootState } from 'reducers'; import { useAppDispatch } from 'store'; import { concatMap, mapBy } from 'utils/types'; -import ImportTrainScheduleV2 from './ImportTrainScheduleV2'; -import ManageTrainScheduleV2 from './ManageTrainScheduleV2'; -import SimulationResultsV2 from './SimulationResultsV2'; -import useScenarioData from '../../hooks/useScenarioData'; +import ImportTrainSchedule from './ImportTrainSchedule'; +import ManageTrainSchedule from './ManageTrainSchedule'; +import SimulationResults from './SimulationResults'; +import useScenarioData from '../hooks/useScenarioData'; const Scenario = () => { const { t } = useTranslation('operationalStudies/scenario'); @@ -222,7 +222,7 @@ const Scenario = () => { <> {displayTrainScheduleManagement !== MANAGE_TRAIN_SCHEDULE_TYPES.none && infra && ( - { /> )} {infra && ( - { {(displayTrainScheduleManagement === MANAGE_TRAIN_SCHEDULE_TYPES.add || displayTrainScheduleManagement === MANAGE_TRAIN_SCHEDULE_TYPES.edit) && (
- +
)} {displayTrainScheduleManagement === MANAGE_TRAIN_SCHEDULE_TYPES.import && (
- +
)}
@@ -305,7 +305,7 @@ const Scenario = () => { ) : ( isInfraLoaded && infra && ( - { +}: SimulationResultsProps) => { const { t } = useTranslation('simulation'); const dispatch = useAppDispatch(); const isUpdating = useSelector(getIsUpdating); @@ -117,7 +120,7 @@ const SimulationResultsV2 = ({ useEffect(() => { if (trainSimulation && trainSimulation.status === 'success') { const { positions } = trainSimulation.final_output; - const newPositionsScaleDomain = getScaleDomainFromValuesV2(positions); + const newPositionsScaleDomain = getScaleDomainFromValues(positions); setPositionScaleDomain({ initial: newPositionsScaleDomain, current: newPositionsScaleDomain, @@ -143,7 +146,7 @@ const SimulationResultsV2 = ({
{trainUsedForProjectionSpaceTimeData && ( - + )}
@@ -195,7 +198,7 @@ const SimulationResultsV2 = ({ height: `${speedSpaceChartContainerHeight + HANDLE_TAB_RESIZE_HEIGHT}px`, }} > - -
- - ((scenarioId) => { - deleteScenarioV2({ projectId: projectId!, studyId: studyId!, scenarioId }); + deleteScenario({ projectId: projectId!, studyId: studyId!, scenarioId }); }); const handleDeleteScenario = () => { if (selectedScenarioIds.length > 0 && studyId && projectId) { @@ -161,7 +161,7 @@ export default function Study() { console.error(error); } } else { - setScenariosList(scenariosV2?.results || []); + setScenariosList(scenarios?.results || []); } setIsLoading(false); } @@ -197,7 +197,7 @@ export default function Study() { useEffect(() => { getScenarioList(); - }, [sortOption, filter, scenariosV2]); + }, [sortOption, filter, scenarios]); return ( <> diff --git a/front/src/applications/stdcm/components/SimulationReportSheetV2.tsx b/front/src/applications/stdcm/components/SimulationReportSheet.tsx similarity index 98% rename from front/src/applications/stdcm/components/SimulationReportSheetV2.tsx rename to front/src/applications/stdcm/components/SimulationReportSheet.tsx index 86f218fe58f..d9dcdad3a45 100644 --- a/front/src/applications/stdcm/components/SimulationReportSheetV2.tsx +++ b/front/src/applications/stdcm/components/SimulationReportSheet.tsx @@ -4,13 +4,13 @@ import { useTranslation } from 'react-i18next'; import iconAlert from 'assets/simulationReportSheet/icon_alert_fill.png'; import logoSNCF from 'assets/simulationReportSheet/logo_sncf_reseau.png'; -import { formatDateToString, formatDayV2 } from 'utils/date'; +import { formatDateToString, formatDay } from 'utils/date'; import styles from './SimulationReportStyleSheet'; import type { SimulationReportSheetProps } from '../types'; import { extractSpeedLimit, getStopDurationTime } from '../utils/formatSimulationReportSheet'; -const SimulationReportSheetV2 = ({ +const SimulationReportSheet = ({ stdcmData, simulationReportSheetNumber, mapCanvas, @@ -70,7 +70,7 @@ const SimulationReportSheetV2 = ({ {t('applicationDate')} - {formatDayV2(departureTime)} + {formatDay(departureTime)} {t('referencePath')} {fakeInformation.path_number1} @@ -347,4 +347,4 @@ const SimulationReportSheetV2 = ({ ); }; -export default SimulationReportSheetV2; +export default SimulationReportSheet; diff --git a/front/src/applications/stdcm/utils/formatStdcmConfV2.ts b/front/src/applications/stdcm/utils/formatStdcmConfV2.ts index 9d974913c5c..4f6132ac349 100644 --- a/front/src/applications/stdcm/utils/formatStdcmConfV2.ts +++ b/front/src/applications/stdcm/utils/formatStdcmConfV2.ts @@ -46,7 +46,7 @@ export const checkStdcmConf = ( pathSteps, timetableID, speedLimitByTag, - rollingStockComfortV2, + rollingStockComfort, infraID, rollingStockID, maximumRunTime, @@ -191,7 +191,6 @@ export const checkStdcmConf = ( if ('track' in stepLocation) { return { duration, - // TODO DROP V1: we should store the offset in mm in the store location: { track: stepLocation.track, offset: mToMm(stepLocation.offset) }, timing_data: timingData, }; @@ -209,7 +208,7 @@ export const checkStdcmConf = ( infraId: infraID!, rollingStockId: rollingStockID!, timetableId: timetableID!, - rollingStockComfort: rollingStockComfortV2, + rollingStockComfort, path, ...(!stdcmV2Activated && { startTime: originTime!, diff --git a/front/src/applications/stdcm/views/StdcmConfig.tsx b/front/src/applications/stdcm/views/StdcmConfig.tsx index 2bad84eaea7..5e368e11693 100644 --- a/front/src/applications/stdcm/views/StdcmConfig.tsx +++ b/front/src/applications/stdcm/views/StdcmConfig.tsx @@ -12,7 +12,7 @@ import { osrdEditoastApi } from 'common/api/osrdEditoastApi'; import { useInfraID, useOsrdConfSelectors } from 'common/osrdContext'; import SpeedLimitByTagSelector from 'common/SpeedLimitByTagSelector/SpeedLimitByTagSelector'; import { useStoreDataForSpeedLimitByTagSelector } from 'common/SpeedLimitByTagSelector/useStoreDataForSpeedLimitByTagSelector'; -import ItineraryV2 from 'modules/pathfinding/components/Itinerary/ItineraryV2'; +import Itinerary from 'modules/pathfinding/components/Itinerary/Itinerary'; import { RollingStockSelector } from 'modules/rollingStock/components/RollingStockSelector'; import { useStoreDataForRollingStockSelector } from 'modules/rollingStock/components/RollingStockSelector/useStoreDataForRollingStockSelector'; import ScenarioExplorer from 'modules/scenario/components/ScenarioExplorer'; @@ -43,15 +43,15 @@ const StdcmConfig = ({ getScenarioID, getStudyID, getTimetableID, - getOriginV2, - getDestinationV2, + getOrigin, + getDestination, } = useOsrdConfSelectors(); const projectID = useSelector(getProjectID); const studyID = useSelector(getStudyID); const scenarioID = useSelector(getScenarioID); const timetableID = useSelector(getTimetableID); - const originV2 = useSelector(getOriginV2); - const destinationV2 = useSelector(getDestinationV2); + const origin = useSelector(getOrigin); + const destination = useSelector(getDestination); const infraID = useInfraID(); const [showMap, setShowMap] = useState(true); @@ -77,7 +77,7 @@ const StdcmConfig = ({ ); const disabledApplyButton = useMemo(() => { - if (!originV2 || !destinationV2 || !osrdconf.originDate) return true; + if (!origin || !destination || !osrdconf.originDate) return true; return ( infra?.state !== 'CACHED' || @@ -87,7 +87,7 @@ const StdcmConfig = ({ osrdconf.originTime > osrdconf.originUpperBoundTime) || !osrdconf.rollingStockID ); - }, [infra, osrdconf, originV2, destinationV2]); + }, [infra, osrdconf, origin, destination]); const handleClick = () => { launchStdcmRequest(); @@ -129,7 +129,7 @@ const StdcmConfig = ({ dispatchUpdateSpeedLimitByTag={dispatchUpdateSpeedLimitByTag} /> - { const { t } = useTranslation(['stdcm']); const [speedSpaceChartContainerHeight, setSpeedSpaceChartContainerHeight] = @@ -74,7 +72,7 @@ const StcdmResultsV2 = ({ mapCanvas, stdcmV2Results, pathProperties }: StcdmResu }} > {speedSpaceChartData ? ( - (undefined); diff --git a/front/src/applications/stdcmV2/components/StdcmDestination.tsx b/front/src/applications/stdcmV2/components/StdcmDestination.tsx index 9db78f9caec..a15eb35b25c 100644 --- a/front/src/applications/stdcmV2/components/StdcmDestination.tsx +++ b/front/src/applications/stdcmV2/components/StdcmDestination.tsx @@ -25,7 +25,7 @@ const StdcmDestination = ({ const { t } = useTranslation('stdcm'); const dispatch = useAppDispatch(); const { - updateDestinationV2, + updateDestination, updateDestinationArrival, updateDestinationArrivalType, updateDestinationTolerances, @@ -58,7 +58,7 @@ const StdcmDestination = ({ }, [destination]); const updateDestinationPoint = (pathStep: PathStep | null) => { - dispatch(updateDestinationV2(pathStep)); + dispatch(updateDestination(pathStep)); }; const onDestinationArrivalChange = (arrival: string) => { diff --git a/front/src/applications/stdcmV2/components/StdcmOrigin.tsx b/front/src/applications/stdcmV2/components/StdcmOrigin.tsx index 03f714edd7a..21b5d88efb8 100644 --- a/front/src/applications/stdcmV2/components/StdcmOrigin.tsx +++ b/front/src/applications/stdcmV2/components/StdcmOrigin.tsx @@ -25,7 +25,7 @@ const StdcmOrigin = ({ const { t } = useTranslation('stdcm'); const dispatch = useAppDispatch(); - const { updateOriginV2, updateOriginArrival, updateOriginArrivalType, updateOriginTolerances } = + const { updateOrigin, updateOriginArrival, updateOriginArrivalType, updateOriginTolerances } = useOsrdConfActions() as StdcmConfSliceActions; const { originArrival, originToleranceValues } = useMemo( @@ -48,8 +48,8 @@ const StdcmOrigin = ({ })); }, [origin]); - const updateOriginV2Point = (pathStep: PathStep | null) => { - dispatch(updateOriginV2(pathStep)); + const updateOriginPoint = (pathStep: PathStep | null) => { + dispatch(updateOrigin(pathStep)); }; const onOriginArrivalChange = (arrival: string) => { @@ -79,7 +79,7 @@ const StdcmOrigin = ({ >
{ - dispatch(deleteViaV2(index)); + dispatch(deleteVia(index)); }; const addViaOnClick = (pathStepIndex: number) => { diff --git a/front/src/common/Map/WarpedMap/SimulationWarpedMap.tsx b/front/src/common/Map/WarpedMap/SimulationWarpedMap.tsx index 76349ce6848..a5077e56cb4 100644 --- a/front/src/common/Map/WarpedMap/SimulationWarpedMap.tsx +++ b/front/src/common/Map/WarpedMap/SimulationWarpedMap.tsx @@ -85,7 +85,7 @@ const SimulationWarpedMap = ({ // const [localPositionValues, setLocalPositionValues] = useState>( // {} as PositionsSpeedTimes // ); - // useChartSynchronizerV2( + // useChartSynchronizer( // debounce((timePosition, positionValues) => { // setLocalTimePosition(timePosition); // setLocalPositionValues(positionValues); @@ -183,7 +183,7 @@ const SimulationWarpedMap = ({ }, [itineraryState, state]); // Trains handling: - // TODO: fix warped map - adapt this part with simulations results v2 + // TODO: fix warped map - adapt this part with simulations results // const trainsIndex = useMemo(() => keyBy(simulation.trains as Train[], 'id'), [simulation.trains]); // const trainsPositionsState: AsyncMemoState< // (TrainPosition & { train: Train; isSelected?: boolean })[] @@ -297,7 +297,7 @@ const SimulationWarpedMap = ({ osrdData={state.osrd} osmData={state.osm} itinerary={warpedItinerary} - // TODO: fix warped map - adapt this part with simulations results v2 + // TODO: fix warped map - adapt this part with simulations results // trainsPositions={getAsyncMemoData(trainsPositionsState) || undefined} boundingBox={mode === 'auto' ? syncedBoundingBox : undefined} /> diff --git a/front/src/common/Map/components/TrainOnMap/TrainOnMap.tsx b/front/src/common/Map/components/TrainOnMap/TrainOnMap.tsx index 59cf192a4f3..5534bb16705 100644 --- a/front/src/common/Map/components/TrainOnMap/TrainOnMap.tsx +++ b/front/src/common/Map/components/TrainOnMap/TrainOnMap.tsx @@ -61,8 +61,6 @@ type TrainOnMapProps = { viewport: Viewport; }; -// TO DO DROP V1: remove this comment -// TrainOnMap corresponds to TrainHoverPositionV2 const TrainOnMap = ({ trainInfo, geojsonPath, viewport, trainSimulation }: TrainOnMapProps) => { const zoomLengthFactor = getZoomPowerOf2LengthFactor(viewport); diff --git a/front/src/common/api/osrdEditoastApi.ts b/front/src/common/api/osrdEditoastApi.ts index eda7337d153..6b49ed8775c 100644 --- a/front/src/common/api/osrdEditoastApi.ts +++ b/front/src/common/api/osrdEditoastApi.ts @@ -33,13 +33,13 @@ const osrdEditoastApi = generatedEditoastApi.enhanceEndpoints({ }), }, deleteTrainSchedule: { - // As we always use all get trainschedule v2 endpoints after updating the timetable, - // we don't want to invalidate the trainschedulev2 tag here to prevent multiple calls + // As we always use all get trainschedule endpoints after updating the timetable, + // we don't want to invalidate the trainschedule tag here to prevent multiple calls invalidatesTags: ['timetable', 'scenarios'], }, postTimetableByIdTrainSchedule: { - // As we always use all get trainschedule v2 endpoints after updating the timetable, - // we don't want to invalidate the trainschedulev2 tag here to prevent multiple calls + // As we always use all get trainschedule endpoints after updating the timetable, + // we don't want to invalidate the trainschedule tag here to prevent multiple calls invalidatesTags: ['timetable', 'scenarios'], }, // Invalidate the children count and last update timestamp diff --git a/front/src/main/app.jsx b/front/src/main/app.jsx index 868902c9a90..0fe86030516 100644 --- a/front/src/main/app.jsx +++ b/front/src/main/app.jsx @@ -6,8 +6,8 @@ import 'i18n'; import HomeEditor from 'applications/editor/Home'; import HomeOperationalStudies from 'applications/operationalStudies/Home'; import Project from 'applications/operationalStudies/views/Project'; +import Scenario from 'applications/operationalStudies/views/Scenario'; import Study from 'applications/operationalStudies/views/Study'; -import Scenario from 'applications/operationalStudies/views/v2/ScenarioV2'; import HomeMap from 'applications/referenceMap/Home'; import HomeRollingStockEditor from 'applications/rollingStockEditor/Home'; import HomeStdcm from 'applications/stdcm/Home'; diff --git a/front/src/modules/conflict/components/ConflictCardV2.tsx b/front/src/modules/conflict/components/ConflictCard.tsx similarity index 95% rename from front/src/modules/conflict/components/ConflictCardV2.tsx rename to front/src/modules/conflict/components/ConflictCard.tsx index b6a39a0bba0..67fba472fc8 100644 --- a/front/src/modules/conflict/components/ConflictCardV2.tsx +++ b/front/src/modules/conflict/components/ConflictCard.tsx @@ -5,7 +5,7 @@ import { formatToIsoDate } from 'utils/date'; import type { ConflictWithTrainNames } from '../types'; -const ConflictCardV2 = ({ +const ConflictCard = ({ conflict, onConflictClick, }: { @@ -45,4 +45,4 @@ const ConflictCardV2 = ({ ); }; -export default ConflictCardV2; +export default ConflictCard; diff --git a/front/src/modules/conflict/components/ConflictsListV2.tsx b/front/src/modules/conflict/components/ConflictsList.tsx similarity index 87% rename from front/src/modules/conflict/components/ConflictsListV2.tsx rename to front/src/modules/conflict/components/ConflictsList.tsx index 606c8b1cb03..123cec51b81 100644 --- a/front/src/modules/conflict/components/ConflictsListV2.tsx +++ b/front/src/modules/conflict/components/ConflictsList.tsx @@ -4,13 +4,13 @@ import cx from 'classnames'; import { useTranslation } from 'react-i18next'; import type { Conflict } from 'common/api/osrdEditoastApi'; -import type { TrainScheduleWithDetails } from 'modules/trainschedule/components/TimetableV2/types'; +import type { TrainScheduleWithDetails } from 'modules/trainschedule/components/Timetable/types'; -import ConflictCardV2 from './ConflictCardV2'; +import ConflictCard from './ConflictCard'; import type { ConflictWithTrainNames } from '../types'; import addTrainNamesToConflicts from '../utils'; -type ConflictsListV2Props = { +type ConflictsListProps = { conflicts: Conflict[]; expanded: boolean; trainSchedulesDetails: TrainScheduleWithDetails[]; @@ -18,13 +18,13 @@ type ConflictsListV2Props = { onConflictClick: (conflict: ConflictWithTrainNames) => void; }; -const ConflictsListV2 = ({ +const ConflictsList = ({ conflicts, expanded, trainSchedulesDetails, toggleConflictsList, onConflictClick, -}: ConflictsListV2Props) => { +}: ConflictsListProps) => { const { t } = useTranslation(['operationalStudies/scenario']); const enrichedConflicts = useMemo( () => addTrainNamesToConflicts(conflicts, trainSchedulesDetails), @@ -51,7 +51,7 @@ const ConflictsListV2 = ({
{enrichedConflicts.map((conflict, index) => ( - void; }; -const DestinationV2 = ({ zoomToFeaturePoint }: DestinationProps) => { - const { getDestinationV2 } = useOsrdConfSelectors(); - const { updateDestinationV2 } = useOsrdConfActions(); - const destination = useSelector(getDestinationV2); +const Destination = ({ zoomToFeaturePoint }: DestinationProps) => { + const { getDestination } = useOsrdConfSelectors(); + const { updateDestination } = useOsrdConfActions(); + const destination = useSelector(getDestination); const dispatch = useDispatch(); const { t } = useTranslation(['operationalStudies/manageTrainSchedule']); @@ -51,7 +51,7 @@ const DestinationV2 = ({ zoomToFeaturePoint }: DestinationProps) => { className="btn btn-sm btn-only-icon btn-white ml-auto" type="button" onClick={() => { - dispatch(updateDestinationV2(null)); + dispatch(updateDestination(null)); }} > @@ -64,4 +64,4 @@ const DestinationV2 = ({ zoomToFeaturePoint }: DestinationProps) => { ); }; -export default DestinationV2; +export default Destination; diff --git a/front/src/modules/pathfinding/components/Itinerary/DisplayItinerary/v2/OriginV2.tsx b/front/src/modules/pathfinding/components/Itinerary/DisplayItinerary/Origin.tsx similarity index 94% rename from front/src/modules/pathfinding/components/Itinerary/DisplayItinerary/v2/OriginV2.tsx rename to front/src/modules/pathfinding/components/Itinerary/DisplayItinerary/Origin.tsx index 6258103de64..6bcac4c5fbd 100644 --- a/front/src/modules/pathfinding/components/Itinerary/DisplayItinerary/v2/OriginV2.tsx +++ b/front/src/modules/pathfinding/components/Itinerary/DisplayItinerary/Origin.tsx @@ -14,9 +14,9 @@ type OriginProps = { zoomToFeaturePoint: (lngLat?: Position, id?: string) => void; }; -const OriginV2 = ({ zoomToFeaturePoint }: OriginProps) => { +const Origin = ({ zoomToFeaturePoint }: OriginProps) => { const { - getOriginV2, + getOrigin, getOriginDate, getOriginTime, getOriginLinkedBounds, @@ -27,7 +27,7 @@ const OriginV2 = ({ zoomToFeaturePoint }: OriginProps) => { const { mode } = useOsrdContext(); const { - updateOriginV2, + updateOrigin, updateOriginDate, updateOriginTime, updateOriginUpperBoundDate, @@ -35,8 +35,7 @@ const OriginV2 = ({ zoomToFeaturePoint }: OriginProps) => { toggleOriginLinkedBounds, } = useOsrdConfActions(); - const origin = useSelector(getOriginV2); - // TODO TS2 : update stdcm store for trainschedule V2 ? + const origin = useSelector(getOrigin); const originDate = useSelector(getOriginDate); const originTime = useSelector(getOriginTime); const originLinkedBounds = useSelector(getOriginLinkedBounds); @@ -101,7 +100,7 @@ const OriginV2 = ({ zoomToFeaturePoint }: OriginProps) => { className="btn btn-sm btn-only-icon btn-white" type="button" onClick={() => { - dispatch(updateOriginV2(null)); + dispatch(updateOrigin(null)); }} > @@ -157,4 +156,4 @@ const OriginV2 = ({ zoomToFeaturePoint }: OriginProps) => { ); }; -export default OriginV2; +export default Origin; diff --git a/front/src/modules/pathfinding/components/Itinerary/DisplayItinerary/v2/ViaStopDurationSelector.tsx b/front/src/modules/pathfinding/components/Itinerary/DisplayItinerary/ViaStopDurationSelector.tsx similarity index 93% rename from front/src/modules/pathfinding/components/Itinerary/DisplayItinerary/v2/ViaStopDurationSelector.tsx rename to front/src/modules/pathfinding/components/Itinerary/DisplayItinerary/ViaStopDurationSelector.tsx index 8cf585ea83d..17917ac1703 100644 --- a/front/src/modules/pathfinding/components/Itinerary/DisplayItinerary/v2/ViaStopDurationSelector.tsx +++ b/front/src/modules/pathfinding/components/Itinerary/DisplayItinerary/ViaStopDurationSelector.tsx @@ -17,7 +17,7 @@ const ViaStopDurationSelector = ({ setFocusedViaId: (focusedViaIndex?: string) => void; }) => { const dispatch = useAppDispatch(); - const { updateViaStopTimeV2 } = useOsrdConfActions(); + const { updateViaStopTime } = useOsrdConfActions(); const currentStopTime = via.stopFor ? ISO8601Duration2sec(via.stopFor) : 0; @@ -25,7 +25,7 @@ const ViaStopDurationSelector = ({ const debouncedStopTime = useDebounce(stopTime, 2000); const updateViaStopDuration = (durationInSec: number) => { - dispatch(updateViaStopTimeV2({ via, duration: formatDurationAsISO8601(durationInSec) })); + dispatch(updateViaStopTime({ via, duration: formatDurationAsISO8601(durationInSec) })); }; useEffect(() => { diff --git a/front/src/modules/pathfinding/components/Itinerary/DisplayItinerary/v2/ViasV2.tsx b/front/src/modules/pathfinding/components/Itinerary/DisplayItinerary/Vias.tsx similarity index 91% rename from front/src/modules/pathfinding/components/Itinerary/DisplayItinerary/v2/ViasV2.tsx rename to front/src/modules/pathfinding/components/Itinerary/DisplayItinerary/Vias.tsx index f45ae1120b4..ce138ded7e1 100644 --- a/front/src/modules/pathfinding/components/Itinerary/DisplayItinerary/v2/ViasV2.tsx +++ b/front/src/modules/pathfinding/components/Itinerary/DisplayItinerary/Vias.tsx @@ -13,17 +13,17 @@ import { formatUicToCi } from 'utils/strings'; import ViaStopDurationSelector from './ViaStopDurationSelector'; -type DisplayViasV2Props = { +type ViasProps = { shouldManageStopDuration?: boolean; zoomToFeaturePoint: (lngLat?: Position, id?: string) => void; }; -const ViasV2 = ({ zoomToFeaturePoint, shouldManageStopDuration }: DisplayViasV2Props) => { +const Vias = ({ zoomToFeaturePoint, shouldManageStopDuration }: ViasProps) => { const { t } = useTranslation('operationalStudies/manageTrainSchedule'); - const { getViasV2 } = useOsrdConfSelectors(); + const { getVias } = useOsrdConfSelectors(); const dispatch = useAppDispatch(); - const vias = useSelector(getViasV2()); - const { moveVia, deleteViaV2 } = useOsrdConfActions(); + const vias = useSelector(getVias()); + const { moveVia, deleteVia } = useOsrdConfActions(); const [focusedViaId, setFocusedViaId] = useState(); return ( @@ -83,7 +83,7 @@ const ViasV2 = ({ zoomToFeaturePoint, shouldManageStopDuration }: DisplayViasV2P data-testid="delete-via-button" className="btn btn-sm btn-only-icon btn-white ml-auto" type="button" - onClick={() => dispatch(deleteViaV2(index))} + onClick={() => dispatch(deleteVia(index))} > - {timetableV2 && v2TrainCount(timetableV2.train_ids)} + {timetable && trainCount(timetable.train_ids)}
diff --git a/front/src/modules/simulationResult/components/ChartHelpers/ChartHelpers.ts b/front/src/modules/simulationResult/components/ChartHelpers/ChartHelpers.ts index 1e6c522676b..aa0d084af76 100644 --- a/front/src/modules/simulationResult/components/ChartHelpers/ChartHelpers.ts +++ b/front/src/modules/simulationResult/components/ChartHelpers/ChartHelpers.ts @@ -7,7 +7,6 @@ import type { ReportTrainData } from 'modules/simulationResult/components/SpeedS import type { ChartAxes, ListValues, XAxis, Y2Axis, YAxis } from 'modules/simulationResult/consts'; import type { Position, - PositionSpeedTime, SimulationD3Scale, PositionsSpeedTimes, } from 'reducers/osrdsimulation/types'; @@ -37,7 +36,7 @@ export type MergedBlock = { // called with keyValues // ['position', 'gradient'] // ['position', 'speed'] -export const mergeDatasAreaConstantV2 = ( +export const mergeDatasAreaConstant = ( data1: PositionData<'gradient'>[], data2: number, keyValues: Keys[] @@ -71,12 +70,12 @@ export const gridY2 = (axisScale: SimulationD3Scale, width: number) => // Interpolation of cursor based on space position // ['position', 'speed'] -export const interpolateOnPositionV2 = ( - dataSimulation: { speed: PositionSpeedTime[] | ReportTrainData[] }, // TODO DROP V1 : remove PositionSpeedTime type +export const interpolateOnPosition = ( + dataSimulation: { speed: ReportTrainData[] }, positionLocal: number, offset: number // in seconds ) => { - const bisect = d3.bisector((d) => d.position).left; + const bisect = d3.bisector((d) => d.position).left; const index = bisect(dataSimulation.speed, positionLocal, 1); const bisection = [dataSimulation.speed[index - 1], dataSimulation.speed[index]]; if (bisection[1]) { diff --git a/front/src/modules/simulationResult/components/ChartHelpers/enableInteractivity.tsx b/front/src/modules/simulationResult/components/ChartHelpers/enableInteractivity.tsx index 7b429ad9ce1..3a5a06137bc 100644 --- a/front/src/modules/simulationResult/components/ChartHelpers/enableInteractivity.tsx +++ b/front/src/modules/simulationResult/components/ChartHelpers/enableInteractivity.tsx @@ -9,12 +9,12 @@ import { gridY2, interpolateOnTime, getAxis, - interpolateOnPositionV2, + interpolateOnPosition, } from 'modules/simulationResult/components/ChartHelpers/ChartHelpers'; import drawGuideLines from 'modules/simulationResult/components/ChartHelpers/drawGuideLines'; import type { AreaBlock } from 'modules/simulationResult/components/SpeedSpaceChart/types'; import { CHART_AXES, LIST_VALUES, type ChartAxes } from 'modules/simulationResult/consts'; -import type { PositionScaleDomain, SpaceCurvesSlopesDataV2 } from 'modules/simulationResult/types'; +import type { PositionScaleDomain, SpaceCurvesSlopesData } from 'modules/simulationResult/types'; import type { Chart, ConsolidatedRouteAspect, @@ -256,9 +256,9 @@ function wheelDelta(event: WheelEvent) { return -event.deltaY * factor; } -export const enableInteractivityV2 = < +export const enableInteractivity = < T extends Chart | SpeedSpaceChart, - Data extends SimulationTrain | SpaceCurvesSlopesDataV2, + Data extends SimulationTrain | SpaceCurvesSlopesData, >( chart: T | undefined, selectedTrainData: Data, @@ -310,7 +310,7 @@ export const enableInteractivityV2 = < if (!simulationIsPlaying) { // SpaceCurvesSlopesChart const positionLocal = chart.x.invert(pointer(event, event.currentTarget)[0]) as number; - const timePositionLocal = interpolateOnPositionV2( + const timePositionLocal = interpolateOnPosition( selectedTrainData as { speed: PositionSpeedTime[] }, Math.max(positionLocal, 0), isoDateWithTimezoneToSec(selectedTrainDepartureDate) diff --git a/front/src/modules/simulationResult/components/ChartHelpers/getScaleDomainFromValues.ts b/front/src/modules/simulationResult/components/ChartHelpers/getScaleDomainFromValues.ts index 097d608c02b..34696ff3b06 100644 --- a/front/src/modules/simulationResult/components/ChartHelpers/getScaleDomainFromValues.ts +++ b/front/src/modules/simulationResult/components/ChartHelpers/getScaleDomainFromValues.ts @@ -3,7 +3,7 @@ import * as d3 from 'd3'; import { mmToM } from 'utils/physics'; -export const getScaleDomainFromValuesV2 = (values: number[]) => { +export const getScaleDomainFromValues = (values: number[]) => { const [minScaleValue, maxScaleValue] = d3.extent(values) as number[]; // These values needs to be in meters return [mmToM(minScaleValue), mmToM(maxScaleValue) + 100]; diff --git a/front/src/modules/simulationResult/components/ChartSynchronizer/ChartSynchronizerV2.ts b/front/src/modules/simulationResult/components/ChartSynchronizer/ChartSynchronizer.ts similarity index 89% rename from front/src/modules/simulationResult/components/ChartSynchronizer/ChartSynchronizerV2.ts rename to front/src/modules/simulationResult/components/ChartSynchronizer/ChartSynchronizer.ts index e0b34c71a0b..b295674e801 100644 --- a/front/src/modules/simulationResult/components/ChartSynchronizer/ChartSynchronizerV2.ts +++ b/front/src/modules/simulationResult/components/ChartSynchronizer/ChartSynchronizer.ts @@ -18,8 +18,8 @@ const IS_TRAIN_SCHEDULE_V2 = true; * each function passed to @method subscribe will receive the new data. * subscriber functions can be used to refresh d3 graphes, or rehydrate react component with this data, now isolated from react life cycle. */ -export class ChartSynchronizerV2 { - private static instance: ChartSynchronizerV2; +export class ChartSynchronizer { + private static instance: ChartSynchronizer; private subscribers: Map; @@ -36,10 +36,10 @@ export class ChartSynchronizerV2 { } static getInstance() { - if (!ChartSynchronizerV2.instance) { - ChartSynchronizerV2.instance = new ChartSynchronizerV2(); + if (!ChartSynchronizer.instance) { + ChartSynchronizer.instance = new ChartSynchronizer(); } - return ChartSynchronizerV2.instance; + return ChartSynchronizer.instance; } setTrainData(trainData?: ChartSynchronizerTrainData) { @@ -82,12 +82,12 @@ export class ChartSynchronizerV2 { * @param dependencies – When a dependency changes, update the subscriber. * @returns */ -export function useChartSynchronizerV2( +export function useChartSynchronizer( subscriber?: Subscriber, key?: string, dependencies?: unknown[] ) { - const synchronizer = useRef(ChartSynchronizerV2.getInstance()); + const synchronizer = useRef(ChartSynchronizer.getInstance()); // create or update subscription useEffect(() => { diff --git a/front/src/modules/simulationResult/components/ChartSynchronizer/index.ts b/front/src/modules/simulationResult/components/ChartSynchronizer/index.ts index e9eaa128196..6fee9f65d1f 100644 --- a/front/src/modules/simulationResult/components/ChartSynchronizer/index.ts +++ b/front/src/modules/simulationResult/components/ChartSynchronizer/index.ts @@ -1 +1 @@ -export { ChartSynchronizerV2, useChartSynchronizerV2 } from './ChartSynchronizerV2'; +export { ChartSynchronizer, useChartSynchronizer } from './ChartSynchronizer'; diff --git a/front/src/modules/simulationResult/components/ChartSynchronizer/utils.ts b/front/src/modules/simulationResult/components/ChartSynchronizer/utils.ts index f9f0b1b93ac..b629f9a8b21 100644 --- a/front/src/modules/simulationResult/components/ChartSynchronizer/utils.ts +++ b/front/src/modules/simulationResult/components/ChartSynchronizer/utils.ts @@ -4,10 +4,10 @@ import type { RollingStock } from 'common/api/osrdEditoastApi'; import { isoDateWithTimezoneToSec } from 'utils/date'; import { mmToM } from 'utils/physics'; -import { ChartSynchronizerV2, type ChartSynchronizerTrainData } from './ChartSynchronizerV2'; +import { ChartSynchronizer, type ChartSynchronizerTrainData } from './ChartSynchronizer'; import { sec2d3datetime } from '../ChartHelpers/ChartHelpers'; -export const updateChartSynchronizerV2TrainData = ( +export const updateChartSynchronizerTrainData = ( simulation: SimulationResponseSuccess, rollingStock: RollingStock, departureTime: string @@ -86,5 +86,5 @@ export const updateChartSynchronizerV2TrainData = ( eco_speed: ecoSpeeds, }; - ChartSynchronizerV2.getInstance().setTrainData(chartSynchronizerData); + ChartSynchronizer.getInstance().setTrainData(chartSynchronizerData); }; diff --git a/front/src/modules/simulationResult/components/SimulationResultsMapV2.tsx b/front/src/modules/simulationResult/components/SimulationResultsMap/SimulationResultsMap.tsx similarity index 96% rename from front/src/modules/simulationResult/components/SimulationResultsMapV2.tsx rename to front/src/modules/simulationResult/components/SimulationResultsMap/SimulationResultsMap.tsx index f74370ebd23..433a4aea62e 100644 --- a/front/src/modules/simulationResult/components/SimulationResultsMapV2.tsx +++ b/front/src/modules/simulationResult/components/SimulationResultsMap/SimulationResultsMap.tsx @@ -55,17 +55,17 @@ import { useAppDispatch } from 'store'; import { isoDateWithTimezoneToSec } from 'utils/date'; import { kmToM, mmToM, msToKmh } from 'utils/physics'; -import { interpolateOnPositionV2 } from './ChartHelpers/ChartHelpers'; -import { useChartSynchronizerV2 } from './ChartSynchronizer'; -import getSelectedTrainHoverPositions from './SimulationResultsMap/getSelectedTrainHoverPositions'; +import getSelectedTrainHoverPositions from './getSelectedTrainHoverPositions'; +import { interpolateOnPosition } from '../ChartHelpers/ChartHelpers'; +import { useChartSynchronizer } from '../ChartSynchronizer'; -type MapProps = { +type SimulationResultMapProps = { setExtViewport: (viewport: Viewport) => void; geometry?: PathPropertiesFormatted['geometry']; trainSimulation?: SimulationResponseSuccess & { trainId: number; startTime: string }; }; -const SimulationResultMapV2 = ({ geometry, trainSimulation }: MapProps) => { +const SimulationResultMap = ({ geometry, trainSimulation }: SimulationResultMapProps) => { const { urlLat = '', urlLon = '', urlZoom = '', urlBearing = '', urlPitch = '' } = useParams(); const mapBlankStyle = useMapBlankStyle(); @@ -84,7 +84,7 @@ const SimulationResultMapV2 = ({ geometry, trainSimulation }: MapProps) => { const dispatch = useAppDispatch(); - const { updateTimePosition } = useChartSynchronizerV2( + const { updateTimePosition } = useChartSynchronizer( (_, positionValues) => { if (trainSimulation && geojsonPath) { const selectedTrainPosition = getSelectedTrainHoverPositions( @@ -136,7 +136,7 @@ const SimulationResultMapV2 = ({ geometry, trainSimulation }: MapProps) => { position: mmToM(trainSimulation.base.positions[i]), time: trainSimulation.base.times[i], })); - const timePositionLocal = interpolateOnPositionV2( + const timePositionLocal = interpolateOnPosition( { speed: baseSpeedData }, positionLocal, isoDateWithTimezoneToSec(trainSimulation.startTime) @@ -350,4 +350,4 @@ const SimulationResultMapV2 = ({ geometry, trainSimulation }: MapProps) => { ); }; -export default SimulationResultMapV2; +export default SimulationResultMap; diff --git a/front/src/modules/simulationResult/components/SimulationResultsMap/TrainHoverPosition.tsx b/front/src/modules/simulationResult/components/SimulationResultsMap/TrainHoverPosition.tsx index 9e9a71e3b01..51e9f2961f1 100644 --- a/front/src/modules/simulationResult/components/SimulationResultsMap/TrainHoverPosition.tsx +++ b/front/src/modules/simulationResult/components/SimulationResultsMap/TrainHoverPosition.tsx @@ -1,5 +1,3 @@ -// TO DO DROP V1: remove this file - import along from '@turf/along'; import bezierSpline from '@turf/bezier-spline'; import { type Point, polygon, lineString } from '@turf/helpers'; diff --git a/front/src/modules/simulationResult/components/SpaceCurvesSlopes/SpaceCurvesSlopesV2.tsx b/front/src/modules/simulationResult/components/SpaceCurvesSlopes/SpaceCurvesSlopes.tsx similarity index 91% rename from front/src/modules/simulationResult/components/SpaceCurvesSlopes/SpaceCurvesSlopesV2.tsx rename to front/src/modules/simulationResult/components/SpaceCurvesSlopes/SpaceCurvesSlopes.tsx index 725289f2fca..970f4a6aa7f 100644 --- a/front/src/modules/simulationResult/components/SpaceCurvesSlopes/SpaceCurvesSlopesV2.tsx +++ b/front/src/modules/simulationResult/components/SpaceCurvesSlopes/SpaceCurvesSlopes.tsx @@ -10,18 +10,18 @@ import type { } from 'applications/operationalStudies/types'; import { defineLinear, - interpolateOnPositionV2, - mergeDatasAreaConstantV2, + interpolateOnPosition, + mergeDatasAreaConstant, } from 'modules/simulationResult/components/ChartHelpers/ChartHelpers'; import defineChart from 'modules/simulationResult/components/ChartHelpers/defineChart'; import drawArea from 'modules/simulationResult/components/ChartHelpers/drawArea'; import { traceVerticalLine, - enableInteractivityV2, + enableInteractivity, } from 'modules/simulationResult/components/ChartHelpers/enableInteractivity'; import type { ReportTrainData } from 'modules/simulationResult/components/SpeedSpaceChart/types'; import { CHART_AXES } from 'modules/simulationResult/consts'; -import type { PositionScaleDomain, SpaceCurvesSlopesDataV2 } from 'modules/simulationResult/types'; +import type { PositionScaleDomain, SpaceCurvesSlopesData } from 'modules/simulationResult/types'; import { getIsPlaying } from 'reducers/osrdsimulation/selectors'; import type { Chart, SpeedSpaceChart } from 'reducers/osrdsimulation/types'; import { dateIsInRange, isoDateWithTimezoneToSec } from 'utils/date'; @@ -33,11 +33,11 @@ import { drawAxisTitle, drawSpaceCurvesSlopesChartCurve, } from './utils'; -import { useChartSynchronizerV2 } from '../ChartSynchronizer'; +import { useChartSynchronizer } from '../ChartSynchronizer'; const CHART_ID = 'SpaceCurvesSlopes'; -type SpaceCurvesSlopesV2Props = { +type SpaceCurvesSlopesProps = { initialHeight: number; trainSimulation: SimulationResponseSuccess; pathProperties: PathPropertiesFormatted; @@ -46,14 +46,14 @@ type SpaceCurvesSlopesV2Props = { departureTime: string; }; -const SpaceCurvesSlopesV2 = ({ +const SpaceCurvesSlopes = ({ initialHeight, trainSimulation, pathProperties, sharedXScaleDomain, setSharedXScaleDomain, departureTime, -}: SpaceCurvesSlopesV2Props) => { +}: SpaceCurvesSlopesProps) => { const simulationIsPlaying = useSelector(getIsPlaying); const { base } = trainSimulation; const { operationalPoints, slopes, curves } = pathProperties; @@ -64,7 +64,7 @@ const SpaceCurvesSlopesV2 = ({ const ref = useRef(null); - const trainData: SpaceCurvesSlopesDataV2 = useMemo(() => { + const trainData: SpaceCurvesSlopesData = useMemo(() => { // speeds (needed for enableInteractivity) const baseSpeedData: ReportTrainData[] = base.speeds.map((speed, i) => ({ @@ -75,7 +75,7 @@ const SpaceCurvesSlopesV2 = ({ // slopes const gradients = slopes.map((step) => step.gradient); - const areaSlopesHistogram = mergeDatasAreaConstantV2(slopes, 0, ['position', 'gradient']); + const areaSlopesHistogram = mergeDatasAreaConstant(slopes, 0, ['position', 'gradient']); const slopesCurve = createSlopeCurve(slopes, gradients); // curves @@ -95,13 +95,13 @@ const SpaceCurvesSlopesV2 = ({ if (chart) { const spaceScaleRange = chart.x.domain(); return spaceScaleRange.map((position) => - interpolateOnPositionV2(trainData, position, isoDateWithTimezoneToSec(departureTime)) + interpolateOnPosition(trainData, position, isoDateWithTimezoneToSec(departureTime)) ) as [Date, Date]; } return [new Date(), new Date()]; }, [chart]); - const { updateTimePosition } = useChartSynchronizerV2( + const { updateTimePosition } = useChartSynchronizer( (timePosition, positionValues) => { if (dateIsInRange(timePosition, timeScaleRange)) { traceVerticalLine(chart, CHART_AXES.SPACE_GRADIENT, positionValues); @@ -214,7 +214,7 @@ const SpaceCurvesSlopesV2 = ({ // Operational points drawOPs(chartLocal); - enableInteractivityV2( + enableInteractivity( chartLocal, trainData, CHART_AXES.SPACE_GRADIENT, @@ -275,4 +275,4 @@ const SpaceCurvesSlopesV2 = ({ ); }; -export default SpaceCurvesSlopesV2; +export default SpaceCurvesSlopes; diff --git a/front/src/modules/simulationResult/components/SpaceCurvesSlopes/utils.ts b/front/src/modules/simulationResult/components/SpaceCurvesSlopes/utils.ts index 9b53cf30cbf..e7e1d741830 100644 --- a/front/src/modules/simulationResult/components/SpaceCurvesSlopes/utils.ts +++ b/front/src/modules/simulationResult/components/SpaceCurvesSlopes/utils.ts @@ -2,7 +2,7 @@ import * as d3 from 'd3'; import type { PositionData } from 'applications/operationalStudies/types'; import drawCurve from 'modules/simulationResult/components/ChartHelpers/drawCurve'; -import type { SpaceCurvesSlopesDataV2 } from 'modules/simulationResult/types'; +import type { SpaceCurvesSlopesData } from 'modules/simulationResult/types'; import type { Chart, GradientPosition, @@ -11,10 +11,7 @@ import type { SpeedSpaceChart, } from 'reducers/osrdsimulation/types'; -export const drawAxisTitle = ( - chart: Chart, - slopes?: SpaceCurvesSlopesDataV2['slopesHistogram'] -) => { +export const drawAxisTitle = (chart: Chart, slopes?: SpaceCurvesSlopesData['slopesHistogram']) => { chart.drawZone .append('text') .attr('class', 'axis-unit') @@ -77,7 +74,7 @@ const calculateReferentialHeight = (data: number[]) => { }; export const createCurveCurve = ( - curves: RadiusPosition[] | PositionData<'radius'>[], // TODO DROPV1 : remove RadiusPosition type + curves: PositionData<'radius'>[], speeds: number[] ): RadiusPosition[] => { const referentialHeight = calculateReferentialHeight(speeds); diff --git a/front/src/modules/simulationResult/components/SpeedSpaceChart/SpeedSpaceChartV2.tsx b/front/src/modules/simulationResult/components/SpeedSpaceChart/SpeedSpaceChartContainer.tsx similarity index 96% rename from front/src/modules/simulationResult/components/SpeedSpaceChart/SpeedSpaceChartV2.tsx rename to front/src/modules/simulationResult/components/SpeedSpaceChart/SpeedSpaceChartContainer.tsx index aba6066c05f..4bf9bc9200c 100644 --- a/front/src/modules/simulationResult/components/SpeedSpaceChart/SpeedSpaceChartV2.tsx +++ b/front/src/modules/simulationResult/components/SpeedSpaceChart/SpeedSpaceChartContainer.tsx @@ -16,7 +16,7 @@ import type { import { formatData } from './helpers'; -export type SpeedSpaceChartV2Props = { +export type SpeedSpaceChartContainerProps = { trainSimulation: SimulationResponseSuccess; selectedTrainPowerRestrictions?: LayerData[]; pathProperties: PathPropertiesFormatted; @@ -29,13 +29,13 @@ const SPEEDSPACECHART_MIN_HEIGHT = 400; const SPEEDSPACECHART_BACKGROUND_COLOR = 'rgb(247, 246, 238)'; const SPEEDSPACECHART_PADDING_BOTTOM = 22.5; -const SpeedSpaceChartV2 = ({ +const SpeedSpaceChartContainer = ({ trainSimulation, selectedTrainPowerRestrictions, pathProperties, heightOfSpeedSpaceChartContainer, setHeightOfSpeedSpaceChartContainer, -}: SpeedSpaceChartV2Props) => { +}: SpeedSpaceChartContainerProps) => { const { t } = useTranslation('simulation'); const [heightOfSpeedSpaceChart, setHeightOfSpeedSpaceChart] = useState(SPEEDSPACECHART_HEIGHT); @@ -119,4 +119,4 @@ const SpeedSpaceChartV2 = ({ ); }; -export default SpeedSpaceChartV2; +export default SpeedSpaceChartContainer; diff --git a/front/src/modules/simulationResult/components/SpeedSpaceChart/useSpeedSpaceChart.ts b/front/src/modules/simulationResult/components/SpeedSpaceChart/useSpeedSpaceChart.ts index 131e4682b8e..f781ad07747 100644 --- a/front/src/modules/simulationResult/components/SpeedSpaceChart/useSpeedSpaceChart.ts +++ b/front/src/modules/simulationResult/components/SpeedSpaceChart/useSpeedSpaceChart.ts @@ -17,7 +17,7 @@ import { useInfraID } from 'common/osrdContext'; import usePathProperties from 'modules/pathfinding/hooks/usePathProperties'; import formatPowerRestrictionRangesWithHandled from 'modules/powerRestriction/helpers/formatPowerRestrictionRangesWithHandled'; -import { updateChartSynchronizerV2TrainData } from '../ChartSynchronizer/utils'; +import { updateChartSynchronizerTrainData } from '../ChartSynchronizer/utils'; /** Prepare data needed for speedSpaceChart */ const useSpeedSpaceChart = ( @@ -83,7 +83,7 @@ const useSpeedSpaceChart = ( // setup chart synchronizer useEffect(() => { if (simulation?.status === 'success' && trainScheduleResult && rollingStock && departureTime) { - updateChartSynchronizerV2TrainData(simulation, rollingStock, departureTime); + updateChartSynchronizerTrainData(simulation, rollingStock, departureTime); } }, [simulation, trainScheduleResult, rollingStock, departureTime]); diff --git a/front/src/modules/simulationResult/components/TimeButtons.tsx b/front/src/modules/simulationResult/components/TimeButtons.tsx index 773fb196a1e..9fc9cb865fe 100644 --- a/front/src/modules/simulationResult/components/TimeButtons.tsx +++ b/front/src/modules/simulationResult/components/TimeButtons.tsx @@ -9,7 +9,7 @@ import { updateIsPlaying } from 'reducers/osrdsimulation/actions'; import { useAppDispatch } from 'store'; import { datetime2time, sec2datetime, time2datetime } from 'utils/timeManipulation'; -import { useChartSynchronizerV2 } from './ChartSynchronizer'; +import { useChartSynchronizer } from './ChartSynchronizer'; // transform a speed ratio (X2 X10 X20, etc.) to interval time & step to bypass const factor2ms = (factor: number) => { @@ -33,7 +33,7 @@ const TimeButtons = ({ departureTime }: TimeButtonsProps) => { const [localTimePosition, setLocalTimePosition] = useState(new Date()); - const { updateTimePosition: updateTimePositionV2 } = useChartSynchronizerV2( + const { updateTimePosition } = useChartSynchronizer( (timePosition) => { setLocalTimePosition(timePosition); }, @@ -44,8 +44,7 @@ const TimeButtons = ({ departureTime }: TimeButtonsProps) => { const stop = () => { clearInterval(playInterval); setPlayInterval(undefined); - if (departureTime) - updateTimePositionV2(sec2datetime(convertDepartureTimeIntoSec(departureTime))); + if (departureTime) updateTimePosition(sec2datetime(convertDepartureTimeIntoSec(departureTime))); dispatch(updateIsPlaying(false)); }; @@ -67,7 +66,7 @@ const TimeButtons = ({ departureTime }: TimeButtonsProps) => { } else { i += factor.steps; } - updateTimePositionV2(new Date(i * 1000)); + updateTimePosition(new Date(i * 1000)); }, factor.ms); setPlayInterval(playIntervalLocal); dispatch(updateIsPlaying(true)); @@ -101,7 +100,7 @@ const TimeButtons = ({ departureTime }: TimeButtonsProps) => { const changeTimePosition = (newTimePosition: string) => { const newTimePositionDate = time2datetime(newTimePosition); if (newTimePositionDate) { - updateTimePositionV2(newTimePositionDate); + updateTimePosition(newTimePositionDate); } }; diff --git a/front/src/modules/simulationResult/components/TrainDetailsV2.tsx b/front/src/modules/simulationResult/components/TrainDetails.tsx similarity index 95% rename from front/src/modules/simulationResult/components/TrainDetailsV2.tsx rename to front/src/modules/simulationResult/components/TrainDetails.tsx index a7d3fe8ad15..dc6d05391b0 100644 --- a/front/src/modules/simulationResult/components/TrainDetailsV2.tsx +++ b/front/src/modules/simulationResult/components/TrainDetails.tsx @@ -6,7 +6,7 @@ import type { TrainSpaceTimeData } from 'applications/operationalStudies/types'; import type { PositionsSpeedTimes } from 'reducers/osrdsimulation/types'; import { sec2d3datetime } from './ChartHelpers/ChartHelpers'; -import { useChartSynchronizerV2 } from './ChartSynchronizer'; +import { useChartSynchronizer } from './ChartSynchronizer'; /** * Given the routeAspects and a timePosition, returns the bounds [start, end] @@ -38,17 +38,17 @@ const getOccupancyBounds = ( return relevantAspect ? [relevantAspect.position_start, relevantAspect.position_end] : [0, 0]; }; -type TrainDetailsV2Props = { +type TrainDetailsProps = { projectedTrain: TrainSpaceTimeData; }; -const TrainDetailsV2 = ({ projectedTrain }: TrainDetailsV2Props) => { +const TrainDetails = ({ projectedTrain }: TrainDetailsProps) => { const [ { eco_headPosition: headPosition, eco_tailPosition: tailPosition, eco_speed: speed }, setLocalPositionValues, ] = useState>({} as PositionsSpeedTimes); - useChartSynchronizerV2( + useChartSynchronizer( (_, positionValues) => { setLocalPositionValues(positionValues); }, @@ -113,4 +113,4 @@ const TrainDetailsV2 = ({ projectedTrain }: TrainDetailsV2Props) => { ); }; -export default TrainDetailsV2; +export default TrainDetails; diff --git a/front/src/modules/simulationResult/types.ts b/front/src/modules/simulationResult/types.ts index 45ee1d7259e..bbf8742e12a 100644 --- a/front/src/modules/simulationResult/types.ts +++ b/front/src/modules/simulationResult/types.ts @@ -19,7 +19,7 @@ export type TimeScaleDomain = { source?: 'SpaceTimeChart' | 'Timeline'; }; -export type SpaceCurvesSlopesDataV2 = { +export type SpaceCurvesSlopesData = { gradients: number[]; speed: ReportTrainData[]; slopesHistogram: PositionData<'gradient'>[]; diff --git a/front/src/modules/timesStops/TimesStopsOutput.tsx b/front/src/modules/timesStops/TimesStopsOutput.tsx index 2c9ad5f424c..69fdd5c3923 100644 --- a/front/src/modules/timesStops/TimesStopsOutput.tsx +++ b/front/src/modules/timesStops/TimesStopsOutput.tsx @@ -6,7 +6,7 @@ import type { } from 'applications/operationalStudies/types'; import type { PathfindingResultSuccess, TrainScheduleResult } from 'common/api/osrdEditoastApi'; import { Loader } from 'common/Loaders/Loader'; -import type { OperationalPointWithTimeAndSpeed } from 'modules/trainschedule/components/DriverTrainScheduleV2/types'; +import type { OperationalPointWithTimeAndSpeed } from 'modules/trainschedule/components/DriverTrainSchedule/types'; import { convertIsoUtcToLocalTime } from 'utils/date'; import { NO_BREAK_SPACE } from 'utils/strings'; diff --git a/front/src/modules/timesStops/helpers/computeMargins.ts b/front/src/modules/timesStops/helpers/computeMargins.ts index e8ccace56da..bb0b647da4b 100644 --- a/front/src/modules/timesStops/helpers/computeMargins.ts +++ b/front/src/modules/timesStops/helpers/computeMargins.ts @@ -1,7 +1,7 @@ import type { SimulationResponseSuccess } from 'applications/operationalStudies/types'; import type { ReportTrain, TrainScheduleResult } from 'common/api/osrdEditoastApi'; -import type { OperationalPointWithTimeAndSpeed } from 'modules/trainschedule/components/DriverTrainScheduleV2/types'; -import { interpolateValue } from 'modules/trainschedule/components/DriverTrainScheduleV2/utils'; +import type { OperationalPointWithTimeAndSpeed } from 'modules/trainschedule/components/DriverTrainSchedule/types'; +import { interpolateValue } from 'modules/trainschedule/components/DriverTrainSchedule/utils'; import { mToMm, msToS } from 'utils/physics'; import { formatDigitsAndUnit } from './utils'; diff --git a/front/src/modules/timesStops/helpers/utils.ts b/front/src/modules/timesStops/helpers/utils.ts index b505fa63683..31f908fdb8c 100644 --- a/front/src/modules/timesStops/helpers/utils.ts +++ b/front/src/modules/timesStops/helpers/utils.ts @@ -3,7 +3,7 @@ import { round } from 'lodash'; import { keyColumn, createTextColumn } from 'react-datasheet-grid'; import { matchPathStepAndOp } from 'modules/pathfinding/utils'; -import type { OperationalPointWithTimeAndSpeed } from 'modules/trainschedule/components/DriverTrainScheduleV2/types'; +import type { OperationalPointWithTimeAndSpeed } from 'modules/trainschedule/components/DriverTrainSchedule/types'; import type { SuggestedOP } from 'modules/trainschedule/components/ManageTrainSchedule/types'; import type { PathStep } from 'reducers/osrdconf/types'; import { extractHHMMSS } from 'utils/date'; diff --git a/front/src/modules/timesStops/hooks/useOutputTableData.ts b/front/src/modules/timesStops/hooks/useOutputTableData.ts index 200a2305f27..2f2add01680 100644 --- a/front/src/modules/timesStops/hooks/useOutputTableData.ts +++ b/front/src/modules/timesStops/hooks/useOutputTableData.ts @@ -8,7 +8,7 @@ import type { } from 'applications/operationalStudies/types'; import type { PathfindingResultSuccess, TrainScheduleResult } from 'common/api/osrdEditoastApi'; import { formatSuggestedOperationalPoints } from 'modules/pathfinding/utils'; -import type { OperationalPointWithTimeAndSpeed } from 'modules/trainschedule/components/DriverTrainScheduleV2/types'; +import type { OperationalPointWithTimeAndSpeed } from 'modules/trainschedule/components/DriverTrainSchedule/types'; import type { SuggestedOP } from 'modules/trainschedule/components/ManageTrainSchedule/types'; import { secToHoursString } from 'utils/timeManipulation'; diff --git a/front/src/modules/trainschedule/components/DriverTrainScheduleV2/DriverTrainScheduleV2.tsx b/front/src/modules/trainschedule/components/DriverTrainSchedule/DriverTrainSchedule.tsx similarity index 84% rename from front/src/modules/trainschedule/components/DriverTrainScheduleV2/DriverTrainScheduleV2.tsx rename to front/src/modules/trainschedule/components/DriverTrainSchedule/DriverTrainSchedule.tsx index 38741d3c6f8..3032d746310 100644 --- a/front/src/modules/trainschedule/components/DriverTrainScheduleV2/DriverTrainScheduleV2.tsx +++ b/front/src/modules/trainschedule/components/DriverTrainSchedule/DriverTrainSchedule.tsx @@ -8,11 +8,11 @@ import type { LightRollingStock, TrainScheduleBase } from 'common/api/osrdEditoa import { Loader } from 'common/Loaders'; import { BaseOrEco, type BaseOrEcoType } from './consts'; -import DriverTrainScheduleHeaderV2 from './DriverTrainScheduleHeaderV2'; -import DriverTrainScheduleStopListV2 from './DriverTrainScheduleStopListV2'; +import DriverTrainScheduleHeader from './DriverTrainScheduleHeader'; +import DriverTrainScheduleStopList from './DriverTrainScheduleStopList'; import type { OperationalPointWithTimeAndSpeed } from './types'; -type DriverTrainScheduleV2Props = { +type DriverTrainScheduleProps = { train: TrainScheduleBase; simulatedTrain: SimulationResponseSuccess; pathProperties: PathPropertiesFormatted; @@ -26,7 +26,7 @@ type DriverTrainScheduleV2Props = { setBaseOrEco: (baseOrEco: BaseOrEcoType) => void; }; -const DriverTrainScheduleV2 = ({ +const DriverTrainSchedule = ({ train, simulatedTrain, pathProperties, @@ -35,7 +35,7 @@ const DriverTrainScheduleV2 = ({ formattedOpPointsLoading, baseOrEco, setBaseOrEco, -}: DriverTrainScheduleV2Props) => { +}: DriverTrainScheduleProps) => { const selectedTrainRegime = useMemo( () => (baseOrEco === BaseOrEco.eco ? simulatedTrain.final_output : simulatedTrain.base), [baseOrEco, simulatedTrain] @@ -48,7 +48,7 @@ const DriverTrainScheduleV2 = ({ return (
-
) : ( - void; }; -const DriverTrainScheduleHeaderV2 = ({ +const DriverTrainScheduleHeader = ({ simulatedTrain, train, operationalPoints, @@ -33,7 +33,7 @@ const DriverTrainScheduleHeaderV2 = ({ rollingStock, baseOrEco, setBaseOrEco, -}: DriverTrainScheduleHeaderV2Props) => { +}: DriverTrainScheduleHeaderProps) => { const { t } = useTranslation(['operationalStudies/drivertrainschedule']); const trainRegime = baseOrEco === BaseOrEco.base ? simulatedTrain.base : simulatedTrain.final_output; @@ -121,4 +121,4 @@ const DriverTrainScheduleHeaderV2 = ({ ); }; -export default DriverTrainScheduleHeaderV2; +export default DriverTrainScheduleHeader; diff --git a/front/src/modules/trainschedule/components/DriverTrainScheduleV2/DriverTrainScheduleStopV2.tsx b/front/src/modules/trainschedule/components/DriverTrainSchedule/DriverTrainScheduleStop.tsx similarity index 95% rename from front/src/modules/trainschedule/components/DriverTrainScheduleV2/DriverTrainScheduleStopV2.tsx rename to front/src/modules/trainschedule/components/DriverTrainSchedule/DriverTrainScheduleStop.tsx index 6269728e4e9..6dbd5d39b57 100644 --- a/front/src/modules/trainschedule/components/DriverTrainScheduleV2/DriverTrainScheduleStopV2.tsx +++ b/front/src/modules/trainschedule/components/DriverTrainSchedule/DriverTrainScheduleStop.tsx @@ -7,7 +7,7 @@ import type { PositionSpeedTime, SpeedRanges } from 'reducers/osrdsimulation/typ import type { OperationalPointWithTimeAndSpeed } from './types'; import { getActualSpeed, getActualVmax, getAverageSpeed, getTime } from './utils'; -type DriverTrainScheduleStopV2Props = { +type DriverTrainScheduleStopProps = { operationalPoint: OperationalPointWithTimeAndSpeed; operationalPoints: OperationalPointWithTimeAndSpeed[]; idx: number; @@ -15,13 +15,13 @@ type DriverTrainScheduleStopV2Props = { speedLimits: SpeedRanges; }; -const DriverTrainScheduleStopV2 = ({ +const DriverTrainScheduleStop = ({ operationalPoint, operationalPoints, idx, trainRegimeReports, speedLimits, -}: DriverTrainScheduleStopV2Props) => { +}: DriverTrainScheduleStopProps) => { const actualSpeed = useMemo( () => getActualSpeed(operationalPoint.position, trainRegimeReports), [operationalPoint.position] @@ -111,4 +111,4 @@ const DriverTrainScheduleStopV2 = ({ ); }; -export default DriverTrainScheduleStopV2; +export default DriverTrainScheduleStop; diff --git a/front/src/modules/trainschedule/components/DriverTrainScheduleV2/DriverTrainScheduleStopListV2.tsx b/front/src/modules/trainschedule/components/DriverTrainSchedule/DriverTrainScheduleStopList.tsx similarity index 92% rename from front/src/modules/trainschedule/components/DriverTrainScheduleV2/DriverTrainScheduleStopListV2.tsx rename to front/src/modules/trainschedule/components/DriverTrainSchedule/DriverTrainScheduleStopList.tsx index 741ae2610bd..0353053dd18 100644 --- a/front/src/modules/trainschedule/components/DriverTrainScheduleV2/DriverTrainScheduleStopListV2.tsx +++ b/front/src/modules/trainschedule/components/DriverTrainSchedule/DriverTrainScheduleStopList.tsx @@ -7,20 +7,20 @@ import type { ReportTrain } from 'common/api/osrdEditoastApi'; import type { PositionSpeedTime, SpeedRanges } from 'reducers/osrdsimulation/types'; import { mmToM } from 'utils/physics'; -import DriverTrainScheduleStopV2 from './DriverTrainScheduleStopV2'; +import DriverTrainScheduleStop from './DriverTrainScheduleStop'; import type { OperationalPointWithTimeAndSpeed } from './types'; -type DriverTrainScheduleStopListV2Props = { +type DriverTrainScheduleStopListProps = { trainRegime: ReportTrain | SimulationResponseSuccess['final_output']; mrsp: SimulationResponseSuccess['mrsp']; operationalPoints: OperationalPointWithTimeAndSpeed[]; }; -const DriverTrainScheduleStopListV2 = ({ +const DriverTrainScheduleStopList = ({ trainRegime, mrsp, operationalPoints, -}: DriverTrainScheduleStopListV2Props) => { +}: DriverTrainScheduleStopListProps) => { const { t } = useTranslation(['operationalStudies/drivertrainschedule']); const formattedTrainRegimeReports: PositionSpeedTime[] = useMemo( @@ -77,7 +77,7 @@ const DriverTrainScheduleStopListV2 = ({ {operationalPoints.length > 0 && operationalPoints.map((op, idx) => ( - { const speedsAtOps = operationalPoints.map((op) => ({ position: op.position, @@ -190,10 +190,10 @@ function createFakeLinkWithData(trainName: string, baseOrEco: BaseOrEcoType, csv document.body.removeChild(fakeLink); } -export default function driverTrainScheduleV2ExportCSV( +export default function driverTrainScheduleExportCSV( simulatedTrain: SimulationResponseSuccess, operationalPoints: OperationalPointWithTimeAndSpeed[], - electrificationRanges: ElectrificationRangeV2[], + electrificationRanges: ElectrificationRange[], baseOrEco: BaseOrEcoType, train: TrainScheduleBase ) { diff --git a/front/src/modules/trainschedule/components/DriverTrainScheduleV2/types.ts b/front/src/modules/trainschedule/components/DriverTrainSchedule/types.ts similarity index 100% rename from front/src/modules/trainschedule/components/DriverTrainScheduleV2/types.ts rename to front/src/modules/trainschedule/components/DriverTrainSchedule/types.ts diff --git a/front/src/modules/trainschedule/components/DriverTrainScheduleV2/utils.ts b/front/src/modules/trainschedule/components/DriverTrainSchedule/utils.ts similarity index 100% rename from front/src/modules/trainschedule/components/DriverTrainScheduleV2/utils.ts rename to front/src/modules/trainschedule/components/DriverTrainSchedule/utils.ts diff --git a/front/src/modules/trainschedule/components/ImportTrainSchedule/ImportTrainScheduleConfigV2.tsx b/front/src/modules/trainschedule/components/ImportTrainSchedule/ImportTrainScheduleConfig.tsx similarity index 99% rename from front/src/modules/trainschedule/components/ImportTrainSchedule/ImportTrainScheduleConfigV2.tsx rename to front/src/modules/trainschedule/components/ImportTrainSchedule/ImportTrainScheduleConfig.tsx index bffa4fb03d0..acc4c6937cd 100644 --- a/front/src/modules/trainschedule/components/ImportTrainSchedule/ImportTrainScheduleConfigV2.tsx +++ b/front/src/modules/trainschedule/components/ImportTrainSchedule/ImportTrainScheduleConfig.tsx @@ -25,7 +25,7 @@ interface ImportTrainScheduleConfigProps { setTrainsJsonData: (trainsJsonData: TrainScheduleBase[]) => void; } -const ImportTrainScheduleConfigV2 = ({ +const ImportTrainScheduleConfig = ({ setTrainsList, setIsLoading, setTrainsJsonData, @@ -287,4 +287,4 @@ const ImportTrainScheduleConfigV2 = ({ ); }; -export default ImportTrainScheduleConfigV2; +export default ImportTrainScheduleConfig; diff --git a/front/src/modules/trainschedule/components/ImportTrainSchedule/ImportTrainScheduleTrainsListV2.tsx b/front/src/modules/trainschedule/components/ImportTrainSchedule/ImportTrainScheduleTrainsList.tsx similarity index 92% rename from front/src/modules/trainschedule/components/ImportTrainSchedule/ImportTrainScheduleTrainsListV2.tsx rename to front/src/modules/trainschedule/components/ImportTrainSchedule/ImportTrainScheduleTrainsList.tsx index 858278b4873..296a863a575 100644 --- a/front/src/modules/trainschedule/components/ImportTrainSchedule/ImportTrainScheduleTrainsListV2.tsx +++ b/front/src/modules/trainschedule/components/ImportTrainSchedule/ImportTrainScheduleTrainsList.tsx @@ -17,7 +17,7 @@ import rollingstockOpenData2OSRD from 'modules/trainschedule/components/ImportTr import { setFailure, setSuccess } from 'reducers/main'; import { useAppDispatch } from 'store'; -import { generateV2TrainSchedulesPayloads } from './generateTrainSchedulesPayloads'; +import { generateTrainSchedulesPayloads } from './generateTrainSchedulesPayloads'; import type { RollingstockOpenData2OSRDKeys } from './types'; function LoadingIfSearching({ isLoading, t }: { isLoading: boolean; t: TFunction }) { @@ -36,7 +36,7 @@ type ImportTrainScheduleTrainsListProps = { trainsJsonData: TrainScheduleBase[]; }; -const ImportTrainScheduleTrainsListV2 = ({ +const ImportTrainScheduleTrainsList = ({ trainsList, rollingStocks, isLoading, @@ -66,12 +66,12 @@ const ImportTrainScheduleTrainsListV2 = ({ const dispatch = useAppDispatch(); - async function generateV2TrainSchedules() { + async function generateTrainSchedules() { try { const payloads = trainsJsonData.length > 0 ? trainsJsonData - : generateV2TrainSchedulesPayloads(formattedTrainsList); + : generateTrainSchedulesPayloads(formattedTrainsList); await postTrainSchedule({ id: timetableId, body: payloads }).unwrap(); dispatch( @@ -107,7 +107,7 @@ const ImportTrainScheduleTrainsListV2 = ({ ) : ( - { @@ -164,7 +164,6 @@ const checkCurrentConfig = ( if ('track' in stepLocation) { return { ...stepLocation, - // TODO drop V1: we should store the offset in mm in the store offset: mToMm(stepLocation.offset), }; } @@ -173,7 +172,7 @@ const checkCurrentConfig = ( margins: formatMargin(compact(pathSteps)), schedule: formatSchedule(compact(pathSteps), startTime), - powerRestrictions: powerRestrictionV2, + powerRestrictions: powerRestriction, firstStartTime: startTime, speedLimitByTag, }; diff --git a/front/src/modules/trainschedule/components/TimetableV2/FilterPanel.tsx b/front/src/modules/trainschedule/components/Timetable/FilterPanel.tsx similarity index 100% rename from front/src/modules/trainschedule/components/TimetableV2/FilterPanel.tsx rename to front/src/modules/trainschedule/components/Timetable/FilterPanel.tsx diff --git a/front/src/modules/trainschedule/components/TimetableV2/TimetableV2.tsx b/front/src/modules/trainschedule/components/Timetable/Timetable.tsx similarity index 95% rename from front/src/modules/trainschedule/components/TimetableV2/TimetableV2.tsx rename to front/src/modules/trainschedule/components/Timetable/Timetable.tsx index cef60a5ef33..904bb59428d 100644 --- a/front/src/modules/trainschedule/components/TimetableV2/TimetableV2.tsx +++ b/front/src/modules/trainschedule/components/Timetable/Timetable.tsx @@ -8,18 +8,18 @@ import { useSelector } from 'react-redux'; import { MANAGE_TRAIN_SCHEDULE_TYPES } from 'applications/operationalStudies/consts'; import type { Conflict, InfraState, TrainScheduleResult } from 'common/api/osrdEditoastApi'; -import ConflictsListV2 from 'modules/conflict/components/ConflictsListV2'; +import ConflictsList from 'modules/conflict/components/ConflictsList'; import { updateSelectedTrainId } from 'reducers/osrdsimulation/actions'; import { getTrainIdUsedForProjection } from 'reducers/osrdsimulation/selectors'; import { useAppDispatch } from 'store'; import { distributedIntervalsFromArrayOfValues, valueToInterval } from 'utils/numbers'; import TimetableToolbar from './TimetableToolbar'; -import TimetableTrainCardV2 from './TimetableTrainCardV2'; +import TimetableTrainCard from './TimetableTrainCard'; import type { TrainScheduleWithDetails } from './types'; import { timetableHasInvalidTrain } from './utils'; -type TimetableV2Props = { +type TimetableProps = { setDisplayTrainScheduleManagement: (mode: string) => void; trainsWithDetails: boolean; infraState: InfraState; @@ -34,7 +34,7 @@ type TimetableV2Props = { trainSchedulesWithDetails: TrainScheduleWithDetails[]; }; -const TimetableV2 = ({ +const Timetable = ({ setDisplayTrainScheduleManagement, trainsWithDetails, infraState, @@ -47,7 +47,7 @@ const TimetableV2 = ({ trainIdToEdit, trainSchedules = [], trainSchedulesWithDetails, -}: TimetableV2Props) => { +}: TimetableProps) => { const { t } = useTranslation(['operationalStudies/scenario', 'common/itemTypes']); const trainIdUsedForProjection = useSelector(getTrainIdUsedForProjection); @@ -151,7 +151,7 @@ const TimetableV2 = ({ > {trainsDurationsIntervals && displayedTrainSchedules.map((train: TrainScheduleWithDetails, idx: number) => ( - )} {conflicts && ( - void; }; -const TimetableTrainCardV2 = ({ +const TimetableTrainCard = ({ isSelectable, isInSelection, train, @@ -223,7 +223,7 @@ const TimetableTrainCardV2 = ({ )}
= { - ['updatePowerRestrictionRangesV2']: CaseReducer>; - ['upsertPowerRestrictionRangesV2']: CaseReducer< + ['updatePowerRestrictionRanges']: CaseReducer>; + ['upsertPowerRestrictionRanges']: CaseReducer< S, PayloadAction<{ from: PathStep; to: PathStep; code: string }> >; - ['cutPowerRestrictionRangesV2']: CaseReducer>; - ['deletePowerRestrictionRangesV2']: CaseReducer< - S, - PayloadAction<{ from: PathStep; to: PathStep }> - >; + ['cutPowerRestrictionRanges']: CaseReducer>; + ['deletePowerRestrictionRanges']: CaseReducer>; ['resizeSegmentEndInput']: CaseReducer< S, PayloadAction<{ - firstRestriction: PowerRestrictionV2; - secondRestriction?: PowerRestrictionV2; + firstRestriction: PowerRestriction; + secondRestriction?: PowerRestriction; newEndPathStep: PathStep; }> >; ['resizeSegmentBeginInput']: CaseReducer< S, PayloadAction<{ - firstRestriction?: PowerRestrictionV2; - secondRestriction: PowerRestrictionV2; + firstRestriction?: PowerRestriction; + secondRestriction: PowerRestriction; newFromPathStep: PathStep; }> >; @@ -40,17 +37,17 @@ export type PowerRestrictionReducer = { export function builPowerRestrictionReducer(): PowerRestrictionReducer { return { - updatePowerRestrictionRangesV2(state: Draft, action: PayloadAction) { - state.powerRestrictionV2 = action.payload; + updatePowerRestrictionRanges(state: Draft, action: PayloadAction) { + state.powerRestriction = action.payload; }, - upsertPowerRestrictionRangesV2( + upsertPowerRestrictionRanges( state: Draft, action: PayloadAction<{ from: PathStep; to: PathStep; code: string }> ) { const { from, to, code } = action.payload; let newPathSteps = compact(state.pathSteps); - let newPowerRestrictionRangesV2 = state.powerRestrictionV2.filter( + let newPowerRestrictionRanges = state.powerRestriction.filter( (restriction) => restriction.from !== from.id && restriction.to !== to.id ); @@ -62,18 +59,18 @@ export function builPowerRestrictionReducer(): PowerRes // update power restriction ranges if (code !== NO_POWER_RESTRICTION) { - newPowerRestrictionRangesV2.push({ from: from.id, to: to.id, value: code }); - newPowerRestrictionRangesV2 = sortBy( - newPowerRestrictionRangesV2, + newPowerRestrictionRanges.push({ from: from.id, to: to.id, value: code }); + newPowerRestrictionRanges = sortBy( + newPowerRestrictionRanges, (range) => newPathStepsById[range.from]?.positionOnPath ); } state.pathSteps = newPathSteps; - state.powerRestrictionV2 = newPowerRestrictionRangesV2; + state.powerRestriction = newPowerRestrictionRanges; }, - cutPowerRestrictionRangesV2(state: Draft, action: PayloadAction<{ cutAt: PathStep }>) { + cutPowerRestrictionRanges(state: Draft, action: PayloadAction<{ cutAt: PathStep }>) { const { cutAt } = action.payload; let newPathSteps = [...state.pathSteps]; @@ -93,10 +90,10 @@ export function builPowerRestrictionReducer(): PowerRes const nextStep = newPathSteps[cutAtIndex + 1]; if (!prevStep || !nextStep) { - console.error('cutPowerRestrictionRangesV2: prevStep or nextStep is undefined'); + console.error('cutPowerRestrictionRanges: prevStep or nextStep is undefined'); } else { // update the power restriction ranges by splitting 1 range into 2 - const newPowerRestrictionRangesV2 = state.powerRestrictionV2.reduce( + const newPowerRestrictionRanges = state.powerRestriction.reduce( (acc, powerRestriction) => { if (powerRestriction.from === prevStep.id) { acc.push({ @@ -113,35 +110,35 @@ export function builPowerRestrictionReducer(): PowerRes } return acc; }, - [] as PowerRestrictionV2[] + [] as PowerRestriction[] ); state.pathSteps = newPathSteps; - state.powerRestrictionV2 = newPowerRestrictionRangesV2; + state.powerRestriction = newPowerRestrictionRanges; } } }, - deletePowerRestrictionRangesV2( + deletePowerRestrictionRanges( state: Draft, action: PayloadAction<{ from: PathStep; to: PathStep }> ) { const { from, to } = action.payload; - const newPowerRestrictionRanges = state.powerRestrictionV2.filter( + const newPowerRestrictionRanges = state.powerRestriction.filter( (restriction) => restriction.from !== from.id && restriction.to !== to.id ); const newPathSteps = [...state.pathSteps] as PathStep[]; state.pathSteps = cleanPathSteps(newPathSteps, newPowerRestrictionRanges); - state.powerRestrictionV2 = newPowerRestrictionRanges; + state.powerRestriction = newPowerRestrictionRanges; }, resizeSegmentBeginInput( state: Draft, action: PayloadAction<{ - firstRestriction?: PowerRestrictionV2; - secondRestriction: PowerRestrictionV2; + firstRestriction?: PowerRestriction; + secondRestriction: PowerRestriction; newFromPathStep: PathStep; }> ) { @@ -150,7 +147,7 @@ export function builPowerRestrictionReducer(): PowerRes // pathSteps should not be undefined or have null values if (state.pathSteps && !state.pathSteps.some((pathStep) => !pathStep)) { let newPathSteps = [...state.pathSteps] as PathStep[]; - let newPowerRestrictionRanges = state.powerRestrictionV2.filter( + let newPowerRestrictionRanges = state.powerRestriction.filter( (restriction) => !isEqual(restriction, firstRestriction) || !isEqual(restriction, secondRestriction) ); @@ -184,14 +181,14 @@ export function builPowerRestrictionReducer(): PowerRes newPathSteps = cleanPathSteps(newPathSteps, newPowerRestrictionRanges); state.pathSteps = newPathSteps; - state.powerRestrictionV2 = newPowerRestrictionRanges; + state.powerRestriction = newPowerRestrictionRanges; } }, resizeSegmentEndInput( state: Draft, action: PayloadAction<{ - firstRestriction: PowerRestrictionV2; - secondRestriction?: PowerRestrictionV2; + firstRestriction: PowerRestriction; + secondRestriction?: PowerRestriction; newEndPathStep: PathStep; }> ) { @@ -200,7 +197,7 @@ export function builPowerRestrictionReducer(): PowerRes // pathSteps should not be undefined or have null values if (state.pathSteps && !state.pathSteps.some((pathStep) => !pathStep)) { let newPathSteps = [...state.pathSteps] as PathStep[]; - let newPowerRestrictionRanges = state.powerRestrictionV2.filter( + let newPowerRestrictionRanges = state.powerRestriction.filter( (restriction) => !isEqual(restriction, firstRestriction) || !isEqual(restriction, secondRestriction) ); @@ -236,7 +233,7 @@ export function builPowerRestrictionReducer(): PowerRes newPathSteps = cleanPathSteps(newPathSteps, newPowerRestrictionRanges); state.pathSteps = newPathSteps; - state.powerRestrictionV2 = newPowerRestrictionRanges; + state.powerRestriction = newPowerRestrictionRanges; } }, }; diff --git a/front/src/reducers/osrdconf/operationalStudiesConf/utils.ts b/front/src/reducers/osrdconf/operationalStudiesConf/utils.ts index 133b4605be6..1566eeb3f1f 100644 --- a/front/src/reducers/osrdconf/operationalStudiesConf/utils.ts +++ b/front/src/reducers/osrdconf/operationalStudiesConf/utils.ts @@ -1,6 +1,6 @@ import { compact } from 'lodash'; -import type { PowerRestrictionV2 } from 'applications/operationalStudies/types'; +import type { PowerRestriction } from 'applications/operationalStudies/types'; import { addElementAtIndex } from 'utils/array'; import type { PathStep } from '../types'; @@ -13,7 +13,7 @@ import type { PathStep } from '../types'; */ export const canRemovePathStep = ( pathStep: PathStep, - powerRestrictionRanges: PowerRestrictionV2[] + powerRestrictionRanges: PowerRestriction[] ) => { const pathStepIsUsed = powerRestrictionRanges.some( (restriction) => restriction.from === pathStep.id || restriction.to === pathStep.id @@ -29,12 +29,12 @@ export const canRemovePathStep = ( /** Remove some restrictions and update the first and second restrictions with the new path step */ export const updateRestrictions = ( - restrictions: PowerRestrictionV2[], - firstRestriction: PowerRestrictionV2 | undefined, - secondRestriction: PowerRestrictionV2 | undefined, + restrictions: PowerRestriction[], + firstRestriction: PowerRestriction | undefined, + secondRestriction: PowerRestriction | undefined, newPathStepId: string, - restrictionsToRemove: PowerRestrictionV2[] = [] -): PowerRestrictionV2[] => + restrictionsToRemove: PowerRestriction[] = [] +): PowerRestriction[] => compact( restrictions.map((restriction) => { for (const restrictionToRemove of restrictionsToRemove) { @@ -58,7 +58,7 @@ export const updateRestrictions = ( export const isRangeCovered = ( pathSteps: PathStep[], - powerRestrictionRange: PowerRestrictionV2, + powerRestrictionRange: PowerRestriction, positionMin: number | undefined, positionMax: number | undefined ): boolean => { @@ -92,7 +92,7 @@ export const addPathStep = (pathSteps: PathStep[], newPathStep: PathStep): PathS /** Remove the unused path steps */ export const cleanPathSteps = ( pathSteps: PathStep[], - powerRestrictions: PowerRestrictionV2[] + powerRestrictions: PowerRestriction[] ): PathStep[] => pathSteps.reduce((acc, pathStep, index) => { if (index === 0 || index === pathSteps.length - 1) { diff --git a/front/src/reducers/osrdconf/osrdConfCommon/__tests__/utils.ts b/front/src/reducers/osrdconf/osrdConfCommon/__tests__/utils.ts index 15a5cc83c8b..83fdfe8f8fd 100644 --- a/front/src/reducers/osrdconf/osrdConfCommon/__tests__/utils.ts +++ b/front/src/reducers/osrdconf/osrdConfCommon/__tests__/utils.ts @@ -335,14 +335,14 @@ const testCommonConfReducers = (slice: OperationalStudiesConfSlice | StdcmConfSl expect(state.originUpperBoundDate).toBe(newOriginUpperBoundDate); }); - it('should handle updateViaStopTimeV2', () => { + it('should handle updateViaStopTime', () => { const pathSteps = testDataBuilder.buildPathSteps(); const via = pathSteps[1]; const store = createStore(slice, { pathSteps, }); - store.dispatch(slice.actions.updateViaStopTimeV2({ via, duration: 'PT60S' })); + store.dispatch(slice.actions.updateViaStopTime({ via, duration: 'PT60S' })); const state = store.getState()[slice.name]; expect(state.pathSteps[1]?.stopFor).toEqual('PT60S'); }); @@ -377,55 +377,55 @@ const testCommonConfReducers = (slice: OperationalStudiesConfSlice | StdcmConfSl expect(state.pathSteps).toEqual(pathSteps); }); - it('should handle updateOriginV2', () => { + it('should handle updateOrigin', () => { const newOrigin = { ...testDataBuilder.buildPathSteps()[0], arrivalType: ArrivalTimeTypes.PRECISE_TIME, }; - defaultStore.dispatch(slice.actions.updateOriginV2(newOrigin)); + defaultStore.dispatch(slice.actions.updateOrigin(newOrigin)); const state = defaultStore.getState()[slice.name]; expect(state.pathSteps[0]).toEqual(newOrigin); }); - it('should handle updateDestinationV2', () => { + it('should handle updateDestination', () => { const lastPathStep = last(testDataBuilder.buildPathSteps()); const newDestination = { ...lastPathStep!, arrivalType: ArrivalTimeTypes.ASAP }; - defaultStore.dispatch(slice.actions.updateDestinationV2(newDestination)); + defaultStore.dispatch(slice.actions.updateDestination(newDestination)); const state = defaultStore.getState()[slice.name]; expect(last(state.pathSteps)).toEqual(newDestination); }); - it('should handle deleteItineraryV2', () => { + it('should handle deleteItinerary', () => { const pathSteps = testDataBuilder.buildPathSteps(); const store = createStore(slice, { pathSteps, }); - store.dispatch(slice.actions.deleteItineraryV2()); + store.dispatch(slice.actions.deleteItinerary()); const state = store.getState()[slice.name]; expect(state.pathSteps).toEqual([null, null]); }); - it('should handle clearViasV2', () => { + it('should handle clearVias', () => { const pathSteps = testDataBuilder.buildPathSteps(); const store = createStore(slice, { pathSteps, }); - store.dispatch(slice.actions.clearViasV2()); + store.dispatch(slice.actions.clearVias()); const state = store.getState()[slice.name]; expect(state.pathSteps).toEqual([pathSteps[0], last(pathSteps)]); }); - it('should handle deleteViaV2', () => { + it('should handle deleteVia', () => { const pathSteps = testDataBuilder.buildPathSteps(); const store = createStore(slice, { pathSteps, }); - store.dispatch(slice.actions.deleteViaV2(0)); + store.dispatch(slice.actions.deleteVia(0)); const state = store.getState()[slice.name]; expect(state.pathSteps).toEqual(removeElementAtIndex(pathSteps, 1)); }); - describe('should handle addViaV2', () => { + describe('should handle addVia', () => { const pathStepsData = testDataBuilder.buildPathSteps(); const [brest, rennes, lemans, paris, strasbourg] = compact(pathStepsData); const pathProperties = testDataBuilder.buildPathProperties(); @@ -440,7 +440,7 @@ const testCommonConfReducers = (slice: OperationalStudiesConfSlice | StdcmConfSl pathSteps, }); - store.dispatch(slice.actions.addViaV2({ newVia: paris, pathProperties })); + store.dispatch(slice.actions.addVia({ newVia: paris, pathProperties })); const state = store.getState()[slice.name]; expect(state.pathSteps).toStrictEqual([null, parisNoPosition, strasbourg]); }); @@ -451,7 +451,7 @@ const testCommonConfReducers = (slice: OperationalStudiesConfSlice | StdcmConfSl pathSteps, }); - store.dispatch(slice.actions.addViaV2({ newVia: rennes, pathProperties })); + store.dispatch(slice.actions.addVia({ newVia: rennes, pathProperties })); const state = store.getState()[slice.name]; expect(state.pathSteps).toStrictEqual([brest, rennesNoPosition, null]); }); @@ -462,7 +462,7 @@ const testCommonConfReducers = (slice: OperationalStudiesConfSlice | StdcmConfSl pathSteps, }); - store.dispatch(slice.actions.addViaV2({ newVia: lemans, pathProperties })); + store.dispatch(slice.actions.addVia({ newVia: lemans, pathProperties })); const state = store.getState()[slice.name]; expect(state.pathSteps).toStrictEqual([brest, lemansNoPosition, strasbourg]); }); @@ -473,7 +473,7 @@ const testCommonConfReducers = (slice: OperationalStudiesConfSlice | StdcmConfSl pathSteps, }); - store.dispatch(slice.actions.addViaV2({ newVia: lemans, pathProperties })); + store.dispatch(slice.actions.addVia({ newVia: lemans, pathProperties })); const state = store.getState()[slice.name]; expect(state.pathSteps).toStrictEqual([brest, rennes, lemansNoPosition, strasbourg]); }); @@ -484,7 +484,7 @@ const testCommonConfReducers = (slice: OperationalStudiesConfSlice | StdcmConfSl pathSteps, }); - store.dispatch(slice.actions.addViaV2({ newVia: lemans, pathProperties })); + store.dispatch(slice.actions.addVia({ newVia: lemans, pathProperties })); const state = store.getState()[slice.name]; expect(state.pathSteps).toStrictEqual([brest, rennes, lemansNoPosition, paris, strasbourg]); }); @@ -495,7 +495,7 @@ const testCommonConfReducers = (slice: OperationalStudiesConfSlice | StdcmConfSl pathSteps, }); - store.dispatch(slice.actions.addViaV2({ newVia: paris, pathProperties })); + store.dispatch(slice.actions.addVia({ newVia: paris, pathProperties })); const state = store.getState()[slice.name]; expect(state.pathSteps).toStrictEqual([brest, rennes, lemans, parisNoPosition, strasbourg]); }); @@ -583,11 +583,11 @@ const testCommonConfReducers = (slice: OperationalStudiesConfSlice | StdcmConfSl }); }); - it('should handle updateRollingStockComfortV2', () => { + it('should handle updateRollingStockComfort', () => { const newRollingStockComfort: TrainScheduleBase['comfort'] = 'AIR_CONDITIONING'; - defaultStore.dispatch(slice.actions.updateRollingStockComfortV2(newRollingStockComfort)); + defaultStore.dispatch(slice.actions.updateRollingStockComfort(newRollingStockComfort)); const state = defaultStore.getState()[slice.name]; - expect(state.rollingStockComfortV2).toBe(newRollingStockComfort); + expect(state.rollingStockComfort).toBe(newRollingStockComfort); }); it('should handle updateStartTime', () => { diff --git a/front/src/reducers/osrdconf/osrdConfCommon/index.ts b/front/src/reducers/osrdconf/osrdConfCommon/index.ts index fb731bff748..af598b17080 100644 --- a/front/src/reducers/osrdconf/osrdConfCommon/index.ts +++ b/front/src/reducers/osrdconf/osrdConfCommon/index.ts @@ -40,7 +40,7 @@ export const defaultCommonConf: OsrdConfState = { timetableID: undefined, electricalProfileSetId: undefined, rollingStockID: undefined, - powerRestrictionV2: [], + powerRestriction: [], speedLimitByTag: undefined, initialSpeed: 0, originDate: formatIsoDate(new Date()), @@ -54,7 +54,7 @@ export const defaultCommonConf: OsrdConfState = { featureInfoClick: { displayPopup: false }, // Corresponds to origin and destination not defined pathSteps: [null, null], - rollingStockComfortV2: 'STANDARD' as const, + rollingStockComfort: 'STANDARD' as const, startTime: new Date().toISOString(), }; @@ -79,7 +79,7 @@ interface CommonConfReducers extends InfraStateReducers ['toggleOriginLinkedBounds']: CaseReducer; ['updateOriginDate']: CaseReducer>; ['updateOriginUpperBoundDate']: CaseReducer>; - ['updateViaStopTimeV2']: CaseReducer>; + ['updateViaStopTime']: CaseReducer>; ['updateGridMarginBefore']: CaseReducer>; ['updateGridMarginAfter']: CaseReducer>; ['updateFeatureInfoClick']: CaseReducer>; @@ -87,10 +87,10 @@ interface CommonConfReducers extends InfraStateReducers S, PayloadAction<{ pathSteps: S['pathSteps']; resetPowerRestrictions?: boolean }> >; - ['deleteItineraryV2']: CaseReducer; - ['clearViasV2']: CaseReducer; - ['deleteViaV2']: CaseReducer>; - ['addViaV2']: CaseReducer< + ['deleteItinerary']: CaseReducer; + ['clearVias']: CaseReducer; + ['deleteVia']: CaseReducer>; + ['addVia']: CaseReducer< S, PayloadAction<{ newVia: PathStep; pathProperties: ManageTrainSchedulePathProperties }> >; @@ -99,10 +99,10 @@ interface CommonConfReducers extends InfraStateReducers prepare: PrepareAction; }; ['upsertViaFromSuggestedOP']: CaseReducer>; - ['updateRollingStockComfortV2']: CaseReducer>; + ['updateRollingStockComfort']: CaseReducer>; ['updateStartTime']: CaseReducer>; - ['updateOriginV2']: CaseReducer>>; - ['updateDestinationV2']: CaseReducer>>; + ['updateOrigin']: CaseReducer>>; + ['updateDestination']: CaseReducer>>; } export function buildCommonConfReducers(): CommonConfReducers { @@ -217,10 +217,7 @@ export function buildCommonConfReducers(): CommonConfRe }, // TODO: Change the type of duration to number. It is preferable to keep this value in seconds in the store //* to avoid multiple conversions between seconds and ISO8601 format across the front. - updateViaStopTimeV2( - state: Draft, - action: PayloadAction<{ via: PathStep; duration: string }> - ) { + updateViaStopTime(state: Draft, action: PayloadAction<{ via: PathStep; duration: string }>) { const { payload: { via, duration }, } = action; @@ -247,22 +244,22 @@ export function buildCommonConfReducers(): CommonConfRe ) { state.pathSteps = action.payload.pathSteps; if (action.payload.resetPowerRestrictions) { - state.powerRestrictionV2 = []; + state.powerRestriction = []; } }, - deleteItineraryV2(state: Draft) { + deleteItinerary(state: Draft) { state.pathSteps = [null, null]; }, - clearViasV2(state: Draft) { + clearVias(state: Draft) { state.pathSteps = [state.pathSteps[0], state.pathSteps[state.pathSteps.length - 1]]; }, // Use this action in the via list, not the suggested op list - deleteViaV2(state: Draft, action: PayloadAction) { + deleteVia(state: Draft, action: PayloadAction) { // Index takes count of the origin in the array state.pathSteps = removeElementAtIndex(state.pathSteps, action.payload + 1); }, // Use this action only to via added by click on map - addViaV2( + addVia( state: Draft, action: PayloadAction<{ newVia: PathStep; @@ -339,16 +336,13 @@ export function buildCommonConfReducers(): CommonConfRe state.pathSteps = addElementAtIndex(state.pathSteps, index || 1, newVia); } }, - updateRollingStockComfortV2( - state: Draft, - action: PayloadAction - ) { - state.rollingStockComfortV2 = action.payload; + updateRollingStockComfort(state: Draft, action: PayloadAction) { + state.rollingStockComfort = action.payload; }, updateStartTime(state: Draft, action: PayloadAction) { state.startTime = action.payload; }, - updateOriginV2(state: Draft, action: PayloadAction>) { + updateOrigin(state: Draft, action: PayloadAction>) { const newPoint = action.payload ? { ...action.payload, @@ -357,7 +351,7 @@ export function buildCommonConfReducers(): CommonConfRe : null; state.pathSteps = updateOriginPathStep(state.pathSteps, newPoint, true); }, - updateDestinationV2(state: Draft, action: PayloadAction>) { + updateDestination(state: Draft, action: PayloadAction>) { const newPoint = action.payload ? { ...action.payload, diff --git a/front/src/reducers/osrdconf/osrdConfCommon/selectors.ts b/front/src/reducers/osrdconf/osrdConfCommon/selectors.ts index 4329913ce04..9dcb3ae4945 100644 --- a/front/src/reducers/osrdconf/osrdConfCommon/selectors.ts +++ b/front/src/reducers/osrdconf/osrdConfCommon/selectors.ts @@ -17,7 +17,7 @@ const buildCommonConfSelectors = ( const getPathSteps = makeOsrdConfSelector('pathSteps'); // If createSelector is not used and we return directly : pathSteps.slice(1, -1), we get this rtk warning : - // Selector getViasV2 returned a different result when called with the same parameters. This can lead to unnecessary rerenders. + // Selector getVias returned a different result when called with the same parameters. This can lead to unnecessary rerenders. // Selectors that return a new reference (such as an object or an array) should be memoized: https://redux.js.org/usage/deriving-data-selectors#optimizing-selectors-with-memoization const viasSelector = createSelector( getPathSteps, @@ -50,20 +50,20 @@ const buildCommonConfSelectors = ( getOriginLinkedBounds: makeOsrdConfSelector('originLinkedBounds'), getGridMarginBefore: makeOsrdConfSelector('gridMarginBefore'), getGridMarginAfter: makeOsrdConfSelector('gridMarginAfter'), - getPowerRestrictionV2: makeOsrdConfSelector('powerRestrictionV2'), + getPowerRestriction: makeOsrdConfSelector('powerRestriction'), getFeatureInfoClick: makeOsrdConfSelector('featureInfoClick'), getPathSteps, - getOriginV2: (state: RootState) => { + getOrigin: (state: RootState) => { const pathSteps = getPathSteps(state); return pathSteps[0]; }, - getDestinationV2: (state: RootState) => { + getDestination: (state: RootState) => { const pathSteps = getPathSteps(state); return pathSteps[pathSteps.length - 1]; }, - /** To use this action, do useSelector(getViasV2()) */ - getViasV2: () => viasSelector, - getRollingStockComfortV2: makeOsrdConfSelector('rollingStockComfortV2'), + /** To use this action, do useSelector(getVias()) */ + getVias: () => viasSelector, + getRollingStockComfort: makeOsrdConfSelector('rollingStockComfort'), getStartTime: makeOsrdConfSelector('startTime'), }; }; diff --git a/front/src/reducers/osrdconf/stdcmConf/stdcmConfReducers.spec.ts b/front/src/reducers/osrdconf/stdcmConf/stdcmConfReducers.spec.ts index cd7a4dc5671..273407ff82b 100644 --- a/front/src/reducers/osrdconf/stdcmConf/stdcmConfReducers.spec.ts +++ b/front/src/reducers/osrdconf/stdcmConf/stdcmConfReducers.spec.ts @@ -121,7 +121,7 @@ describe('stdcmConfReducers', () => { }; it('should handle updateOriginArrival', () => { - store.dispatch(stdcmConfSliceActions.updateOriginV2(newOrigin)); + store.dispatch(stdcmConfSliceActions.updateOrigin(newOrigin)); store.dispatch(stdcmConfSliceActions.updateOriginArrival('2024-08-12T15:45:00.000+02:00')); const state = store.getState()[stdcmConfSlice.name]; expect(state.pathSteps[0]).toEqual({ @@ -168,7 +168,7 @@ describe('stdcmConfReducers', () => { }; it('should handle updateDestinationArrival', () => { - store.dispatch(stdcmConfSliceActions.updateDestinationV2(newDestination)); + store.dispatch(stdcmConfSliceActions.updateDestination(newDestination)); store.dispatch( stdcmConfSliceActions.updateDestinationArrival('2024-08-12T15:45:00.000+02:00') ); diff --git a/front/src/reducers/osrdconf/types.ts b/front/src/reducers/osrdconf/types.ts index 0e9cca40898..d0676b10dc7 100644 --- a/front/src/reducers/osrdconf/types.ts +++ b/front/src/reducers/osrdconf/types.ts @@ -1,6 +1,6 @@ import type { Feature, Position } from 'geojson'; -import type { PowerRestrictionV2 } from 'applications/operationalStudies/types'; +import type { PowerRestriction } from 'applications/operationalStudies/types'; import type { AllowanceValue } from 'applications/stdcm/types'; import type { ArrivalTimeTypes } from 'applications/stdcmV2/types'; import type { Comfort, Distribution, PathItemLocation } from 'common/api/osrdEditoastApi'; @@ -23,7 +23,7 @@ export interface OsrdConfState extends InfraState { searchDatetimeWindow?: { begin: Date; end: Date }; rollingStockID?: number; speedLimitByTag?: string; - powerRestrictionV2: PowerRestrictionV2[]; + powerRestriction: PowerRestriction[]; initialSpeed?: number; originDate?: string; originTime?: string; @@ -34,7 +34,7 @@ export interface OsrdConfState extends InfraState { gridMarginAfter?: number; featureInfoClick: { displayPopup: boolean; feature?: Feature; coordinates?: number[] }; pathSteps: (PathStep | null)[]; - rollingStockComfortV2: Comfort; + rollingStockComfort: Comfort; // Format ISO 8601 startTime: string; } diff --git a/front/src/styles/scss/applications/operationalStudies/_scenario.scss b/front/src/styles/scss/applications/operationalStudies/_scenario.scss index ca7c7d9d990..db3d6740273 100644 --- a/front/src/styles/scss/applications/operationalStudies/_scenario.scss +++ b/front/src/styles/scss/applications/operationalStudies/_scenario.scss @@ -333,7 +333,7 @@ display: flex; justify-content: right; align-items: center; - min-width: 20%; + min-width: 45%; text-align: right; line-height: 0.8rem; padding-right: 0.25rem; @@ -347,9 +347,6 @@ font-size: 0.8rem; } } - .V2 { - min-width: 45%; - } .not-honored { background-color: #eaa72b; justify-content: space-between; diff --git a/front/src/utils/date.ts b/front/src/utils/date.ts index 9ad87d7d646..9e7b1564185 100644 --- a/front/src/utils/date.ts +++ b/front/src/utils/date.ts @@ -112,19 +112,7 @@ export const isoDateWithTimezoneToSec = (isoDate: string) => { return isoDateToMs(isoDate) / 1000 + Math.abs(timeDifferenceMinutes) * 60; }; -// TODO: This function is only used for V1, so it must be deleted when V1 is abandoned. Also we must rename formatDayV2. -export function formatDay(locale = 'fr') { - if (!['en', 'fr'].includes(locale)) { - throw new Error('Invalid locale'); - } - const currentDate = dayjs().locale(locale); - if (locale === 'en') { - return currentDate.format('dddd, MMMM D, YYYY'); - } - return currentDate.format('dddd D MMMM YYYY'); -} - -export function formatDayV2(dateString: string, locale: string = 'fr'): string { +export function formatDay(dateString: string, locale: string = 'fr'): string { if (!['en', 'fr'].includes(locale)) { throw new Error('Invalid locale'); } diff --git a/front/tests/pages/home-page-model.ts b/front/tests/pages/home-page-model.ts index 0a3930e3cf4..c6ecbfbb995 100644 --- a/front/tests/pages/home-page-model.ts +++ b/front/tests/pages/home-page-model.ts @@ -30,8 +30,6 @@ class HomePage { readonly getViteOverlay: Locator; - readonly TSV2Switch: Locator; - readonly dropDown: Locator; readonly userSettings: Locator; @@ -55,7 +53,6 @@ class HomePage { this.getBody = page.locator('body'); this.translation = home; this.getViteOverlay = page.locator('vite-plugin-checker-error-overlay'); - this.TSV2Switch = page.getByTestId('train-schedule-version-switch'); this.stdcmSwitch = page.getByTestId('stdcm-version-switch'); this.dropDown = page.getByTestId('dropdown-sncf'); this.userSettings = page.getByTestId('user-settings-btn');