Skip to content

Commit

Permalink
front: drop ViaStopDurationSelector
Browse files Browse the repository at this point in the history
Not used anymore since the end of TS V2 migration and the new STDCM view page

Signed-off-by: Clara Ni <[email protected]>
  • Loading branch information
clarani committed Dec 24, 2024
1 parent 41e05a4 commit 7919b9b
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 135 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { useState } from 'react';

import { XCircle } from '@osrd-project/ui-icons';
import cx from 'classnames';
import type { Position } from 'geojson';
Expand All @@ -13,20 +11,16 @@ import { isPathStepInvalid } from 'modules/pathfinding/utils';
import { moveElement, removeElementAtIndex } from 'utils/array';
import { formatUicToCi } from 'utils/strings';

import ViaStopDurationSelector from './ViaStopDurationSelector';

type ViasProps = {
shouldManageStopDuration?: boolean;
zoomToFeaturePoint: (lngLat?: Position, id?: string) => void;
};

const Vias = ({ zoomToFeaturePoint, shouldManageStopDuration }: ViasProps) => {
const Vias = ({ zoomToFeaturePoint }: ViasProps) => {
const { t } = useTranslation('operationalStudies/manageTrainSchedule');
const { getVias, getPathSteps } = useOsrdConfSelectors();
const vias = useSelector(getVias());
const pathSteps = useSelector(getPathSteps);
const { launchPathfinding } = useManageTrainScheduleContext();
const [focusedViaId, setFocusedViaId] = useState<string>();

return (
<DragDropContext
Expand Down Expand Up @@ -80,13 +74,6 @@ const Vias = ({ zoomToFeaturePoint, shouldManageStopDuration }: ViasProps) => {
</small>
)}
</div>
{shouldManageStopDuration && (
<ViaStopDurationSelector
via={via}
focusedViaId={focusedViaId}
setFocusedViaId={setFocusedViaId}
/>
)}
<button
data-testid="delete-via-button"
className="btn btn-sm btn-only-icon btn-white ml-auto"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,7 @@ import Origin from './DisplayItinerary/Origin';
import Vias from './DisplayItinerary/Vias';
import ModalSuggestedVias from './ModalSuggestedVias';

type ItineraryProps = {
shouldManageStopDuration?: boolean;
};

const Itinerary = ({ shouldManageStopDuration }: ItineraryProps) => {
const Itinerary = () => {
const { getPathSteps, getOrigin, getDestination, getPowerRestriction } = useOsrdConfSelectors();
const origin = useSelector(getOrigin);
const destination = useSelector(getDestination);
Expand Down Expand Up @@ -170,7 +166,6 @@ const Itinerary = ({ shouldManageStopDuration }: ItineraryProps) => {
{pathSteps.length > 2 ? (
<Vias
zoomToFeaturePoint={zoomToFeaturePoint}
shouldManageStopDuration={shouldManageStopDuration}
/>
) : (
<small data-testid="no-waypoint-chosen-text" className="ml-4">
Expand Down
20 changes: 0 additions & 20 deletions front/src/reducers/osrdconf/osrdConfCommon/__tests__/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { describe, beforeEach, it, expect } from 'vitest';

import { StdcmStopTypes } from 'applications/stdcm/types';
import type { Distribution, Infra, TrainScheduleBase } from 'common/api/osrdEditoastApi';
import type { OperationalStudiesConfSlice } from 'reducers/osrdconf/operationalStudiesConf';
import { defaultCommonConf } from 'reducers/osrdconf/osrdConfCommon';
Expand Down Expand Up @@ -187,25 +186,6 @@ const testCommonConfReducers = (slice: OperationalStudiesConfSlice | StdcmConfSl
expect(state.initialSpeed).toBe(newInitialSpeed);
});

it('should handle updateViaStopTime', () => {
const pathSteps = testDataBuilder.buildPathSteps();
const via = pathSteps[1];
const store = createStore(slice, {
pathSteps,
});

store.dispatch(
slice.actions.updateViaStopTime({
via,
duration: 'PT60S',
stopType: StdcmStopTypes.SERVICE_STOP,
})
);
const state = store.getState()[slice.name];
expect(state.pathSteps[1]?.stopFor).toEqual('PT60S');
expect(state.pathSteps[1]?.stopType).toEqual('serviceStop');
});

it('should handle updateGridMarginBefore', () => {
const newGridMarginBefore = 5;
defaultStore.dispatch(slice.actions.updateGridMarginBefore(newGridMarginBefore));
Expand Down
20 changes: 0 additions & 20 deletions front/src/reducers/osrdconf/osrdConfCommon/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,6 @@ interface CommonConfReducers<S extends OsrdConfState> extends InfraStateReducers
['updateRollingStockID']: CaseReducer<S, PayloadAction<S['rollingStockID']>>;
['updateSpeedLimitByTag']: CaseReducer<S, PayloadAction<S['speedLimitByTag'] | null>>;
['updateInitialSpeed']: CaseReducer<S, PayloadAction<S['initialSpeed']>>;
['updateViaStopTime']: CaseReducer<
S,
PayloadAction<{ via: PathStep; duration: string; stopType?: StdcmStopTypes }>
>;
['updateGridMarginBefore']: CaseReducer<S, PayloadAction<S['gridMarginBefore']>>;
['updateGridMarginAfter']: CaseReducer<S, PayloadAction<S['gridMarginAfter']>>;
['updatePathSteps']: CaseReducer<S, PayloadAction<S['pathSteps']>>;
Expand Down Expand Up @@ -121,22 +117,6 @@ export function buildCommonConfReducers<S extends OsrdConfState>(): CommonConfRe
updateInitialSpeed(state: Draft<S>, action: PayloadAction<S['initialSpeed']>) {
state.initialSpeed = action.payload;
},
// 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.
updateViaStopTime(
state: Draft<S>,
action: PayloadAction<{ via: PathStep; duration: string; stopType?: StdcmStopTypes }>
) {
const {
payload: { via, duration, stopType },
} = action;
state.pathSteps = state.pathSteps.map((pathStep) => {
if (pathStep && pathStep.id === via.id) {
return { ...pathStep, stopFor: duration, stopType };
}
return pathStep;
});
},
updateGridMarginBefore(state: Draft<S>, action: PayloadAction<S['gridMarginBefore']>) {
state.gridMarginBefore = action.payload;
},
Expand Down

0 comments on commit 7919b9b

Please sign in to comment.