diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d925f2eee..4c71ed6237 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [Unreleased] ### Added +- Added parseTrend() function to ScanConfig model [#1583](https://github.com/greenbone/gsa/pull/1583) - Added DetailsPage and more funtionalities to TLS Certificate assets [#1578](https://github.com/greenbone/gsa/pull/1578) - Added Explicit Compliance [#1495](https://github.com/greenbone/gsa/pull/1495) - Added tasktrendgroup component for tasks filter dialog [#1511](https://github.com/greenbone/gsa/pull/1511) diff --git a/gsa/src/gmp/models/__tests__/scanconfig.js b/gsa/src/gmp/models/__tests__/scanconfig.js index 3ec14ea5f6..71621c2395 100644 --- a/gsa/src/gmp/models/__tests__/scanconfig.js +++ b/gsa/src/gmp/models/__tests__/scanconfig.js @@ -24,6 +24,7 @@ import ScanConfig, { filterEmptyScanConfig, openVasScanConfigsFilter, ospScanConfigsFilter, + SCANCONFIG_TREND_DYNAMIC, } from 'gmp/models/scanconfig'; import {testModel} from 'gmp/models/testing'; @@ -119,7 +120,7 @@ describe('ScanConfig model tests', () => { const scanConfig = new ScanConfig(elem); expect(scanConfig.families.count).toEqual(42); - expect(scanConfig.families.trend).toEqual('1'); + expect(scanConfig.families.trend).toEqual(SCANCONFIG_TREND_DYNAMIC); expect(scanConfig.family_count).toBeUndefined(); }); @@ -134,7 +135,7 @@ describe('ScanConfig model tests', () => { }; const res = { count: 42, - trend: '1', + trend: SCANCONFIG_TREND_DYNAMIC, known: 21, max: 1337, }; diff --git a/gsa/src/gmp/models/scanconfig.js b/gsa/src/gmp/models/scanconfig.js index f1d4695882..f872d45e90 100644 --- a/gsa/src/gmp/models/scanconfig.js +++ b/gsa/src/gmp/models/scanconfig.js @@ -55,6 +55,8 @@ export const openVasScanConfigsFilter = config => export const ospScanConfigsFilter = config => config.scan_config_type === OSP_SCAN_CONFIG_TYPE; +const parseTrend = parseInt; + class ScanConfig extends Model { static entityType = 'scanconfig'; @@ -85,7 +87,7 @@ class ScanConfig extends Model { if (isDefined(ret.family_count)) { families.count = parse_count(ret.family_count.__text); - families.trend = ret.family_count.growing; + families.trend = parseTrend(ret.family_count.growing); delete ret.family_count; } else { @@ -97,7 +99,7 @@ class ScanConfig extends Model { if (isDefined(ret.nvt_count)) { ret.nvts = { count: parse_count(ret.nvt_count.__text), - trend: ret.nvt_count.growing, + trend: parseTrend(ret.nvt_count.growing), }; delete ret.nvt_count;