From 09c2b19df69a1164d246ed61c5e019332d3a11f5 Mon Sep 17 00:00:00 2001 From: chisom chima Date: Thu, 28 Mar 2024 17:19:00 +0100 Subject: [PATCH] feat: update the summary table to display a notification instead of of a table when isdryrun is true feat: update the summary to display noticebox for pages based on import type --- src/components/JobSummary/JobSummary.js | 6 +++- src/components/JobSummary/Summary/Summary.js | 29 +++++++++++++++++--- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/src/components/JobSummary/JobSummary.js b/src/components/JobSummary/JobSummary.js index a013b5747..3dce9d5d7 100644 --- a/src/components/JobSummary/JobSummary.js +++ b/src/components/JobSummary/JobSummary.js @@ -82,7 +82,11 @@ const JobSummary = ({ {task.completed && task.summary && ( - + )}
diff --git a/src/components/JobSummary/Summary/Summary.js b/src/components/JobSummary/Summary/Summary.js index 5fd1f48ca..61e3bd340 100644 --- a/src/components/JobSummary/Summary/Summary.js +++ b/src/components/JobSummary/Summary/Summary.js @@ -1,3 +1,5 @@ +import i18n from '@dhis2/d2-i18n' +import { NoticeBox } from '@dhis2/ui' import PropTypes from 'prop-types' import React from 'react' import { typeReportParse } from '../helper.js' @@ -6,7 +8,7 @@ import { TypeReportSummary } from '../TypeReportSummary/TypeReportSummary.js' import styles from './Summary.module.css' const extractStats = (summary) => { - if (summary.responseType == 'ImportSummaries') { + if (summary.responseType === 'ImportSummaries') { const { imported, deleted, ignored, updated, total } = summary return { imported, deleted, ignored, updated, total } } else if (summary.importCount) { @@ -18,8 +20,25 @@ const extractStats = (summary) => { } } -const Summary = ({ summary, importType }) => { - // gml import type object return +const Summary = ({ summary, importType, isDryRun }) => { + if (isDryRun && importType === 'TRACKER_IMPORT_JOB') { + const { ignored, total } = extractStats(summary) + return ( +
+
+ + {i18n.t( + `${ignored} entities will be ignored out of ${total} entitiesā ` + )} + +
+
+ ) + } + if (summary.typeReports) { const overviewStats = { ...summary.stats, @@ -56,8 +75,9 @@ const Summary = ({ summary, importType }) => { } /> ) + const allSummaries = - summary.responseType == 'ImportSummaries' && summary.importSummaries + summary.responseType === 'ImportSummaries' && summary.importSummaries ? summary.importSummaries.map((s, i) => { const importCount = extractStats(s) return ( @@ -87,6 +107,7 @@ const Summary = ({ summary, importType }) => { Summary.propTypes = { summary: PropTypes.object.isRequired, importType: PropTypes.string, + isDryRun: PropTypes.bool, } export { Summary }