diff --git a/package-lock.json b/package-lock.json index e6be9778d5..1f54bb8c95 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "gsa", - "version": "23.3.1-dev1", + "version": "24.0.2-dev1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "gsa", - "version": "23.3.1-dev1", + "version": "24.0.2-dev1", "license": "AGPL-3.0+", "dependencies": { "@greenbone/opensight-ui-components": "^0.4.1-alpha6", diff --git a/src/web/components/menu/menu.jsx b/src/web/components/menu/menu.jsx index b6e29768a5..83bfc9204d 100644 --- a/src/web/components/menu/menu.jsx +++ b/src/web/components/menu/menu.jsx @@ -149,7 +149,6 @@ const Menu = () => { label: 'Compliance Audit Reports', to: '/auditreports', activeCondition: useIsActive('/auditreports'), - featureEnabled: 'COMPLIANCE_REPORTS', }, ], secInfo: [ diff --git a/src/web/pages/audits/__tests__/row.jsx b/src/web/pages/audits/__tests__/row.jsx index aff985c754..92c9b97921 100644 --- a/src/web/pages/audits/__tests__/row.jsx +++ b/src/web/pages/audits/__tests__/row.jsx @@ -20,8 +20,8 @@ import {getActionItems} from 'web/components/testing'; import Row from '../row'; const gmp = {settings: {}}; -const featureList = [{name: 'COMPLIANCE_REPORTS', _enabled: 0}]; -const caps = new Capabilities(['everything'], featureList); + +const caps = new Capabilities(['everything']); const lastReport = { report: { @@ -39,734 +39,10 @@ const currentReport = { }; describe('Audit Row tests', () => { - // deactivate console.error for tests - // to make it possible to test a row without a table - const consoleError = console.error; - console.error = () => {}; - - test('should render', () => { - const audit = Audit.fromElement({ - _id: '314', - owner: {name: 'username'}, - name: 'foo', - comment: 'bar', - status: AUDIT_STATUS.done, - alterable: '0', - last_report: lastReport, - permissions: {permission: [{name: 'everything'}]}, - target: {_id: '5678', name: 'target'}, - usage_type: 'audit', - }); - - const handleAuditClone = testing.fn(); - const handleAuditDelete = testing.fn(); - const handleAuditDownload = testing.fn(); - const handleAuditEdit = testing.fn(); - const handleAuditResume = testing.fn(); - const handleAuditStart = testing.fn(); - const handleAuditStop = testing.fn(); - const handleReportDownload = testing.fn(); - const handleToggleDetailsClick = testing.fn(); - - const {render, store} = rendererWith({ - gmp, - capabilities: caps, - store: true, - router: true, - }); - - store.dispatch(setTimezone('CET')); - store.dispatch(setUsername('username')); - - const {element} = render( - , - ); - - expect(element).toBeVisible(); - - // Name - expect(element).toHaveTextContent('foo'); - expect(element).toHaveTextContent('(bar)'); - - // Status - const bars = screen.getAllByTestId('progressbar-box'); - - expect(bars[0]).toHaveAttribute('title', AUDIT_STATUS.done); - expect(bars[0]).toHaveTextContent(AUDIT_STATUS.done); - - const detailsLinks = screen.getAllByTestId('details-link'); - - expect(detailsLinks[0]).toHaveTextContent('Done'); - expect(detailsLinks[0]).toHaveAttribute('href', '/report/1234'); - - // Report - expect(detailsLinks[1]).toHaveTextContent('Wed, Jul 10, 2019 2:51 PM CEST'); - expect(detailsLinks[1]).toHaveAttribute('href', '/report/1234'); - - // Compliance Status - expect(bars[1]).toHaveAttribute('title', '50%'); - expect(bars[1]).toHaveTextContent('50%'); - - // Actions - const icons = getActionItems(); - - expect(icons[0]).toHaveAttribute('title', 'Start'); - expect(icons[1]).toHaveAttribute('title', 'Audit is not stopped'); - expect(icons[2]).toHaveAttribute('title', 'Move Audit to trashcan'); - expect(icons[3]).toHaveAttribute('title', 'Edit Audit'); - expect(icons[4]).toHaveAttribute('title', 'Clone Audit'); - expect(icons[5]).toHaveAttribute('title', 'Export Audit'); - expect(icons[6]).toHaveAttribute( - 'title', - 'Download Greenbone Compliance Report', - ); - }); - - test('should render icons', () => { - const audit = Audit.fromElement({ - _id: '314', - owner: {name: 'username'}, - name: 'foo', - comment: 'bar', - status: AUDIT_STATUS.new, - alterable: '1', - last_report: lastReport, - permissions: {permission: [{name: 'everything'}]}, - target: {_id: 'id', name: 'target'}, - scanner: { - _id: 'id', - name: 'scanner', - type: GREENBONE_SENSOR_SCANNER_TYPE, - }, - observers: { - __text: 'anon nymous', - role: [{name: 'lorem'}], - group: [{name: 'ipsum'}, {name: 'dolor'}], - }, - }); - - const handleAuditClone = testing.fn(); - const handleAuditDelete = testing.fn(); - const handleAuditDownload = testing.fn(); - const handleAuditEdit = testing.fn(); - const handleAuditResume = testing.fn(); - const handleAuditStart = testing.fn(); - const handleAuditStop = testing.fn(); - const handleReportDownload = testing.fn(); - const handleToggleDetailsClick = testing.fn(); - - const {render, store} = rendererWith({ - gmp, - capabilities: caps, - store: true, - router: true, - }); - - store.dispatch(setTimezone('CET')); - store.dispatch(setUsername('username')); - - render( - , - ); - - const icons = getActionItems(); - - expect(icons[0]).toHaveAttribute('title', 'Audit is alterable'); - expect(icons[1]).toHaveAttribute( - 'title', - 'Audit is configured to run on sensor scanner', - ); - expect(icons[2]).toHaveAttribute( - 'title', - 'Audit made visible for:\nUsers anon, nymous\nRoles lorem\nGroups ipsum, dolor', - ); - }); - - test('should call click handlers for new audit', () => { - const audit = Audit.fromElement({ - _id: '314', - owner: {name: 'username'}, - name: 'foo', - comment: 'bar', - status: AUDIT_STATUS.new, - alterable: '0', - permissions: {permission: [{name: 'everything'}]}, - target: {_id: 'id', name: 'target'}, - usage_type: 'audit', - }); - - const handleAuditClone = testing.fn(); - const handleAuditDelete = testing.fn(); - const handleAuditDownload = testing.fn(); - const handleAuditEdit = testing.fn(); - const handleAuditResume = testing.fn(); - const handleAuditStart = testing.fn(); - const handleAuditStop = testing.fn(); - const handleReportDownload = testing.fn(); - const handleToggleDetailsClick = testing.fn(); - - const {render, store} = rendererWith({ - gmp, - capabilities: caps, - store: true, - router: true, - }); - - store.dispatch(setTimezone('CET')); - store.dispatch(setUsername('username')); - - const {baseElement, getAllByTestId, queryAllByTestId} = render( - , - ); - - // Name - const spans = baseElement.querySelectorAll('span'); - fireEvent.click(spans[0]); - expect(handleToggleDetailsClick).toHaveBeenCalledWith(undefined, '314'); - - // Status - const bars = getAllByTestId('progressbar-box'); - - expect(bars[0]).toHaveAttribute('title', AUDIT_STATUS.new); - expect(bars[0]).toHaveTextContent(AUDIT_STATUS.new); - - const detailsLinks = queryAllByTestId('details-link'); - expect(detailsLinks.length).toBe(0); - // because there are no reports yet - - // Compliance Status - expect(bars.length).toBe(1); - // because there is no compliance status bar yet - - // Actions - const icons = getAllByTestId('svg-icon'); - - fireEvent.click(icons[0]); - expect(handleAuditStart).toHaveBeenCalledWith(audit); - expect(icons[0]).toHaveAttribute('title', 'Start'); - - fireEvent.click(icons[1]); - expect(handleAuditResume).not.toHaveBeenCalled(); - expect(icons[1]).toHaveAttribute('title', 'Audit is not stopped'); - - fireEvent.click(icons[2]); - expect(handleAuditDelete).toHaveBeenCalledWith(audit); - expect(icons[2]).toHaveAttribute('title', 'Move Audit to trashcan'); - - fireEvent.click(icons[3]); - expect(handleAuditEdit).toHaveBeenCalledWith(audit); - expect(icons[3]).toHaveAttribute('title', 'Edit Audit'); - - fireEvent.click(icons[4]); - expect(handleAuditClone).toHaveBeenCalledWith(audit); - expect(icons[4]).toHaveAttribute('title', 'Clone Audit'); - - fireEvent.click(icons[5]); - expect(handleAuditDownload).toHaveBeenCalledWith(audit); - expect(icons[5]).toHaveAttribute('title', 'Export Audit'); - - fireEvent.click(icons[6]); - expect(handleReportDownload).not.toHaveBeenCalled(); - expect(icons[6]).toHaveAttribute('title', 'Report download not available'); - }); - - test('should call click handlers for running audit', () => { - const audit = Audit.fromElement({ - _id: '314', - owner: {name: 'username'}, - name: 'foo', - comment: 'bar', - in_use: true, - status: AUDIT_STATUS.running, - alterable: '0', - current_report: currentReport, - permissions: {permission: [{name: 'everything'}]}, - target: {_id: 'id', name: 'target'}, - usage_type: 'audit', - }); - - const handleAuditClone = testing.fn(); - const handleAuditDelete = testing.fn(); - const handleAuditDownload = testing.fn(); - const handleAuditEdit = testing.fn(); - const handleAuditResume = testing.fn(); - const handleAuditStart = testing.fn(); - const handleAuditStop = testing.fn(); - const handleReportDownload = testing.fn(); - const handleToggleDetailsClick = testing.fn(); - - const {render, store} = rendererWith({ - gmp, - capabilities: caps, - store: true, - router: true, - }); - - store.dispatch(setTimezone('CET')); - store.dispatch(setUsername('username')); - - const {baseElement, getAllByTestId} = render( - , - ); - - // Name - const spans = baseElement.querySelectorAll('span'); - fireEvent.click(spans[0]); - expect(handleToggleDetailsClick).toHaveBeenCalledWith(undefined, '314'); - - // Status - const bars = getAllByTestId('progressbar-box'); - - expect(bars[0]).toHaveAttribute('title', AUDIT_STATUS.running); - expect(bars[0]).toHaveTextContent('0 %'); - - const detailsLinks = getAllByTestId('details-link'); - - expect(detailsLinks[0]).toHaveTextContent('0 %'); - expect(detailsLinks[0]).toHaveAttribute('href', '/report/5678'); - - // Report - expect(detailsLinks.length).toBe(1); - // because there is no last report yet - - // Compliance Status - expect(bars.length).toBe(1); - // because there is no compliance status bar yet - - // Actions - const icons = getActionItems(); - - fireEvent.click(icons[0]); - expect(handleAuditStart).not.toHaveBeenCalled(); - expect(icons[0]).toHaveAttribute('title', 'Stop'); - - fireEvent.click(icons[1]); - expect(handleAuditResume).not.toHaveBeenCalled(); - expect(icons[1]).toHaveAttribute('title', 'Audit is not stopped'); - - fireEvent.click(icons[2]); - expect(handleAuditDelete).not.toHaveBeenCalled(); - expect(icons[2]).toHaveAttribute('title', 'Audit is still in use'); - - fireEvent.click(icons[3]); - expect(handleAuditEdit).toHaveBeenCalledWith(audit); - expect(icons[3]).toHaveAttribute('title', 'Edit Audit'); - - fireEvent.click(icons[4]); - expect(handleAuditClone).toHaveBeenCalledWith(audit); - expect(icons[4]).toHaveAttribute('title', 'Clone Audit'); - - fireEvent.click(icons[5]); - expect(handleAuditDownload).toHaveBeenCalledWith(audit); - expect(icons[5]).toHaveAttribute('title', 'Export Audit'); - - fireEvent.click(icons[6]); - expect(handleReportDownload).not.toHaveBeenCalled(); - expect(icons[6]).toHaveAttribute('title', 'Report download not available'); - }); - - test('should call click handlers for stopped audit', () => { - const audit = Audit.fromElement({ - _id: '314', - owner: {name: 'username'}, - name: 'foo', - comment: 'bar', - status: AUDIT_STATUS.stopped, - alterable: '0', - current_report: currentReport, - last_report: lastReport, - permissions: {permission: [{name: 'everything'}]}, - target: {_id: 'id', name: 'target'}, - usage_type: 'audit', - }); - - const handleAuditClone = testing.fn(); - const handleAuditDelete = testing.fn(); - const handleAuditDownload = testing.fn(); - const handleAuditEdit = testing.fn(); - const handleAuditResume = testing.fn(); - const handleAuditStart = testing.fn(); - const handleAuditStop = testing.fn(); - const handleReportDownload = testing.fn(); - const handleToggleDetailsClick = testing.fn(); - - const {render, store} = rendererWith({ - gmp, - capabilities: caps, - store: true, - router: true, - }); - - store.dispatch(setTimezone('CET')); - store.dispatch(setUsername('username')); - - const {baseElement, getAllByTestId} = render( - , - ); - - // Name - const spans = baseElement.querySelectorAll('span'); - fireEvent.click(spans[0]); - expect(handleToggleDetailsClick).toHaveBeenCalledWith(undefined, '314'); - - // Status - const bars = getAllByTestId('progressbar-box'); - - expect(bars[0]).toHaveAttribute('title', AUDIT_STATUS.stopped); - expect(bars[0]).toHaveTextContent(AUDIT_STATUS.stopped); - - const detailsLinks = getAllByTestId('details-link'); - - expect(detailsLinks[0]).toHaveTextContent('Stopped'); - expect(detailsLinks[0]).toHaveAttribute('href', '/report/5678'); - - // Report - expect(detailsLinks[1]).toHaveTextContent('Wed, Jul 10, 2019 2:51 PM CEST'); - expect(detailsLinks[1]).toHaveAttribute('href', '/report/1234'); - - // Compliance Status - expect(bars[1]).toHaveAttribute('title', '50%'); - expect(bars[1]).toHaveTextContent('50%'); - - // Actions - const icons = getActionItems(); - - fireEvent.click(icons[0]); - expect(handleAuditStart).toHaveBeenCalledWith(audit); - expect(icons[0]).toHaveAttribute('title', 'Start'); - - fireEvent.click(icons[1]); - expect(handleAuditResume).toHaveBeenCalledWith(audit); - expect(icons[1]).toHaveAttribute('title', 'Resume'); - - fireEvent.click(icons[2]); - expect(handleAuditDelete).toHaveBeenCalledWith(audit); - expect(icons[2]).toHaveAttribute('title', 'Move Audit to trashcan'); - - fireEvent.click(icons[3]); - expect(handleAuditEdit).toHaveBeenCalledWith(audit); - expect(icons[3]).toHaveAttribute('title', 'Edit Audit'); - - fireEvent.click(icons[4]); - expect(handleAuditClone).toHaveBeenCalledWith(audit); - expect(icons[4]).toHaveAttribute('title', 'Clone Audit'); - - fireEvent.click(icons[5]); - expect(handleAuditDownload).toHaveBeenCalledWith(audit); - expect(icons[5]).toHaveAttribute('title', 'Export Audit'); - - fireEvent.click(icons[6]); - expect(handleReportDownload).toHaveBeenCalledWith(audit); - expect(icons[6]).toHaveAttribute( - 'title', - 'Download Greenbone Compliance Report', - ); - }); - - test('should call click handlers for finished audit', () => { - const audit = Audit.fromElement({ - _id: '314', - owner: {name: 'username'}, - name: 'foo', - comment: 'bar', - status: AUDIT_STATUS.done, - alterable: '0', - last_report: lastReport, - permissions: {permission: [{name: 'everything'}]}, - target: {_id: 'id', name: 'target'}, - usage_type: 'audit', - }); - - const handleAuditClone = testing.fn(); - const handleAuditDelete = testing.fn(); - const handleAuditDownload = testing.fn(); - const handleAuditEdit = testing.fn(); - const handleAuditResume = testing.fn(); - const handleAuditStart = testing.fn(); - const handleAuditStop = testing.fn(); - const handleReportDownload = testing.fn(); - const handleToggleDetailsClick = testing.fn(); - - const {render, store} = rendererWith({ - gmp, - capabilities: caps, - store: true, - router: true, - }); - - store.dispatch(setTimezone('CET')); - store.dispatch(setUsername('username')); - - const {baseElement, getAllByTestId} = render( - , - ); - - // Name - const spans = baseElement.querySelectorAll('span'); - fireEvent.click(spans[0]); - expect(handleToggleDetailsClick).toHaveBeenCalledWith(undefined, '314'); - - // Status - const bars = getAllByTestId('progressbar-box'); - - expect(bars[0]).toHaveAttribute('title', AUDIT_STATUS.done); - expect(bars[0]).toHaveTextContent(AUDIT_STATUS.done); - - const detailsLinks = getAllByTestId('details-link'); - - expect(detailsLinks[0]).toHaveTextContent('Done'); - expect(detailsLinks[0]).toHaveAttribute('href', '/report/1234'); - - // Report - expect(detailsLinks[1]).toHaveTextContent('Wed, Jul 10, 2019 2:51 PM CEST'); - expect(detailsLinks[1]).toHaveAttribute('href', '/report/1234'); - - // Compliance Status - expect(bars[1]).toHaveAttribute('title', '50%'); - expect(bars[1]).toHaveTextContent('50%'); - - // Actions - const icons = getActionItems(); - - fireEvent.click(icons[0]); - expect(handleAuditStart).toHaveBeenCalledWith(audit); - expect(icons[0]).toHaveAttribute('title', 'Start'); - - fireEvent.click(icons[1]); - expect(handleAuditResume).not.toHaveBeenCalled(); - expect(icons[1]).toHaveAttribute('title', 'Audit is not stopped'); - - fireEvent.click(icons[2]); - expect(handleAuditDelete).toHaveBeenCalledWith(audit); - expect(icons[2]).toHaveAttribute('title', 'Move Audit to trashcan'); - - fireEvent.click(icons[3]); - expect(handleAuditEdit).toHaveBeenCalledWith(audit); - expect(icons[3]).toHaveAttribute('title', 'Edit Audit'); - - fireEvent.click(icons[4]); - expect(handleAuditClone).toHaveBeenCalledWith(audit); - expect(icons[4]).toHaveAttribute('title', 'Clone Audit'); - - fireEvent.click(icons[5]); - expect(handleAuditDownload).toHaveBeenCalledWith(audit); - expect(icons[5]).toHaveAttribute('title', 'Export Audit'); - - fireEvent.click(icons[6]); - expect(handleReportDownload).toHaveBeenCalledWith(audit); - expect(icons[6]).toHaveAttribute( - 'title', - 'Download Greenbone Compliance Report', - ); - }); - - test('should not call click handlers for audit without permission', () => { - const audit = Audit.fromElement({ - _id: '314', - owner: {name: 'user'}, - name: 'foo', - comment: 'bar', - status: AUDIT_STATUS.done, - alterable: '0', - last_report: lastReport, - permissions: {permission: [{name: 'get_tasks'}]}, - target: {_id: 'id', name: 'target'}, - usage_type: 'audit', - }); - - const handleAuditClone = testing.fn(); - const handleAuditDelete = testing.fn(); - const handleAuditDownload = testing.fn(); - const handleAuditEdit = testing.fn(); - const handleAuditResume = testing.fn(); - const handleAuditStart = testing.fn(); - const handleAuditStop = testing.fn(); - const handleReportDownload = testing.fn(); - const handleToggleDetailsClick = testing.fn(); - - const {render, store} = rendererWith({ - gmp, - capabilities: caps, - store: true, - router: true, - }); - - store.dispatch(setTimezone('CET')); - store.dispatch(setUsername('username')); - - const {baseElement, getAllByTestId} = render( - , - ); - - // Name - const spans = baseElement.querySelectorAll('span'); - fireEvent.click(spans[0]); - expect(handleToggleDetailsClick).toHaveBeenCalledWith(undefined, '314'); - - const icons = getActionItems(); - expect(icons[0]).toHaveAttribute('title', 'Audit owned by user'); - - // Status - const bars = getAllByTestId('progressbar-box'); - - expect(bars[0]).toHaveAttribute('title', AUDIT_STATUS.done); - expect(bars[0]).toHaveTextContent(AUDIT_STATUS.done); - - const detailsLinks = getAllByTestId('details-link'); - - expect(detailsLinks[0]).toHaveTextContent('Done'); - expect(detailsLinks[0]).toHaveAttribute('href', '/report/1234'); - - // Report - expect(detailsLinks[1]).toHaveTextContent('Wed, Jul 10, 2019 2:51 PM CEST'); - expect(detailsLinks[1]).toHaveAttribute('href', '/report/1234'); - - // Compliance Status - expect(bars[1]).toHaveAttribute('title', '50%'); - expect(bars[1]).toHaveTextContent('50%'); - - // Actions - fireEvent.click(icons[1]); - expect(handleAuditStart).not.toHaveBeenCalled(); - expect(icons[1]).toHaveAttribute( - 'title', - 'Permission to start audit denied', - ); - - fireEvent.click(icons[2]); - expect(handleAuditResume).not.toHaveBeenCalled(); - expect(icons[2]).toHaveAttribute('title', 'Audit is not stopped'); - - fireEvent.click(icons[3]); - expect(handleAuditDelete).not.toHaveBeenCalled(); - expect(icons[3]).toHaveAttribute( - 'title', - 'Permission to move Audit to trashcan denied', - ); - - fireEvent.click(icons[4]); - expect(handleAuditEdit).not.toHaveBeenCalled(); - expect(icons[4]).toHaveAttribute( - 'title', - 'Permission to edit Audit denied', - ); - - fireEvent.click(icons[5]); - expect(handleAuditClone).toHaveBeenCalledWith(audit); - expect(icons[5]).toHaveAttribute('title', 'Clone Audit'); - - fireEvent.click(icons[6]); - expect(handleAuditDownload).toHaveBeenCalledWith(audit); - expect(icons[6]).toHaveAttribute('title', 'Export Audit'); - - fireEvent.click(icons[7]); - expect(handleReportDownload).toHaveBeenCalledWith(audit); - expect(icons[7]).toHaveAttribute( - 'title', - 'Download Greenbone Compliance Report', - ); - }); - - console.warn = consoleError; -}); - -describe('Audit Row tests - compliance reports enabled', () => { // deactivate console.error for tests // to make it possible to test a row without a table console.error = () => {}; - const featureList = [{name: 'COMPLIANCE_REPORTS', _enabled: 1}]; - const caps = new Capabilities(['everything'], featureList); + const caps = new Capabilities(['everything']); test('should render', () => { const audit = Audit.fromElement({ diff --git a/src/web/pages/audits/row.jsx b/src/web/pages/audits/row.jsx index d8f46e3b77..897e5e3602 100644 --- a/src/web/pages/audits/row.jsx +++ b/src/web/pages/audits/row.jsx @@ -36,10 +36,8 @@ import {GREENBONE_SENSOR_SCANNER_TYPE} from 'gmp/models/scanner'; import ComplianceStatusBar from 'web/components/bar/compliancestatusbar'; -import {renderReport} from 'web/pages/tasks/row'; import DateTime from 'web/components/date/datetime'; import DetailsLink from 'web/components/link/detailslink'; -import useCapabilities from 'web/hooks/useCapabilities'; const renderAuditReport = (report, links) => { if (!isDefined(report)) { @@ -86,7 +84,6 @@ const Row = ({ }) => { const {scanner, observers} = entity; const obs = []; - const caps = useCapabilities(); if (isDefined(observers)) { if (isDefined(observers.user)) { @@ -146,15 +143,12 @@ const Row = ({ - {caps.featureEnabled('COMPLIANCE_REPORTS') - ? renderAuditReport(entity.last_report, links) - : renderReport(entity.last_report, links) - } + {renderAuditReport(entity.last_report, links)} {isDefined(entity.last_report) && ( diff --git a/src/web/pages/filters/component.jsx b/src/web/pages/filters/component.jsx index 1330c349c4..94d5cb20b8 100644 --- a/src/web/pages/filters/component.jsx +++ b/src/web/pages/filters/component.jsx @@ -20,6 +20,7 @@ import FilterDialog from 'web/pages/filters/dialog'; const FILTER_OPTIONS = [ ['alert', _l('Alert')], + ['audit_report', _l('Audit Report')], ['credential', _l('Credential')], ['filter', _l('Filter')], ['group', _l('Group')], @@ -75,13 +76,7 @@ class FilterComponent extends React.Component { openFilterDialog(filter) { const {capabilities} = this.props; - const filterOptions = [ - ...(capabilities.featureEnabled('COMPLIANCE_REPORTS') - ? [['audit_report', _l('Audit Report')]] - : []), - ...FILTER_OPTIONS - ]; - let types = filterOptions.filter(option => + let types = FILTER_OPTIONS.filter(option => filter_types(capabilities, option[0]), ); diff --git a/src/web/pages/start/dashboard.jsx b/src/web/pages/start/dashboard.jsx index 62b1ff4f03..71c09e9f28 100644 --- a/src/web/pages/start/dashboard.jsx +++ b/src/web/pages/start/dashboard.jsx @@ -29,7 +29,6 @@ import {DFNCERT_DISPLAYS} from '../dfncert/dashboard'; import {TICKETS_DISPLAYS} from '../tickets/dashboard'; import {AUDIT_REPORTS_DISPLAYS} from '../reports/auditdashboard'; import {DEFAULT_DISPLAYS} from './newdashboarddialog'; -import useCapabilities from 'web/hooks/useCapabilities'; const ALL_DISPLAYS = [ ...TASKS_DISPLAYS, @@ -46,6 +45,7 @@ const ALL_DISPLAYS = [ ...CPES_DISPLAYS, ...DFNCERT_DISPLAYS, ...TICKETS_DISPLAYS, + ...AUDIT_REPORTS_DISPLAYS, ]; const StartDashboard = ({ @@ -58,13 +58,6 @@ const StartDashboard = ({ onResetDashboard, ...props }) => { - const caps = useCapabilities(); - const displayIds = [ - ...ALL_DISPLAYS, - ...(caps.featureEnabled('COMPLIANCE_REPORTS') - ? AUDIT_REPORTS_DISPLAYS - : []) - ]; return ( @@ -72,7 +65,7 @@ const StartDashboard = ({ settings={settings} canAdd={canAddDisplay(props)} dashboardId={id} - displayIds={displayIds} + displayIds={ALL_DISPLAYS} onInteraction={onInteraction} onNewDisplay={onNewDisplay} onResetClick={onResetDashboard} @@ -86,7 +79,7 @@ const StartDashboard = ({ showFilterSelection showFilterString defaultDisplays={DEFAULT_DISPLAYS} - permittedDisplays={displayIds} + permittedDisplays={ALL_DISPLAYS} loadSettings={loadSettings} saveSettings={saveSettings} onInteraction={onInteraction} diff --git a/src/web/pages/tags/component.jsx b/src/web/pages/tags/component.jsx index fa868aaa99..714ab2c5f3 100644 --- a/src/web/pages/tags/component.jsx +++ b/src/web/pages/tags/component.jsx @@ -30,6 +30,7 @@ export const MAX_RESOURCES = 40; // concerns listing in "Assigned Resources" tab const TYPES = [ 'alert', 'audit', + 'auditreport', 'host', 'operatingsystem', 'cpe', @@ -108,13 +109,7 @@ class TagComponent extends React.Component { getResourceTypes() { const {capabilities} = this.props; - const types = [ - ...TYPES, - ...(capabilities.featureEnabled('COMPLIANCE_REPORTS') - ? ['auditreport'] - : []) - ].sort(); - return types.map(type => + return TYPES.map(type => capabilities.mayAccess(type) ? [type, typeName(type)] : undefined, ).filter(isDefined); } diff --git a/src/web/pages/usersettings/filterpart.jsx b/src/web/pages/usersettings/filterpart.jsx index 61dd3d4513..2d7cc66a58 100644 --- a/src/web/pages/usersettings/filterpart.jsx +++ b/src/web/pages/usersettings/filterpart.jsx @@ -12,7 +12,6 @@ import PropTypes from 'web/utils/proptypes'; import {renderSelectItems, UNSET_VALUE} from 'web/utils/render'; import useTranslation from 'web/hooks/useTranslation'; -import useCapabilities from 'web/hooks/useCapabilities'; const filterFilters = (filters, type) => filters.filter(filter => filter.filter_type === type); @@ -52,7 +51,6 @@ const FilterPart = ({ onChange, }) => { const [_] = useTranslation(); - const caps = useCapabilities(); return ( @@ -66,19 +64,18 @@ const FilterPart = ({ onChange={onChange} /> - {caps.featureEnabled('COMPLIANCE_REPORTS') && ( - - - )} + )