Skip to content

Commit

Permalink
Fix: Allow applying report configs to delta reports.
Browse files Browse the repository at this point in the history
  • Loading branch information
a-h-abdelsalam committed Jun 27, 2024
1 parent b6d060c commit 90ead61
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions src/web/pages/reports/deltadetailspage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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,
Expand Down Expand Up @@ -168,6 +176,7 @@ class DeltaReportDetails extends React.Component {
componentDidMount() {
this.props.loadSettings();
this.props.loadFilters();
this.props.loadReportConfigs();

Check warning on line 179 in src/web/pages/reports/deltadetailspage.jsx

View check run for this annotation

Codecov / codecov/patch

src/web/pages/reports/deltadetailspage.jsx#L179

Added line #L179 was not covered by tests
this.props.loadReportFormats();
this.props.loadReportComposerDefaults();
}
Expand Down Expand Up @@ -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;

Check warning on line 325 in src/web/pages/reports/deltadetailspage.jsx

View check run for this annotation

Codecov / codecov/patch

src/web/pages/reports/deltadetailspage.jsx#L319-L325

Added lines #L319 - L325 were not covered by tests

const newFilter = reportFilter.copy();
newFilter.set('notes', includeNotes);
Expand All @@ -317,6 +331,7 @@ class DeltaReportDetails extends React.Component {
if (storeAsDefault) {
const defaults = {
...reportComposerDefaults,
defaultReportConfigId: reportConfigId,

Check warning on line 334 in src/web/pages/reports/deltadetailspage.jsx

View check run for this annotation

Codecov / codecov/patch

src/web/pages/reports/deltadetailspage.jsx#L334

Added line #L334 was not covered by tests
defaultReportFormatId: reportFormatId,
includeNotes,
includeOverrides,
Expand All @@ -336,6 +351,7 @@ class DeltaReportDetails extends React.Component {

return gmp.report
.download(entity, {
reportConfigId,

Check warning on line 354 in src/web/pages/reports/deltadetailspage.jsx

View check run for this annotation

Codecov / codecov/patch

src/web/pages/reports/deltadetailspage.jsx#L354

Added line #L354 was not covered by tests
reportFormatId,
deltaReportId,
filter: newFilter,
Expand Down Expand Up @@ -457,6 +473,7 @@ class DeltaReportDetails extends React.Component {
isLoading,
reportFilter,
reportFormats,
reportConfigs,

Check warning on line 476 in src/web/pages/reports/deltadetailspage.jsx

View check run for this annotation

Codecov / codecov/patch

src/web/pages/reports/deltadetailspage.jsx#L476

Added line #L476 was not covered by tests
reportId,
onInteraction,
reportComposerDefaults,
Expand Down Expand Up @@ -530,11 +547,13 @@ class DeltaReportDetails extends React.Component {
)}
{showDownloadReportDialog && (
<DownloadReportDialog
defaultReportConfigId={reportComposerDefaults.defaultReportConfigId}

Check warning on line 550 in src/web/pages/reports/deltadetailspage.jsx

View check run for this annotation

Codecov / codecov/patch

src/web/pages/reports/deltadetailspage.jsx#L550

Added line #L550 was not covered by tests
defaultReportFormatId={reportComposerDefaults.defaultReportFormatId}
filter={reportFilter}
includeNotes={reportComposerDefaults.includeNotes}
includeOverrides={reportComposerDefaults.includeOverrides}
reportFormats={reportFormats}
reportConfigs={reportConfigs}

Check warning on line 556 in src/web/pages/reports/deltadetailspage.jsx

View check run for this annotation

Codecov / codecov/patch

src/web/pages/reports/deltadetailspage.jsx#L556

Added line #L556 was not covered by tests
storeAsDefault={storeAsDefault}
onClose={this.handleCloseDownloadReportDialog}
onSave={this.handleReportDownload}
Expand All @@ -556,6 +575,7 @@ DeltaReportDetails.propTypes = {
loadFilters: PropTypes.func.isRequired,
loadReport: PropTypes.func.isRequired,
loadReportComposerDefaults: PropTypes.func.isRequired,
loadReportConfigs: PropTypes.func.isRequired,
loadReportFormats: PropTypes.func.isRequired,
loadReportIfNeeded: PropTypes.func.isRequired,
loadSettings: PropTypes.func.isRequired,
Expand All @@ -567,6 +587,7 @@ DeltaReportDetails.propTypes = {
reportExportFileName: PropTypes.string,
reportFilter: PropTypes.filter,
reportFormats: PropTypes.array,
reportConfigs: PropTypes.array,
reportId: PropTypes.id,
resultDefaultFilter: PropTypes.filter,
saveReportComposerDefaults: PropTypes.func.isRequired,
Expand All @@ -585,6 +606,7 @@ const mapDispatchToProps = (dispatch, {gmp}) => {
loadFilters: () => dispatch(loadFilters(gmp)(RESULTS_FILTER_FILTER)),
loadSettings: () => dispatch(loadUserSettingDefaults(gmp)()),
loadTarget: targetId => gmp.target.get({id: targetId}),
loadReportConfigs: () => dispatch(loadReportConfigs(gmp)(ALL_FILTER)),

Check warning on line 609 in src/web/pages/reports/deltadetailspage.jsx

View check run for this annotation

Codecov / codecov/patch

src/web/pages/reports/deltadetailspage.jsx#L609

Added line #L609 was not covered by tests
loadReportFormats: () =>
dispatch(loadReportFormats(gmp)(REPORT_FORMATS_FILTER)),
loadReport: (id, deltaId, filter) =>
Expand All @@ -605,6 +627,7 @@ const mapStateToProps = (rootState, {match}) => {
const filterSel = filterSelector(rootState);
const deltaSel = deltaReportSelector(rootState);
const reportFormatsSel = reportFormatsSelector(rootState);
const reportConfigsSel = reportConfigsSelector(rootState);

Check warning on line 630 in src/web/pages/reports/deltadetailspage.jsx

View check run for this annotation

Codecov / codecov/patch

src/web/pages/reports/deltadetailspage.jsx#L630

Added line #L630 was not covered by tests
const userDefaultsSelector = getUserSettingsDefaults(rootState);
const userDefaultFilterSel = getUserSettingsDefaultFilter(
rootState,
Expand All @@ -624,6 +647,7 @@ const mapStateToProps = (rootState, {match}) => {
'reportexportfilename',
),
reportFilter: getFilter(entity),
reportConfigs: reportConfigsSel.getAllEntities(ALL_FILTER),

Check warning on line 650 in src/web/pages/reports/deltadetailspage.jsx

View check run for this annotation

Codecov / codecov/patch

src/web/pages/reports/deltadetailspage.jsx#L650

Added line #L650 was not covered by tests
reportFormats: reportFormatsSel.getAllEntities(REPORT_FORMATS_FILTER),
reportId: id,
reportComposerDefaults: getReportComposerDefaults(rootState),
Expand Down

0 comments on commit 90ead61

Please sign in to comment.