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

feat: update the summary to display noticebox for pages based on import type
  • Loading branch information
Chisomchima committed Apr 3, 2024
1 parent 35e7df7 commit 09c2b19
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
6 changes: 5 additions & 1 deletion src/components/JobSummary/JobSummary.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,11 @@ const JobSummary = ({
<Tags jobDetails={jobDetails} task={task} />
<Divider />
{task.completed && task.summary && (
<Summary summary={task.summary} importType={task.importType} />
<Summary
summary={task.summary}
importType={task.importType}
isDryRun={jobDetails.dryRun}
/>
)}
<div className={styles.events}>
<Log events={task.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 && importType === 'TRACKER_IMPORT_JOB') {
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 09c2b19

Please sign in to comment.