diff --git a/public/locales/gsa-de.json b/public/locales/gsa-de.json index 594d03e783..bf0b41a9d2 100644 --- a/public/locales/gsa-de.json +++ b/public/locales/gsa-de.json @@ -450,6 +450,7 @@ "Deny all": "Alle verweigern", "Deny all and allow": "Verweigere alle und erlaube", "Deny all and allow from {{addresses}}": "Alle verweigern und von {{addresses}} erlauben", + "Deprecated": "Veraltet", "Deprecated By": "Veraltet ab", "Descending": "Absteigend", "Description": "Beschreibung", @@ -1922,4 +1923,4 @@ "{{usageType}} is not stopped": "{{usageType}} ist nicht gestoppt", "{{usageType}} is scheduled": "{{usageType}} ist durch Zeitplan gesteuert", "{{value}}: {{count}} (severity: {{severity}})": "{{value}}: {{count}} (Schweregrad: {{severity}})" -} \ No newline at end of file +} diff --git a/src/web/entities/entitynametabledata.js b/src/web/entities/entitynametabledata.js index 127e183316..afec3896a7 100644 --- a/src/web/entities/entitynametabledata.js +++ b/src/web/entities/entitynametabledata.js @@ -55,12 +55,14 @@ const EntityNameTableData = ({ {entity.name} + {entity.deprecated && ({_('Deprecated')})} ) : ( {entity.name} + {entity.deprecated && ({_('Deprecated')})} )} diff --git a/src/web/pages/portlists/details.js b/src/web/pages/portlists/details.js index 0788046ff6..ac77ac53b1 100644 --- a/src/web/pages/portlists/details.js +++ b/src/web/pages/portlists/details.js @@ -35,6 +35,7 @@ import {Col} from 'web/entity/page'; const PortListDetails = ({entity, ...props}) => { const { comment, + deprecated, port_count = { all: 0, tcp: 0, @@ -50,6 +51,13 @@ const PortListDetails = ({entity, ...props}) => { + {deprecated && ( + + {_('Deprecated')} + {_('yes')} + + )} + {_('Comment')} {comment} diff --git a/src/web/pages/reportformats/details.js b/src/web/pages/reportformats/details.js index b6ccf39408..9ce4b7546e 100644 --- a/src/web/pages/reportformats/details.js +++ b/src/web/pages/reportformats/details.js @@ -40,6 +40,7 @@ import {Col} from 'web/entity/page'; const ReportFormatDetails = ({entity, links = true}) => { const { + deprecated, extension, content_type, trust = {}, @@ -55,6 +56,13 @@ const ReportFormatDetails = ({entity, links = true}) => { + {deprecated && ( + + {_('Deprecated')} + {_('yes')} + + )} + {_('Extension')} {extension} diff --git a/src/web/pages/scanconfigs/__tests__/details.js b/src/web/pages/scanconfigs/__tests__/details.js index 1322548316..b69f6049c2 100644 --- a/src/web/pages/scanconfigs/__tests__/details.js +++ b/src/web/pages/scanconfigs/__tests__/details.js @@ -59,4 +59,25 @@ describe('Scan Config Details tests', () => { expect(element).not.toHaveTextContent('scanner'); }); + + test('should mark deprecated', () => { + const config = ScanConfig.fromElement({ + name: 'foo', + comment: 'bar', + deprecated: '1', + scanner: {name: 'scanner1', id: '42', type: OPENVAS_SCANNER_TYPE}, + tasks: { + task: [ + {id: '1234', name: 'task1'}, + {id: '5678', name: 'task2'}, + ], + }, + }); + const caps = new Capabilities(['everything']); + + const {render} = rendererWith({capabilities: caps, router: true}); + + const {element} = render(
); + expect(element).toHaveTextContent('Deprecatedyes'); + }); }); diff --git a/src/web/pages/scanconfigs/__tests__/row.js b/src/web/pages/scanconfigs/__tests__/row.js index 2b70ab8611..5c9398d1ce 100644 --- a/src/web/pages/scanconfigs/__tests__/row.js +++ b/src/web/pages/scanconfigs/__tests__/row.js @@ -97,6 +97,54 @@ describe('Scan Config row tests', () => { ); }); + test('should mark deprecated config', () => { + const config = ScanConfig.fromElement({ + _id: '1234', + name: 'foo', + comment: 'bar', + in_use: '0', + writable: '1', + deprecated: '1', + owner: { + name: 'user', + }, + permissions: {permission: [{name: 'everything'}]}, + family_count: { + __text: 2, + growing: SCANCONFIG_TREND_STATIC, + }, + nvt_count: { + __text: 4, + growing: SCANCONFIG_TREND_DYNAMIC, + }, + }); + + const handleToggleDetailsClick = jest.fn(); + const handleScanConfigClone = jest.fn(); + const handleScanConfigDelete = jest.fn(); + const handleScanConfigDownload = jest.fn(); + const handleScanConfigEdit = jest.fn(); + + const {render} = rendererWith({ + gmp, + capabilities: caps, + store: true, + }); + + const {baseElement, getAllByTestId} = render( + , + ); + + expect(baseElement).toHaveTextContent('(Deprecated)'); + }); + test('should render observer icon', () => { const config = ScanConfig.fromElement({ _id: '1234', diff --git a/src/web/pages/scanconfigs/details.js b/src/web/pages/scanconfigs/details.js index 14fc7b858a..7dc1b22cbe 100644 --- a/src/web/pages/scanconfigs/details.js +++ b/src/web/pages/scanconfigs/details.js @@ -36,7 +36,7 @@ import TableRow from 'web/components/table/row'; import {Col} from 'web/entity/page'; const ScanConfigDetails = ({entity}) => { - const {comment, tasks = []} = entity; + const {comment, deprecated, tasks = []} = entity; return ( @@ -45,6 +45,12 @@ const ScanConfigDetails = ({entity}) => { + {deprecated && ( + + {_('Deprecated')} + {_('yes')} + + )} {isDefined(comment) && ( {_('Comment')} diff --git a/src/web/utils/__tests__/render.js b/src/web/utils/__tests__/render.js index 243eae7e1a..3e5d411a15 100644 --- a/src/web/utils/__tests__/render.js +++ b/src/web/utils/__tests__/render.js @@ -37,6 +37,31 @@ describe('render_select_items test', () => { expect(items[1]).toEqual({label: 'B Task', value: '2'}); }); + test('should mark deprecated items', () => { + const entities = [ + { + name: 'A Config', + id: '1', + }, + { + name: 'B Config', + deprecated: '1', + id: '2', + }, + { + name: 'C Config', + id: '3', + }, + ]; + + const items = renderSelectItems(entities); + + expect(items.length).toBe(3); + expect(items[0]).toEqual({label: 'A Config', value: '1'}); + expect(items[1]).toEqual({label: B Config (Deprecated), value: '2'}); + expect(items[2]).toEqual({label: 'C Config', value: '3'}); + }); + test('should add default item', () => { const entities = [ { diff --git a/src/web/utils/render.js b/src/web/utils/render.js index 6c71445312..2a4490572e 100644 --- a/src/web/utils/render.js +++ b/src/web/utils/render.js @@ -30,6 +30,13 @@ import {typeName, getEntityType} from 'gmp/utils/entitytype'; export const UNSET_VALUE = '0'; export const UNSET_LABEL = '--'; +function selectItemLabel(item) { + if (item.deprecated) { + return {item.name + ' (' + _('Deprecated') + ')'}; + } + return item.name; +} + /** * Render a entities list as items array * @@ -45,7 +52,7 @@ export const renderSelectItems = ( default_item_label = UNSET_LABEL, ) => { const items = isDefined(list) - ? list.map(item => ({label: item.name, value: item.id})) + ? list.map(item => ({label: selectItemLabel(item), value: item.id})) : undefined; if (!isDefined(default_item_value)) {