From 56b48bb5cccee8e626cfc32565b64bf383529d84 Mon Sep 17 00:00:00 2001 From: Amelia Vance Date: Mon, 1 Apr 2024 14:41:35 -0400 Subject: [PATCH 1/4] Rename and create admin-tools page and routing from scans --- frontend/src/App.tsx | 20 ++++++---- frontend/src/components/Header.tsx | 12 +++--- frontend/src/pages/AdminTools/AdminTools.tsx | 39 ++++++++++++++++++++ frontend/src/pages/AdminTools/index.ts | 1 + frontend/src/pages/index.ts | 1 + 5 files changed, 60 insertions(+), 13 deletions(-) create mode 100644 frontend/src/pages/AdminTools/AdminTools.tsx create mode 100644 frontend/src/pages/AdminTools/index.ts diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 818a0f3d..337182d3 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -15,6 +15,7 @@ import { } from '@jonkoops/matomo-tracker-react'; import { Domain, + AdminTools, AuthLogin, AuthLoginCreate, AuthCreateAccount, @@ -167,21 +168,26 @@ const App: React.FC = () => ( permissions={['standard', 'globalView']} /> + {/* + // permissions={['standard', 'globalView']} + /> */} = (props) => { if (user && user.isRegistered) { if (user.userType === 'standard') { userLevel = STANDARD_USER; + } else if (user.userType === 'globalAdmin') { + userLevel = GLOBAL_ADMIN; } else if ( - user.userType === 'globalAdmin' || + user.userType === 'regionalAdmin' || user.userType === 'globalView' ) { - userLevel = GLOBAL_ADMIN; - } else if (user.userType === 'regionalAdmin') { userLevel = REGIONAL_ADMIN; } } @@ -232,8 +232,8 @@ const HeaderNoCtx: React.FC = (props) => { onClick: toggleDrawer(false) }, { - title: 'Scans', - path: '/scans', + title: 'Admin Tools', + path: '/admin-tools/scans', users: GLOBAL_ADMIN, exact: true, onClick: toggleDrawer(false) @@ -258,7 +258,7 @@ const HeaderNoCtx: React.FC = (props) => { { title: 'Manage Organizations', path: '/organizations', - users: GLOBAL_ADMIN, + users: REGIONAL_ADMIN, exact: true }, { diff --git a/frontend/src/pages/AdminTools/AdminTools.tsx b/frontend/src/pages/AdminTools/AdminTools.tsx new file mode 100644 index 00000000..3b8a2c79 --- /dev/null +++ b/frontend/src/pages/AdminTools/AdminTools.tsx @@ -0,0 +1,39 @@ +import React from 'react'; +import classes from 'pages/Scans/Scans.module.scss'; +import ScansView from 'pages/Scans/ScansView'; +import ScanTasksView from 'pages/Scans/ScanTasksView'; +import { Subnav } from 'components'; +import { Switch, Route } from 'react-router-dom'; + +export const AdminTools: React.FC = () => { + return ( + <> + +
+ + + + + + + + +
+ + ); +}; + +export default AdminTools; diff --git a/frontend/src/pages/AdminTools/index.ts b/frontend/src/pages/AdminTools/index.ts new file mode 100644 index 00000000..074285ee --- /dev/null +++ b/frontend/src/pages/AdminTools/index.ts @@ -0,0 +1 @@ +export { default } from './AdminTools'; diff --git a/frontend/src/pages/index.ts b/frontend/src/pages/index.ts index c3392002..a25fa0e6 100644 --- a/frontend/src/pages/index.ts +++ b/frontend/src/pages/index.ts @@ -7,6 +7,7 @@ export * from './Vulnerability'; export * from './TermsOfUse'; export * from './Search'; export * from './LoginGovCallback'; +export { default as AdminTools } from './AdminTools'; export { default as Organization } from './Organization'; export { default as Vulnerabilities } from './Vulnerabilities'; export { default as Risk } from './Risk'; From bf9c45f97ce52226b4decd11c5a93667c2876678 Mon Sep 17 00:00:00 2001 From: Amelia Vance Date: Mon, 1 Apr 2024 15:08:07 -0400 Subject: [PATCH 2/4] Update header placement of admin tools --- frontend/src/components/Header.tsx | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/frontend/src/components/Header.tsx b/frontend/src/components/Header.tsx index 3cd35560..202b1b61 100644 --- a/frontend/src/components/Header.tsx +++ b/frontend/src/components/Header.tsx @@ -230,13 +230,6 @@ const HeaderNoCtx: React.FC = (props) => { users: STANDARD_USER, exact: false, onClick: toggleDrawer(false) - }, - { - title: 'Admin Tools', - path: '/admin-tools/scans', - users: GLOBAL_ADMIN, - exact: true, - onClick: toggleDrawer(false) } ].filter(({ users }) => users <= userLevel); @@ -249,6 +242,12 @@ const HeaderNoCtx: React.FC = (props) => { path: '#', exact: false, nested: [ + { + title: 'Admin Tools', + path: '/admin-tools/scans', + users: GLOBAL_ADMIN, + exact: true + }, { title: 'User Registration', path: '/region-admin-dashboard', From 24580096417ce5f9a6e0c8e9b646e3f16565c83e Mon Sep 17 00:00:00 2001 From: Amelia Vance Date: Mon, 1 Apr 2024 15:12:05 -0400 Subject: [PATCH 3/4] Remove scans from test header.spec.tsx --- frontend/src/components/__tests__/header.spec.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/components/__tests__/header.spec.tsx b/frontend/src/components/__tests__/header.spec.tsx index 7b1189d8..99f9ed13 100644 --- a/frontend/src/components/__tests__/header.spec.tsx +++ b/frontend/src/components/__tests__/header.spec.tsx @@ -66,7 +66,7 @@ describe('Header component', () => { currentOrganization: { ...testOrganization } } }); - ['Overview', 'Inventory', 'Scans'].forEach((expected) => { + ['Overview', 'Inventory'].forEach((expected) => { expect(getByText(expected)).toBeInTheDocument(); }); }); From df615b5cf6b074329def392f28473d113024ca21 Mon Sep 17 00:00:00 2001 From: Amelia Vance Date: Mon, 8 Apr 2024 12:04:28 -0400 Subject: [PATCH 4/4] Remove the commented code I added in App.tsx --- frontend/src/App.tsx | 9 --------- 1 file changed, 9 deletions(-) diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 337182d3..6d60ea15 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -170,24 +170,15 @@ const App: React.FC = () => ( - {/* */}