Skip to content

Commit 714b2bc

Browse files
committed
front+editoast: remove route starting direction parameter
1 parent 5053be2 commit 714b2bc

File tree

7 files changed

+13
-69
lines changed

7 files changed

+13
-69
lines changed

editoast/openapi.yaml

+1-6
Original file line numberDiff line numberDiff line change
@@ -4144,12 +4144,7 @@ paths:
41444144
ending:
41454145
$ref: '#/components/schemas/TrackLocation'
41464146
starting:
4147-
allOf:
4148-
- $ref: '#/components/schemas/TrackLocation'
4149-
- properties:
4150-
direction:
4151-
$ref: '#/components/schemas/Direction'
4152-
type: object
4147+
$ref: '#/components/schemas/TrackLocation'
41534148
type: object
41544149
description: Starting and ending track location
41554150
responses:

editoast/openapi_legacy.yaml

+1-6
Original file line numberDiff line numberDiff line change
@@ -642,12 +642,7 @@ paths:
642642
type: object
643643
properties:
644644
starting:
645-
allOf:
646-
- $ref: "#/components/schemas/TrackLocation"
647-
- type: object
648-
properties:
649-
direction:
650-
$ref: "#/components/schemas/Direction"
645+
$ref: "#/components/schemas/TrackLocation"
651646
ending:
652647
$ref: "#/components/schemas/TrackLocation"
653648
responses:

