Skip to content

Commit

Permalink
[frontend] add security for trash root
Browse files Browse the repository at this point in the history
  • Loading branch information
SouadHadjiat committed Apr 4, 2024
1 parent b92e137 commit 238cc3c
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ import useGranted, {
KNOWLEDGE,
KNOWLEDGE_KNASKIMPORT,
KNOWLEDGE_KNUPDATE,
KNOWLEDGE_KNUPDATE_KNDELETE,
MODULES,
SETTINGS,
SETTINGS_SETACCESSES,
Expand Down Expand Up @@ -816,26 +817,27 @@ const LeftBar = () => {
],
)}
</Security>
{/* TODO: <SECURITY> check */}
<StyledTooltip title={!navOpen && t_i18n('Trash')} placement="right">
<MenuItem
component={Link}
to="/dashboard/trash/all"
selected={!navOpen && location.pathname.includes('/dashboard/trash/all')}
dense={true}
classes={{ root: classes.menuItem }}
>
<ListItemIcon classes={{ root: classes.menuItemIcon }} style={{ minWidth: 20 }}>
<DeleteOutlined />
</ListItemIcon>
{navOpen && (
<ListItemText
classes={{ primary: classes.menuItemText }}
primary={t_i18n('Trash')}
/>
)}
</MenuItem>
</StyledTooltip>
<Security needs={[KNOWLEDGE_KNUPDATE_KNDELETE]}>
<StyledTooltip title={!navOpen && t_i18n('Trash')} placement="right">
<MenuItem
component={Link}
to="/dashboard/trash"
selected={!navOpen && location.pathname.includes('/dashboard/trash')}
dense={true}
classes={{ root: classes.menuItem }}
>
<ListItemIcon classes={{ root: classes.menuItemIcon }} style={{ minWidth: 20 }}>
<DeleteOutlined />
</ListItemIcon>
{navOpen && (
<ListItemText
classes={{ primary: classes.menuItemText }}
primary={t_i18n('Trash')}
/>
)}
</MenuItem>
</StyledTooltip>
</Security>
</MenuList>
</Security>
<Security needs={[SETTINGS, MODULES, KNOWLEDGE, TAXIIAPI_SETCOLLECTIONS]}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,24 @@ import React, { Suspense, lazy } from 'react';
import { Switch } from 'react-router-dom';
import { BoundaryRoute } from '../Error';
import Loader from '../../../components/Loader';
import { KNOWLEDGE_KNUPDATE_KNDELETE } from '../../../utils/hooks/useGranted';
import Security from '../../../utils/Security';

const Trash = lazy(() => import('./Trash'));

const Root = () => {
// TODO: <SECURITY> check
return (
<Suspense fallback={<Loader />}>
<Switch>
<BoundaryRoute
exact
path="/dashboard/trash/all"
component={Trash}
/>
</Switch>
</Suspense>
<Security needs={[KNOWLEDGE_KNUPDATE_KNDELETE]}>
<Suspense fallback={<Loader />}>
<Switch>
<BoundaryRoute
exact
path="/dashboard/trash"
component={Trash}
/>
</Switch>
</Suspense>
</Security>
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ const Trash: React.FC = () => {
};
return (
<ExportContextProvider>
<Breadcrumbs variant="list" elements={[{ label: t_i18n('Data') }, { label: t_i18n('Trash'), current: true }]} />
<Breadcrumbs variant="list" elements={[{ label: t_i18n('Trash'), current: true }]} />
{renderLines()}
</ExportContextProvider>
);
Expand Down

0 comments on commit 238cc3c

Please sign in to comment.