Skip to content

Commit

Permalink
[frontend] Change app routing /exercises to /simulations (#1940)
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaumejparis authored Nov 28, 2024
1 parent 8dc8497 commit eb0d6aa
Show file tree
Hide file tree
Showing 26 changed files with 64 additions and 64 deletions.
6 changes: 3 additions & 3 deletions openbas-front/src/admin/Index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ const Index = () => {
<Route path="profile/*" element={errorWrapper(IndexProfile)()} />
<Route path="" element={errorWrapper(Dashboard)()} />
<Route path="fulltextsearch" element={errorWrapper(FullTextSearch)()} />
<Route path="exercises" element={errorWrapper(Exercises)()} />
<Route path="exercises/:exerciseId/*" element={errorWrapper(IndexExercise)()} />
<Route path="exercises/:exerciseId/injects/:injectId/*" element={errorWrapper(InjectIndex)()} />
<Route path="simulations" element={errorWrapper(Exercises)()} />
<Route path="simulations/:exerciseId/*" element={errorWrapper(IndexExercise)()} />
<Route path="simulations/:exerciseId/injects/:injectId/*" element={errorWrapper(InjectIndex)()} />
<Route path="atomic_testings" element={errorWrapper(AtomicTestings)()} />
<Route path="atomic_testings/:injectId/*" element={errorWrapper(IndexAtomicTesting)()} />
<Route path="scenarios" element={errorWrapper(Scenarios)()} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ const InjectPopover: FunctionComponent<Props> = ({
testInject(inject.inject_id).then((result: { data: InjectTestStatus }) => {
if (isExercise) {
MESSAGING$.notifySuccess(t('Inject test has been sent, you can view test logs details on {itsDedicatedPage}.', {
itsDedicatedPage: <Link to={`/admin/exercises/${exerciseOrScenarioId}/tests/${result.data.status_id}`}>{t('its dedicated page')}</Link>,
itsDedicatedPage: <Link to={`/admin/simulations/${exerciseOrScenarioId}/tests/${result.data.status_id}`}>{t('its dedicated page')}</Link>,
}));
} else {
MESSAGING$.notifySuccess(t('Inject test has been sent, you can view test logs details on {itsDedicatedPage}.', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ const Challenges = () => {
label={exercise.exercise_name}
component={Link}
clickable={true}
to={`/admin/exercises/${exercise.exercise_id}`}
to={`/admin/simulations/${exercise.exercise_id}`}
/>
</Tooltip>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ const Documents = () => {
// prevent parent link from triggering
event.stopPropagation();
event.preventDefault();
navigate(`/admin/exercises/${exercise.exercise_id}`);
navigate(`/admin/simulations/${exercise.exercise_id}`);
}
}
/>
Expand Down
4 changes: 2 additions & 2 deletions openbas-front/src/admin/components/nav/LeftBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -380,8 +380,8 @@ const LeftBar = () => {
<StyledTooltip title={!navOpen && t('Simulations')} placement="right">
<MenuItem
component={Link}
to="/admin/exercises"
selected={location.pathname.includes('/admin/exercises')}
to="/admin/simulations"
selected={location.pathname.includes('/admin/simulations')}
dense
classes={{ root: classes.menuItem }}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ const ScenarioHeader = ({
setOpenInstantiateSimulationAndStart(false);
const exercise: Exercise = (await createRunningExerciseFromScenario(scenarioId)).data;
MESSAGING$.notifySuccess(t('New simulation successfully created and started. Click {here} to view the simulation.', {
here: <Link to={`/admin/exercises/${exercise.exercise_id}`}>{t('here')}</Link>,
here: <Link to={`/admin/simulations/${exercise.exercise_id}`}>{t('here')}</Link>,
}));
}}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const useEntityLink = (entity: string, id: string, searchTerm: string) => {
case 'Scenario':
return `/admin/scenarios/${id}}`;
case 'Exercise':
return `/admin/exercises/${id}`;
return `/admin/simulations/${id}`;
default:
return ('');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ const ExerciseList: FunctionComponent<Props> = ({
<ListItemButton
classes={{ root: classes.item }}
component={Link}
to={`/admin/exercises/${exercise.exercise_id}`}
to={`/admin/simulations/${exercise.exercise_id}`}
>
<ListItemIcon>
<HubOutlined color="primary" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ const AnimationMenu: React.FC<Props> = ({ exerciseId }) => {
<MenuList component="nav">
<MenuItem
component={Link}
to={`/admin/exercises/${exerciseId}/animation/timeline`}
to={`/admin/simulations/${exerciseId}/animation/timeline`}
selected={
location.pathname
=== `/admin/exercises/${exerciseId}/animation/timeline`
=== `/admin/simulations/${exerciseId}/animation/timeline`
}
classes={{ root: classes.item }}
>
Expand All @@ -56,9 +56,9 @@ const AnimationMenu: React.FC<Props> = ({ exerciseId }) => {
</MenuItem>
<MenuItem
component={Link}
to={`/admin/exercises/${exerciseId}/animation/mails`}
to={`/admin/simulations/${exerciseId}/animation/mails`}
selected={location.pathname.includes(
`/admin/exercises/${exerciseId}/animation/mails`,
`/admin/simulations/${exerciseId}/animation/mails`,
)}
classes={{ root: classes.item }}
>
Expand All @@ -69,10 +69,10 @@ const AnimationMenu: React.FC<Props> = ({ exerciseId }) => {
</MenuItem>
<MenuItem
component={Link}
to={`/admin/exercises/${exerciseId}/animation/validations`}
to={`/admin/simulations/${exerciseId}/animation/validations`}
selected={
location.pathname
=== `/admin/exercises/${exerciseId}/animation/validations`
=== `/admin/simulations/${exerciseId}/animation/validations`
}
classes={{ root: classes.item }}
>
Expand All @@ -83,10 +83,10 @@ const AnimationMenu: React.FC<Props> = ({ exerciseId }) => {
</MenuItem>
<MenuItem
component={Link}
to={`/admin/exercises/${exerciseId}/animation/logs`}
to={`/admin/simulations/${exerciseId}/animation/logs`}
selected={
location.pathname
=== `/admin/exercises/${exerciseId}/animation/logs`
=== `/admin/simulations/${exerciseId}/animation/logs`
}
classes={{ root: classes.item }}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const injectContextForExercise = (exercise: ExerciseStore) => {
},
bulkTestInjects(injectIds: string[]): Promise<{ uri: string; data: InjectTestStatus[] }> {
return bulkTestInjects(injectIds).then(result => ({
uri: `/admin/exercises/${exercise.exercise_id}/tests`,
uri: `/admin/simulations/${exercise.exercise_id}/tests`,
data: result.data,
}));
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const ExerciseCreation = () => {
const onSubmit = (data: ExerciseInput) => {
dispatch(addExercise(data)).then((result: { result: string; entities: { scenarios: Record<string, ExerciseStore> } }) => {
setOpen(false);
navigate(`/admin/exercises/${result.result}`);
navigate(`/admin/simulations/${result.result}`);
});
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ const ExerciseHeader = () => {
<ExercisePopover
exercise={exercise}
actions={actions}
onDelete={() => navigate('/admin/exercises')}
onDelete={() => navigate('/admin/simulations')}
/>
</div>
<div className="clearfix" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ const ExercisePopover: FunctionComponent<ExercisePopoverProps> = ({
const submitDuplicate = () => {
dispatch(duplicateExercise(exercise.exercise_id)).then((result: { result: string; entities: { exercises: ExerciseStore } }) => {
handleCloseDuplicate();
navigate(`/admin/exercises/${result.result}`);
navigate(`/admin/simulations/${result.result}`);
});
};

Expand Down
42 changes: 21 additions & 21 deletions openbas-front/src/admin/components/simulations/simulation/Index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ const IndexComponent: FunctionComponent<{ exercise: ExerciseType }> = ({
}),
};
let tabValue = location.pathname;
if (location.pathname.includes(`/admin/exercises/${exercise.exercise_id}/definition`)) {
tabValue = `/admin/exercises/${exercise.exercise_id}/definition`;
} else if (location.pathname.includes(`/admin/exercises/${exercise.exercise_id}/animation`)) {
tabValue = `/admin/exercises/${exercise.exercise_id}/animation`;
} else if (location.pathname.includes(`/admin/exercises/${exercise.exercise_id}/results`)) {
tabValue = `/admin/exercises/${exercise.exercise_id}/results`;
} else if (location.pathname.includes(`/admin/exercises/${exercise.exercise_id}/tests`)) {
tabValue = `/admin/exercises/${exercise.exercise_id}/tests`;
if (location.pathname.includes(`/admin/simulations/${exercise.exercise_id}/definition`)) {
tabValue = `/admin/simulations/${exercise.exercise_id}/definition`;
} else if (location.pathname.includes(`/admin/simulations/${exercise.exercise_id}/animation`)) {
tabValue = `/admin/simulations/${exercise.exercise_id}/animation`;
} else if (location.pathname.includes(`/admin/simulations/${exercise.exercise_id}/results`)) {
tabValue = `/admin/simulations/${exercise.exercise_id}/results`;
} else if (location.pathname.includes(`/admin/simulations/${exercise.exercise_id}/tests`)) {
tabValue = `/admin/simulations/${exercise.exercise_id}/tests`;
}
return (
<PermissionsContext.Provider value={permissionsContext}>
Expand All @@ -76,7 +76,7 @@ const IndexComponent: FunctionComponent<{ exercise: ExerciseType }> = ({
<Breadcrumbs
variant="object"
elements={[
{ label: t('Simulations'), link: '/admin/exercises' },
{ label: t('Simulations'), link: '/admin/simulations' },
{ label: exercise.exercise_name, current: true },
]}
/>
Expand All @@ -91,38 +91,38 @@ const IndexComponent: FunctionComponent<{ exercise: ExerciseType }> = ({
<Tabs value={tabValue}>
<Tab
component={Link}
to={`/admin/exercises/${exercise.exercise_id}`}
value={`/admin/exercises/${exercise.exercise_id}`}
to={`/admin/simulations/${exercise.exercise_id}`}
value={`/admin/simulations/${exercise.exercise_id}`}
label={t('Overview')}
/>
<Tab
component={Link}
to={`/admin/exercises/${exercise.exercise_id}/definition`}
value={`/admin/exercises/${exercise.exercise_id}/definition`}
to={`/admin/simulations/${exercise.exercise_id}/definition`}
value={`/admin/simulations/${exercise.exercise_id}/definition`}
label={t('Definition')}
/>
<Tab
component={Link}
to={`/admin/exercises/${exercise.exercise_id}/injects`}
value={`/admin/exercises/${exercise.exercise_id}/injects`}
to={`/admin/simulations/${exercise.exercise_id}/injects`}
value={`/admin/simulations/${exercise.exercise_id}/injects`}
label={t('Injects')}
/>
<Tab
component={Link}
to={`/admin/exercises/${exercise.exercise_id}/tests`}
value={`/admin/exercises/${exercise.exercise_id}/tests`}
to={`/admin/simulations/${exercise.exercise_id}/tests`}
value={`/admin/simulations/${exercise.exercise_id}/tests`}
label={t('Tests')}
/>
<Tab
component={Link}
to={`/admin/exercises/${exercise.exercise_id}/animation`}
value={`/admin/exercises/${exercise.exercise_id}/animation`}
to={`/admin/simulations/${exercise.exercise_id}/animation`}
value={`/admin/simulations/${exercise.exercise_id}/animation`}
label={t('Animation')}
/>
<Tab
component={Link}
to={`/admin/exercises/${exercise.exercise_id}/lessons`}
value={`/admin/exercises/${exercise.exercise_id}/lessons`}
to={`/admin/simulations/${exercise.exercise_id}/lessons`}
value={`/admin/simulations/${exercise.exercise_id}/lessons`}
label={t('Lessons learned')}
/>
</Tabs>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const ExerciseChallenges = () => {
};
return (
<ChallengeContext.Provider value={context}>
<ContextualChallenges challenges={challenges} linkToInjects={`/admin/exercises/${exerciseId}/injects`} />
<ContextualChallenges challenges={challenges} linkToInjects={`/admin/simulations/${exerciseId}/injects`} />
</ChallengeContext.Provider>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const CreateControl: React.FC<Props> = ({ exerciseId, variant }) => {
const onSubmitComcheck = async (data: ComcheckInput) => {
const result = await dispatch(addComcheck(exerciseId, data));
navigate(
`/admin/exercises/${exerciseId}/controls/comchecks/${result.result}`,
`/admin/simulations/${exerciseId}/controls/comchecks/${result.result}`,
);
};

Expand All @@ -73,7 +73,7 @@ const CreateControl: React.FC<Props> = ({ exerciseId, variant }) => {

const result = await dispatch(addDryrun(exerciseId, inputValues));
navigate(
`/admin/exercises/${exerciseId}/controls/dryruns/${result.result}`,
`/admin/simulations/${exerciseId}/controls/dryruns/${result.result}`,
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const ExerciseControlComChecks: FunctionComponent<Props> = ({
classes={{ root: classes.item }}
divider
component={Link}
to={`/admin/exercises/${exercise.exercise_id}/controls/comchecks/${comcheck.comcheck_id}`}
to={`/admin/simulations/${exercise.exercise_id}/controls/comchecks/${comcheck.comcheck_id}`}
>
<ListItemIcon>
<MarkEmailReadOutlined />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const ExerciseControlDryRuns: FunctionComponent<Props> = ({
classes={{ root: classes.item }}
divider
component={Link}
to={`/admin/exercises/${exercise.exercise_id}/controls/dryruns/${dryrun.dryrun_id}`}
to={`/admin/simulations/${exercise.exercise_id}/controls/dryruns/${dryrun.dryrun_id}`}
>
<ListItemIcon>
<VideoSettingsOutlined />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const ExerciseSettings = () => {

return (
<>
<DefinitionMenu base="/admin/exercises" id={exercise.exercise_id} />
<DefinitionMenu base="/admin/simulations" id={exercise.exercise_id} />
<Grid container spacing={3} style={{ marginBottom: 24 }}>
<Grid item xs={3} sx={{ display: 'flex', flexDirection: 'column' }}>
<PaperMetric title={t('Players')} icon={<PersonOutlined />} number={exercise.exercise_users_number ?? '-'} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ const ExerciseInjects: FunctionComponent = () => {
teams={teams}
articles={articles}
variables={variables}
uriVariable={`/admin/exercises/${exerciseId}/definition`}
uriVariable={`/admin/simulations/${exerciseId}/definition`}
allUsersNumber={exercise.exercise_all_users_number}
usersNumber={exercise.exercise_users_number}
// @ts-expect-error typing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ const InjectIndexComponent: FunctionComponent<{ exercise: ExerciseType; injectRe
};

const breadcrumbs: BreadcrumbsElement[] = [
{ label: t('Simulations'), link: '/admin/exercises' },
{ label: t(exercise.exercise_name), link: `/admin/exercises/${exercise.exercise_id}` },
{ label: t('Simulations'), link: '/admin/simulations' },
{ label: t(exercise.exercise_name), link: `/admin/simulations/${exercise.exercise_id}` },
];
if (backlabel && backuri) {
breadcrumbs.push({ label: backlabel, link: backuri });
Expand All @@ -84,15 +84,15 @@ const InjectIndexComponent: FunctionComponent<{ exercise: ExerciseType; injectRe
<Tabs value={tabValue}>
<Tab
component={Link}
to={`/admin/exercises/${exercise.exercise_id}/injects/${injectResultOverviewOutput.inject_id}`}
value={`/admin/exercises/${exercise.exercise_id}/injects/${injectResultOverviewOutput.inject_id}`}
to={`/admin/simulations/${exercise.exercise_id}/injects/${injectResultOverviewOutput.inject_id}`}
value={`/admin/simulations/${exercise.exercise_id}/injects/${injectResultOverviewOutput.inject_id}`}
label={t('Overview')}
className={classes.item}
/>
<Tab
component={Link}
to={`/admin/exercises/${exercise.exercise_id}/injects/${injectResultOverviewOutput.inject_id}/detail`}
value={`/admin/exercises/${exercise.exercise_id}/injects/${injectResultOverviewOutput.inject_id}/detail`}
to={`/admin/simulations/${exercise.exercise_id}/injects/${injectResultOverviewOutput.inject_id}/detail`}
value={`/admin/simulations/${exercise.exercise_id}/injects/${injectResultOverviewOutput.inject_id}/detail`}
label={t('Execution details')}
className={classes.item}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1426,7 +1426,7 @@ class QuickInject extends Component {
</Form>
</div>
<AvailableVariablesDialog
uriVariable={`/admin/exercises/${exerciseId}/definition`}
uriVariable={`/admin/simulations/${exerciseId}/definition`}
variables={this.props.exerciseVariables}
open={openVariables}
handleClose={this.handleCloseVariables.bind(this)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ const Mails = () => {
<ListItemButton
key={inject.inject_id}
component={Link}
to={`/admin/exercises/${exerciseId}/animation/mails/${inject.inject_id}`}
to={`/admin/simulations/${exerciseId}/animation/mails/${inject.inject_id}`}
classes={{ root: classes.item }}
divider={true}
>
Expand Down
Loading

0 comments on commit eb0d6aa

Please sign in to comment.