Skip to content

Commit

Permalink
[frontend] Fix tags displayed and links to item exercises lists (#1610)
Browse files Browse the repository at this point in the history
  • Loading branch information
damgouj authored Oct 21, 2024
1 parent 190c8e0 commit 7b1f920
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 7 deletions.
7 changes: 6 additions & 1 deletion openbas-front/src/admin/Index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import Loader from '../components/Loader';
import NotFound from '../components/NotFound';
import InjectIndex from './components/simulations/simulation/injects/InjectIndex';
import SystemBanners, { computeBannerSettings } from '../public/components/systembanners/SystemBanners';
import { fetchTags } from '../actions/Tag';
import { useAppDispatch } from '../utils/hooks';

const Dashboard = lazy(() => import('./components/Dashboard'));
const IndexProfile = lazy(() => import('./components/profile/Index'));
Expand Down Expand Up @@ -57,7 +59,10 @@ const Index = () => {
overflowX: 'hidden',
overflowY: 'hidden',
};
useDataLoader();
const dispatch = useAppDispatch();
useDataLoader(() => {
dispatch(fetchTags());
});
const { bannerHeight } = computeBannerSettings(settings);
return (
<>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { CSSProperties, FunctionComponent, useMemo, useState } from 'react';
import { Link } from 'react-router-dom';
import { makeStyles } from '@mui/styles';
import { List, ListItem, ListItemButton, ListItemIcon, ListItemText } from '@mui/material';
import { useFormatter } from '../../../components/i18n';
Expand Down Expand Up @@ -195,7 +196,8 @@ const InjectDtoList: FunctionComponent<Props> = ({
disablePadding
>
<ListItemButton
href={goTo(injectDto.inject_id)}
component={Link}
to={goTo(injectDto.inject_id)}
>
<ListItemIcon>
<InjectIcon
Expand Down
4 changes: 3 additions & 1 deletion openbas-front/src/admin/components/scenarios/Scenarios.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { makeStyles } from '@mui/styles';
import { List, ListItem, ListItemButton, ListItemIcon, ListItemText, ToggleButtonGroup } from '@mui/material';
import { MovieFilterOutlined } from '@mui/icons-material';
import React, { CSSProperties, useMemo, useState } from 'react';
import { Link } from 'react-router-dom';
import { useFormatter } from '../../../components/i18n';
import { useHelper } from '../../../store';
import type { TagHelper, UserHelper } from '../../../actions/helper';
Expand Down Expand Up @@ -244,7 +245,8 @@ const Scenarios = () => {
disablePadding
>
<ListItemButton
href={`/admin/scenarios/${scenario.scenario_id}`}
component={Link}
to={`/admin/scenarios/${scenario.scenario_id}`}
classes={{ root: classes.item }}
>
<ListItemIcon>
Expand Down
20 changes: 16 additions & 4 deletions openbas-front/src/admin/components/simulations/ExerciseList.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { List, ListItem, ListItemButton, ListItemIcon, ListItemText } from '@mui/material';
import { HubOutlined } from '@mui/icons-material';
import React, { CSSProperties, FunctionComponent } from 'react';
import { Link } from 'react-router-dom';
import { makeStyles } from '@mui/styles';
import ExerciseStatus from './simulation/ExerciseStatus';
import ItemTags from '../../../components/ItemTags';
Expand Down Expand Up @@ -82,7 +83,7 @@ const ExerciseList: FunctionComponent<Props> = ({
const dispatch = useAppDispatch();
const classes = useStyles();
const inlineStyles = getInlineStyles(variant);
const { nsdt } = useFormatter();
const { nsdt, vnsdt } = useFormatter();

// Fetching data
useDataLoader(() => {
Expand All @@ -101,7 +102,12 @@ const ExerciseList: FunctionComponent<Props> = ({
field: 'exercise_start_date',
label: 'Start date',
isSortable: true,
value: (exercise: ExerciseSimple) => <>{(exercise.exercise_start_date ? (nsdt(exercise.exercise_start_date)) : ('-'))}</>,
value: (exercise: ExerciseSimple) => {
if (!exercise.exercise_start_date) {
return '-';
}
return <>{(variant === 'reduced-view' ? vnsdt(exercise.exercise_start_date) : nsdt(exercise.exercise_start_date))}</>;
},
},
{
field: 'exercise_status',
Expand Down Expand Up @@ -131,7 +137,12 @@ const ExerciseList: FunctionComponent<Props> = ({
field: 'exercise_updated_at',
label: 'Updated',
isSortable: true,
value: (exercise: ExerciseSimple) => <>{nsdt(exercise.exercise_updated_at)}</>,
value: (exercise: ExerciseSimple) => {
if (!exercise.exercise_updated_at) {
return '-';
}
return <>{(variant === 'reduced-view' ? vnsdt(exercise.exercise_updated_at) : nsdt(exercise.exercise_updated_at))}</>;
},
},
];

Expand Down Expand Up @@ -164,7 +175,8 @@ const ExerciseList: FunctionComponent<Props> = ({
>
<ListItemButton
classes={{ root: classes.item }}
href={`/admin/exercises/${exercise.exercise_id}`}
component={Link}
to={`/admin/exercises/${exercise.exercise_id}`}
>
<ListItemIcon>
<HubOutlined color="primary" />
Expand Down

0 comments on commit 7b1f920

Please sign in to comment.