Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would just put this in a variable to make the intention clearer

Suggested change
if (isDryRun && importType === 'TRACKER_IMPORT_JOB') {
const isTrackerDryRun = isDryRun && importType === 'TRACKER_IMPORT_JOB
if (isTrackerDryRun) {

and maybe add a comment for posterity:

// the new tracker endpoints don't return a full summary, so we're just showing the ignored/total

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 }