From 8e8a002bae61b73b9044d7ee7d01633728bb3e8c Mon Sep 17 00:00:00 2001 From: Steffen Waterkamp Date: Tue, 11 Dec 2018 12:25:18 +0100 Subject: [PATCH] Save selected alert to report content composer defaults --- gsa/src/web/pages/reports/alertactions.js | 3 +++ gsa/src/web/pages/reports/triggeralertdialog.js | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/gsa/src/web/pages/reports/alertactions.js b/gsa/src/web/pages/reports/alertactions.js index 015805523d..28b28adcca 100644 --- a/gsa/src/web/pages/reports/alertactions.js +++ b/gsa/src/web/pages/reports/alertactions.js @@ -113,6 +113,7 @@ class AlertActions extends React.Component { if (storeAsDefault) { this.props.saveReportComposerDefaults({ applyOverrides, + defaultAlertId: alertId, includeNotes, includeOverrides, }); @@ -164,6 +165,7 @@ class AlertActions extends React.Component { const { alertId, applyOverrides, + defaultAlertId, includeNotes, includeOverrides, showTriggerAlertDialog, @@ -189,6 +191,7 @@ class AlertActions extends React.Component { alertId={alertId} alerts={alerts} applyOverrides={applyOverrides} + defaultAlertId={defaultAlertId} filter={filter} includeNotes={includeNotes} includeOverrides={includeOverrides} diff --git a/gsa/src/web/pages/reports/triggeralertdialog.js b/gsa/src/web/pages/reports/triggeralertdialog.js index fa4dc9d34a..4eae103ac9 100644 --- a/gsa/src/web/pages/reports/triggeralertdialog.js +++ b/gsa/src/web/pages/reports/triggeralertdialog.js @@ -26,6 +26,7 @@ import _ from 'gmp/locale'; import {NO_VALUE, YES_VALUE} from 'gmp/parser'; import {first} from 'gmp/utils/array'; +import {selectSaveId} from 'gmp/utils/id'; import {isDefined, isString} from 'gmp/utils/identity'; import PropTypes from 'web/utils/proptypes'; import {renderSelectItems} from 'web/utils/render'; @@ -50,6 +51,7 @@ const TriggerAlertDialog = ({ alertId, alerts = [], applyOverrides = COMPOSER_CONTENT_DEFAULTS.applyOverrides, + defaultAlertId, filter = {}, includeNotes = COMPOSER_CONTENT_DEFAULTS.includeNotes, includeOverrides = COMPOSER_CONTENT_DEFAULTS.includeOverrides, @@ -64,6 +66,10 @@ const TriggerAlertDialog = ({ const filterString = isString(filter) ? filter : filter.toFilterCriteriaString(); + if (isDefined(defaultAlertId)) { + alertId = selectSaveId(alerts, defaultAlertId); + }; + const unControlledValues = { applyOverrides, includeNotes,