Skip to content

Commit

Permalink
[frontend] Fix Data > Ingestion and Processing menus access (#6312) (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
SouadHadjiat committed Mar 14, 2024
1 parent 1278c91 commit 7b2a771
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import React from 'react';
import NavToolbarMenu, { MenuEntry } from '@components/common/menus/NavToolbarMenu';
import useGranted, { MODULES } from '../../../utils/hooks/useGranted';
import useGranted, { MODULES, SETTINGS } from '../../../utils/hooks/useGranted';

const IngestionMenu = () => {
const isConnectorReader = useGranted([MODULES]);
const entries: MenuEntry[] = [
const isGrantedSettings = useGranted([SETTINGS]);
const settingsEntries: MenuEntry[] = [
{
path: '/dashboard/data/ingestion/sync',
label: 'Remote OCTI Streams',
Expand All @@ -22,6 +23,7 @@ const IngestionMenu = () => {
label: 'CSV Feeds',
},
];
const entries: MenuEntry[] = isGrantedSettings ? [...settingsEntries] : [];
if (isConnectorReader) {
entries.push({
path: '/dashboard/data/ingestion/connectors',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { Suspense, lazy } from 'react';
import { Switch, Redirect } from 'react-router-dom';
import { BoundaryRoute } from '../Error';
import { KNOWLEDGE_KNUPDATE, SETTINGS_SETACCESSES, TAXIIAPI_SETCSVMAPPERS } from '../../../utils/hooks/useGranted';
import { KNOWLEDGE_KNUPDATE, MODULES, SETTINGS, SETTINGS_SETACCESSES, TAXIIAPI_SETCSVMAPPERS } from '../../../utils/hooks/useGranted';
import Loader from '../../../components/Loader';

const CsvMappers = lazy(() => import('./CsvMappers'));
Expand Down Expand Up @@ -44,7 +44,23 @@ const Root = () => {
<BoundaryRoute
exact
path="/dashboard/data/ingestion"
render={() => <Redirect to="/dashboard/data/ingestion/sync" />}
render={() => (
<Security
needs={[SETTINGS]}
placeholder={(
<Security
needs={[MODULES]}
placeholder={(
<Redirect to="/dashboard" />
)}
>
<Redirect to="/dashboard/data/ingestion/connectors" />
</Security>
)}
>
<Redirect to="/dashboard/data/ingestion/sync" />
</Security>
)}
/>
<BoundaryRoute
exact
Expand Down Expand Up @@ -104,7 +120,7 @@ const Root = () => {
path="/dashboard/data/processing"
render={() => (
<Security
needs={[KNOWLEDGE_KNUPDATE, SETTINGS_SETACCESSES]}
needs={[SETTINGS_SETACCESSES]}
placeholder={(
<Security
needs={[TAXIIAPI_SETCSVMAPPERS]}
Expand Down Expand Up @@ -143,7 +159,14 @@ const Root = () => {
<BoundaryRoute
exact
path="/dashboard/data/processing/tasks"
component={Tasks}
render={() => (
<Security
needs={[KNOWLEDGE_KNUPDATE]}
placeholder={<Redirect to="/dashboard" />}
>
<Tasks />
</Security>
)}
/>
</Switch>
</Suspense>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ const LeftBar = () => {
const isGrantedToProcessing = useGranted([KNOWLEDGE_KNUPDATE, SETTINGS_SETACCESSES, TAXIIAPI_SETCSVMAPPERS]);
const isGrantedToSharing = useGranted([TAXIIAPI_SETCOLLECTIONS]);
const isGrantedToSettings = useGranted([SETTINGS]);
const isGrantedToIngestion = useGranted([SETTINGS, MODULES]);
const isOrganizationAdmin = useGranted([VIRTUAL_ORGANIZATION_ADMIN]);
const isGrantedToLabels = useGranted([SETTINGS_SETLABELS]);
const isGrantedToSecurity = useGranted([SETTINGS_SETMARKINGS, SETTINGS_SETACCESSES, VIRTUAL_ORGANIZATION_ADMIN]);
Expand Down Expand Up @@ -783,7 +784,7 @@ const LeftBar = () => {
[
{ granted: isGrantedToKnowledge, link: '/dashboard/data/entities', label: 'Entities' },
{ granted: isGrantedToKnowledge, link: '/dashboard/data/relationships', label: 'Relationships' },
{ granted: isGrantedToSettings, link: '/dashboard/data/ingestion', label: 'Ingestion' },
{ granted: isGrantedToIngestion, link: '/dashboard/data/ingestion', label: 'Ingestion' },
{ granted: isGrantedToImport, link: '/dashboard/data/import', label: 'Import' },
{ granted: isGrantedToProcessing, link: '/dashboard/data/processing', label: 'Processing' },
{ granted: isGrantedToSharing, link: '/dashboard/data/sharing', label: 'Data sharing' },
Expand Down

0 comments on commit 7b2a771

Please sign in to comment.