Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename and create admin-tools page and routing from scans #145

Merged
merged 4 commits into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading