Skip to content

Commit

Permalink
Merge pull request #145 from cisagov/133-update-scan-page-and-address…
Browse files Browse the repository at this point in the history
…-dependencies

Rename and create admin-tools page and routing from scans
  • Loading branch information
cduhn17 authored Apr 8, 2024
2 parents 2e95b52 + df615b5 commit 4a4db8f
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 20 deletions.
13 changes: 5 additions & 8 deletions frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
} from '@jonkoops/matomo-tracker-react';
import {
Domain,
AdminTools,
AuthLogin,
AuthLoginCreate,
AuthCreateAccount,
Expand Down Expand Up @@ -167,21 +168,17 @@ const App: React.FC = () => (
permissions={['standard', 'globalView']}
/>
<RouteGuard
path="/scans"
exact
component={Scans}
permissions={['standard', 'globalView']}
path="/admin-tools/scans"
component={AdminTools}
/>
<RouteGuard
path="/scans/history"
path="/admin-tools/scans/history"
component={Scans}
exact
permissions={['standard', 'globalView']}
/>
<RouteGuard
path="/scans/:scanId"
path="/admin-tools/scans/:scanId"
component={Scan}
permissions={['standard', 'globalView']}
/>
<RouteGuard
path="/organizations/:organizationId"
Expand Down
21 changes: 10 additions & 11 deletions frontend/src/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,12 @@ const HeaderNoCtx: React.FC<ContextType> = (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;
}
}
Expand Down Expand Up @@ -230,13 +230,6 @@ const HeaderNoCtx: React.FC<ContextType> = (props) => {
users: STANDARD_USER,
exact: false,
onClick: toggleDrawer(false)
},
{
title: 'Scans',
path: '/scans',
users: GLOBAL_ADMIN,
exact: true,
onClick: toggleDrawer(false)
}
].filter(({ users }) => users <= userLevel);

Expand All @@ -249,6 +242,12 @@ const HeaderNoCtx: React.FC<ContextType> = (props) => {
path: '#',
exact: false,
nested: [
{
title: 'Admin Tools',
path: '/admin-tools/scans',
users: GLOBAL_ADMIN,
exact: true
},
{
title: 'User Registration',
path: '/region-admin-dashboard',
Expand All @@ -258,7 +257,7 @@ const HeaderNoCtx: React.FC<ContextType> = (props) => {
{
title: 'Manage Organizations',
path: '/organizations',
users: GLOBAL_ADMIN,
users: REGIONAL_ADMIN,
exact: true
},
{
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/__tests__/header.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ describe('Header component', () => {
currentOrganization: { ...testOrganization }
}
});
['Overview', 'Inventory', 'Scans'].forEach((expected) => {
['Overview', 'Inventory'].forEach((expected) => {
expect(getByText(expected)).toBeInTheDocument();
});
});
Expand Down
39 changes: 39 additions & 0 deletions frontend/src/pages/AdminTools/AdminTools.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<>
<Subnav
items={[
{
title: 'Scans',
path: `/admin-tools/scans`,
exact: true
},
{
title: 'Scan History',
path: `/admin-tools/scans/history`,
exact: true
}
]}
></Subnav>
<div className={classes.root}>
<Switch>
<Route path="/admin-tools/scans" exact>
<ScansView />
</Route>
<Route path="/admin-tools/scans/history" exact>
<ScanTasksView />
</Route>
</Switch>
</div>
</>
);
};

export default AdminTools;
1 change: 1 addition & 0 deletions frontend/src/pages/AdminTools/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './AdminTools';
1 change: 1 addition & 0 deletions frontend/src/pages/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down

0 comments on commit 4a4db8f

Please sign in to comment.