Skip to content

Commit

Permalink
feat: update the summary table to display a notification instead of o…
Browse files Browse the repository at this point in the history
…f a table when isdryrun is true
  • Loading branch information
Chisomchima committed Mar 28, 2024
1 parent e6d62f2 commit 2941960
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/components/JobSummary/JobSummary.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ const JobSummary = ({
<Summary
summary={task.summary}
importType={task.importType}
dryRun={jobDetails.dryRun}
isDryRun={jobDetails.dryRun}
/>
)}
<div className={styles.events}>
Expand Down
29 changes: 25 additions & 4 deletions src/components/JobSummary/Summary/Summary.js
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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) {
Expand All @@ -18,8 +20,25 @@ const extractStats = (summary) => {
}
}

const Summary = ({ summary, importType }) => {
// gml import type object return
const Summary = ({ summary, importType, isDryRun }) => {
if (isDryRun) {
const { ignored, total } = extractStats(summary)
return (
<div data-test="job-summary-summary" className={styles.container}>
<div
className={styles.rest}
data-test="job-summary-summary-rest"
>
<NoticeBox title="Summary">
{i18n.t(
`${ignored} entities will be ignored out of ${total} entities⁠`
)}
</NoticeBox>
</div>
</div>
)
}

if (summary.typeReports) {
const overviewStats = {
...summary.stats,
Expand Down Expand Up @@ -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 (
Expand Down Expand Up @@ -87,6 +107,7 @@ const Summary = ({ summary, importType }) => {
Summary.propTypes = {
summary: PropTypes.object.isRequired,
importType: PropTypes.string,
isDryRun: PropTypes.bool,
}

export { Summary }

0 comments on commit 2941960

Please sign in to comment.