editoast/src/views/infra/pathfinding.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ enum PathfindingViewErrors {
4545
struct PathfindingTrackLocationDirInput {
4646
track: Identifier,
4747
position: f64,
48-
direction: Direction,
4948
}
5049

5150
#[derive(Debug, Clone, Deserialize)]
@@ -128,11 +127,11 @@ struct PathfindingStep {
128127
}
129128

130129
impl PathfindingStep {
131-
fn new_init(track: String, position: f64, direction: Direction) -> Self {
130+
fn new_init(track: String, position: f64) -> Self {
132131
Self {
133132
track,
134133
position,
135-
direction,
134+
direction: Direction::StartToStop, // Ignored for initial node
136135
switch_direction: None,
137136
found: false,
138137
starting_step: true,
@@ -185,7 +184,7 @@ fn compute_path(
185184
k: u8,
186185
) -> Vec<PathfindingOutput> {
187186
let start = &input.starting;
188-
let start = PathfindingStep::new_init(start.track.0.clone(), start.position, start.direction);
187+
let start = PathfindingStep::new_init(start.track.0.clone(), start.position);
189188

190189
let track_sections = infra_cache.track_sections();
191190
// Transform a length (in m) into a cost (in mm). This provide the Ord implementation for our cost using u64.
@@ -403,7 +402,6 @@ mod tests {
403402
starting: PathfindingTrackLocationDirInput {
404403
track: "A".into(),
405404
position: 30.0,
406-
direction: Direction::StartToStop,
407405
},
408406
ending: PathfindingTrackLocationInput {
409407
track: "C".into(),
@@ -427,7 +425,6 @@ mod tests {
427425
starting: PathfindingTrackLocationDirInput {
428426
track: "A".into(),
429427
position: 30.0,
430-
direction: Direction::StopToStart,
431428
},
432429
ending: PathfindingTrackLocationInput {
433430
track: "C".into(),

front/src/applications/editor/tools/routeEdition/components/EditRoutePath.tsx

+4-12
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,12 @@ export const EditRoutePathLeftPanel: FC<{ state: EditRoutePathState }> = ({ stat
4242
const infraID = useSelector(getInfraID);
4343
const [isSaving, setIsSaving] = useState(false);
4444
const [includeReleaseDetectors, setIncludeReleaseDetectors] = useState(true);
45-
const { entryPoint, exitPoint, entryPointDirection } = state.routeState;
45+
const { entryPoint, exitPoint } = state.routeState;
4646

4747
const [postPathfinding] = osrdEditoastApi.endpoints.postInfraByIdPathfinding.useMutation();
4848

4949
const searchCandidates = useCallback(async () => {
50-
if (!entryPoint || !exitPoint || !entryPointDirection || state.optionsState.type === 'loading')
51-
return;
50+
if (!entryPoint || !exitPoint || state.optionsState.type === 'loading') return;
5251

5352
setState({
5453
optionsState: { type: 'loading' },
@@ -57,7 +56,6 @@ export const EditRoutePathLeftPanel: FC<{ state: EditRoutePathState }> = ({ stat
5756
const payload = await getCompatibleRoutesPayload(
5857
infraID as number,
5958
entryPoint,
60-
entryPointDirection,
6159
exitPoint,
6260
dispatch
6361
);
@@ -87,7 +85,7 @@ export const EditRoutePathLeftPanel: FC<{ state: EditRoutePathState }> = ({ stat
8785
})),
8886
},
8987
});
90-
}, [entryPoint, entryPointDirection, exitPoint, infraID, setState, state.optionsState.type]);
88+
}, [entryPoint, exitPoint, infraID, setState, state.optionsState.type]);
9189

9290
const focusedOptionIndex =
9391
state.optionsState.type === 'options' ? state.optionsState.focusedOptionIndex : null;
@@ -108,12 +106,7 @@ export const EditRoutePathLeftPanel: FC<{ state: EditRoutePathState }> = ({ stat
108106
<button
109107
className="btn btn-primary btn-sm mr-2 d-block w-100 text-center"
110108
type="submit"
111-
disabled={
112-
!entryPoint ||
113-
!entryPointDirection ||
114-
!exitPoint ||
115-
state.optionsState.type === 'loading'
116-
}
109+
disabled={!entryPoint || !exitPoint || state.optionsState.type === 'loading'}
117110
>
118111
<FiSearch /> {t('Editor.tools.routes-edition.search-routes')}
119112
</button>
@@ -222,7 +215,6 @@ export const EditRoutePathLeftPanel: FC<{ state: EditRoutePathState }> = ({ stat
222215
id: '', // will be replaced by entityToCreateOperation
223216
entry_point: omit(entryPoint, 'position'),
224217
exit_point: omit(exitPoint, 'position'),
225-
entry_point_direction: entryPointDirection,
226218
switches_directions: candidate.data.switches_directions,
227219
release_detectors: includeReleaseDetectors
228220
? candidate.data.detectors

front/src/applications/editor/tools/routeEdition/components/Endpoints.tsx

+3-33
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
import Select from 'react-select';
2-
import React, { FC, useContext, useMemo } from 'react';
1+
import React, { FC, useContext } from 'react';
32
import { BsArrowBarRight, BsBoxArrowInRight } from 'react-icons/bs';
43
import { HiSwitchVertical } from 'react-icons/hi';
54
import { FaFlagCheckered } from 'react-icons/fa';
65
import { useTranslation } from 'react-i18next';
76
import { useDispatch, useSelector } from 'react-redux';
87

98
import { getInfraID } from 'reducers/osrdconf/selectors';
10-
import { BufferStopEntity, DetectorEntity, DIRECTIONS, WayPoint, WayPointEntity } from 'types';
9+
import { BufferStopEntity, DetectorEntity, WayPoint, WayPointEntity } from 'types';
1110
import EditorContext from 'applications/editor/context';
1211
import { getEntity } from 'applications/editor/data/api';
1312
import EntitySumUp from 'applications/editor/components/EntitySumUp';
@@ -20,20 +19,7 @@ export const EditEndpoints: FC<{ state: RouteState; onChange: (newState: RouteSt
2019
onChange,
2120
}) => {
2221
const { t } = useTranslation();
23-
const { entryPoint, exitPoint, entryPointDirection } = state;
24-
25-
const options = useMemo(
26-
() =>
27-
DIRECTIONS.map((s) => ({
28-
value: s,
29-
label: t(`Editor.tools.routes-edition.directions.${s}`),
30-
})),
31-
[t]
32-
);
33-
const option = useMemo(
34-
() => options.find((o) => o.value === entryPointDirection) || options[0],
35-
[options, entryPointDirection]
36-
);
22+
const { entryPoint, exitPoint } = state;
3723

3824
return (
3925
<>
@@ -45,22 +31,6 @@ export const EditEndpoints: FC<{ state: RouteState; onChange: (newState: RouteSt
4531
wayPoint={entryPoint}
4632
onChange={(wayPoint) => onChange({ ...state, entryPoint: wayPoint })}
4733
/>
48-
{entryPoint && (
49-
<div className="d-flex flex-row align-items-baseline justify-content-center mb-2">
50-
<span className="mr-2">{t('Editor.tools.routes-edition.start_direction')}</span>
51-
<Select
52-
value={option}
53-
options={options}
54-
onChange={(o) => {
55-
if (o)
56-
onChange({
57-
...state,
58-
entryPointDirection: o.value,
59-
});
60-
}}
61-
/>
62-
</div>
63-
)}
6434
<div className="text-center">
6535
<button
6636
type="button"

front/src/applications/editor/tools/routeEdition/utils.ts

-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import { getEntities, getEntity, getMixedEntities } from 'applications/editor/da
99
import { DEFAULT_COMMON_TOOL_STATE } from 'applications/editor/tools/commonToolState';
1010
import { RouteCandidate, RouteEditionState } from 'applications/editor/tools/routeEdition/types';
1111
import {
12-
Direction,
1312
PartialButFor,
1413
RouteEntity,
1514
TrackRange,
@@ -220,7 +219,6 @@ export async function getRouteGeometries(
220219
export async function getCompatibleRoutesPayload(
221220
infra: number,
222221
entryPoint: WayPoint,
223-
entryPointDirection: Direction,
224222
exitPoint: WayPoint,
225223
dispatch: Dispatch
226224
) {
@@ -240,7 +238,6 @@ export async function getCompatibleRoutesPayload(
240238
starting: {
241239
track: entryPointEntity.properties.track as string,
242240
position: entryPointEntity.properties.position as number,
243-
direction: entryPointDirection,
244241
},
245242
ending: {
246243
track: exitPointEntity.properties.track as string,

front/src/common/api/osrdEditoastApi.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -905,9 +905,7 @@ export type PostInfraByIdPathfindingApiArg = {
905905
/** Starting and ending track location */
906906
body: {
907907
ending?: TrackLocation;
908-
starting?: TrackLocation & {
909-
direction?: Direction;
910-
};
908+
starting?: TrackLocation;
911909
};
912910
};
913911
export type GetInfraByIdRailjsonApiResponse =

0 commit comments

Comments
 (0)