From 90ead61461092a47bd5dadceef1429378d03cf35 Mon Sep 17 00:00:00 2001 From: Ahmed Abdelsalam Date: Thu, 27 Jun 2024 16:06:56 +0200 Subject: [PATCH] Fix: Allow applying report configs to delta reports. --- src/web/pages/reports/deltadetailspage.jsx | 30 +++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/src/web/pages/reports/deltadetailspage.jsx b/src/web/pages/reports/deltadetailspage.jsx index e37ac172aa..1f2137ca61 100644 --- a/src/web/pages/reports/deltadetailspage.jsx +++ b/src/web/pages/reports/deltadetailspage.jsx @@ -12,7 +12,10 @@ import _ from 'gmp/locale'; import logger from 'gmp/log'; -import Filter, {RESET_FILTER, RESULTS_FILTER_FILTER} from 'gmp/models/filter'; +import Filter, { + ALL_FILTER, + RESET_FILTER, + RESULTS_FILTER_FILTER} from 'gmp/models/filter'; import {isActive} from 'gmp/models/task'; import {first} from 'gmp/utils/array'; @@ -34,6 +37,11 @@ import { selector as filterSelector, } from 'web/store/entities/filters'; +import { + loadAllEntities as loadReportConfigs, + selector as reportConfigsSelector, +} from 'web/store/entities/reportconfigs'; + import { loadAllEntities as loadReportFormats, selector as reportFormatsSelector, @@ -168,6 +176,7 @@ class DeltaReportDetails extends React.Component { componentDidMount() { this.props.loadSettings(); this.props.loadFilters(); + this.props.loadReportConfigs(); this.props.loadReportFormats(); this.props.loadReportComposerDefaults(); } @@ -307,8 +316,13 @@ class DeltaReportDetails extends React.Component { username, onDownload, } = this.props; - const {includeNotes, includeOverrides, reportFormatId, storeAsDefault} = - state; + const { + includeNotes, + includeOverrides, + reportConfigId, + reportFormatId, + storeAsDefault + } = state; const newFilter = reportFilter.copy(); newFilter.set('notes', includeNotes); @@ -317,6 +331,7 @@ class DeltaReportDetails extends React.Component { if (storeAsDefault) { const defaults = { ...reportComposerDefaults, + defaultReportConfigId: reportConfigId, defaultReportFormatId: reportFormatId, includeNotes, includeOverrides, @@ -336,6 +351,7 @@ class DeltaReportDetails extends React.Component { return gmp.report .download(entity, { + reportConfigId, reportFormatId, deltaReportId, filter: newFilter, @@ -457,6 +473,7 @@ class DeltaReportDetails extends React.Component { isLoading, reportFilter, reportFormats, + reportConfigs, reportId, onInteraction, reportComposerDefaults, @@ -530,11 +547,13 @@ class DeltaReportDetails extends React.Component { )} {showDownloadReportDialog && ( { loadFilters: () => dispatch(loadFilters(gmp)(RESULTS_FILTER_FILTER)), loadSettings: () => dispatch(loadUserSettingDefaults(gmp)()), loadTarget: targetId => gmp.target.get({id: targetId}), + loadReportConfigs: () => dispatch(loadReportConfigs(gmp)(ALL_FILTER)), loadReportFormats: () => dispatch(loadReportFormats(gmp)(REPORT_FORMATS_FILTER)), loadReport: (id, deltaId, filter) => @@ -605,6 +627,7 @@ const mapStateToProps = (rootState, {match}) => { const filterSel = filterSelector(rootState); const deltaSel = deltaReportSelector(rootState); const reportFormatsSel = reportFormatsSelector(rootState); + const reportConfigsSel = reportConfigsSelector(rootState); const userDefaultsSelector = getUserSettingsDefaults(rootState); const userDefaultFilterSel = getUserSettingsDefaultFilter( rootState, @@ -624,6 +647,7 @@ const mapStateToProps = (rootState, {match}) => { 'reportexportfilename', ), reportFilter: getFilter(entity), + reportConfigs: reportConfigsSel.getAllEntities(ALL_FILTER), reportFormats: reportFormatsSel.getAllEntities(REPORT_FORMATS_FILTER), reportId: id, reportComposerDefaults: getReportComposerDefaults(rootState),