Skip to content

Commit

Permalink
feat: update the summary table to display a message in the cases of a…
Browse files Browse the repository at this point in the history
… dry run
  • Loading branch information
Chisomchima committed Mar 28, 2024
1 parent 6cd4f22 commit 310f912
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 40 deletions.
76 changes: 41 additions & 35 deletions i18n/en.pot
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ msgstr ""
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
"POT-Creation-Date: 2024-03-01T15:50:32.586Z\n"
"PO-Revision-Date: 2024-03-01T15:50:32.586Z\n"
"POT-Creation-Date: 2024-03-28T10:36:03.141Z\n"
"PO-Revision-Date: 2024-03-28T10:36:03.141Z\n"

msgid "Something went wrong when loading the current user!"
msgstr "Something went wrong when loading the current user!"
Expand Down Expand Up @@ -688,6 +688,15 @@ msgstr "Updated"
msgid "Total"
msgstr "Total"

msgid "Reports"
msgstr "Reports"

msgid "Error Code"
msgstr "Error Code"

msgid "Tracker Type"
msgstr "Tracker Type"

msgid "Indexes"
msgstr "Indexes"

Expand Down Expand Up @@ -745,8 +754,8 @@ msgstr "Org unit geometry import"
msgid "Metadata import"
msgstr "Metadata import"

msgid "TEI import"
msgstr "TEI import"
msgid "Tracked entity import"
msgstr "Tracked entity import"

msgid "Data export"
msgstr "Data export"
Expand All @@ -760,8 +769,8 @@ msgstr "Metadata dependency export"
msgid "Metadata export"
msgstr "Metadata export"

msgid "TEI export"
msgstr "TEI export"
msgid "Tracked entity export"
msgstr "Tracked entity export"

msgid "Job overview"
msgstr "Job overview"
Expand Down Expand Up @@ -1117,24 +1126,24 @@ msgstr ""
"geometry."

msgid ""
"Export event data for programs, stages and tracked entities to JSON, CSV, "
"or DXF2 format."
"Export event data for programs, stages and tracked entities to JSON or CSV "
"format."
msgstr ""
"Export event data for programs, stages and tracked entities to JSON, CSV, "
"or DXF2 format."
"Export event data for programs, stages and tracked entities to JSON or CSV "
"format."

msgid "Export events"
msgstr "Export events"

msgid ""
"Import event data for programs, stages and tracked entities to JSON, CSV, "
"or DXF2 format."
"Import event data for programs, stages and tracked entities from JSON or "
"CSV format."
msgstr ""
"Import event data for programs, stages and tracked entities to JSON, CSV, "
"or DXF2 format."
"Import event data for programs, stages and tracked entities from JSON or "
"CSV format."

msgid "Supported file types: JSON, CSV, and DXF2."
msgstr "Supported file types: JSON, CSV, and DXF2."
msgid "Supported file types: JSON and CSV."
msgstr "Supported file types: JSON and CSV."

msgid "Organisation unit geometry import"
msgstr "Organisation unit geometry import"
Expand Down Expand Up @@ -1165,8 +1174,8 @@ msgstr "Export metadata dependencies"
msgid "Export metadata"
msgstr "Export metadata"

msgid "Export tracked entity instances"
msgstr "Export tracked entity instances"
msgid "Export tracked entities"
msgstr "Export tracked entities"

msgid "Import data"
msgstr "Import data"
Expand All @@ -1183,8 +1192,8 @@ msgstr "Import GeoJSON"
msgid "Import metadata"
msgstr "Import metadata"

msgid "Import tracked entity instances"
msgstr "Import tracked entity instances"
msgid "Import tracked entities"
msgstr "Import tracked entities"

msgid "An overview of all import jobs started this session."
msgstr "An overview of all import jobs started this session."
Expand All @@ -1210,17 +1219,14 @@ msgstr ""
"Import metadata, such as data elements and organisation units, using JSON "
"or CSV format."

msgid "Supported file types: JSON and CSV."
msgstr "Supported file types: JSON and CSV."

msgid "A class key must be selected"
msgstr "A class key must be selected"

msgid "Tracked entity instances export"
msgstr "Tracked entity instances export"
msgid "Tracked entities export"
msgstr "Tracked entities export"

msgid "Export tracked entity instances in JSON, CSV, or DXF2 format."
msgstr "Export tracked entity instances in JSON, CSV, or DXF2 format."
msgid "Export tracked entities in JSON or CSV format."
msgstr "Export tracked entities in JSON or CSV format."

msgid "Program to export from"
msgstr "Program to export from"
Expand All @@ -1231,14 +1237,14 @@ msgstr "Enrollment date range"
msgid "At least one of the 'last updated' date fields must be specified"
msgstr "At least one of the 'last updated' date fields must be specified"

msgid "Tracked entity instances import"
msgstr "Tracked entity instances import"
msgid "Tracked entities import"
msgstr "Tracked entities import"

msgid "Import tracked entity instances using JSON or DXF2 format."
msgstr "Import tracked entity instances using JSON or DXF2 format."
msgid "Import tracked entities using JSON format."
msgstr "Import tracked entities using JSON format."

msgid "Supported file types: JSON and DXF2."
msgstr "Supported file types: JSON and DXF2."
msgid "Supported file types: JSON."
msgstr "Supported file types: JSON."

msgid "Job started."
msgstr "Job started."
Expand All @@ -1264,5 +1270,5 @@ msgstr "GML"
msgid "Metadata"
msgstr "Metadata"

msgid "TEI"
msgstr "TEI"
msgid "Tracked entity"
msgstr "Tracked entity"
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}
dryRun={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,12 +1,14 @@
import PropTypes from 'prop-types'
import { NoticeBox } from '@dhis2/ui'

Check failure on line 2 in src/components/JobSummary/Summary/Summary.js

View workflow job for this annotation

GitHub Actions / lint

`@dhis2/ui` import should occur before import of `prop-types`
import i18n from '@dhis2/d2-i18n'

Check failure on line 3 in src/components/JobSummary/Summary/Summary.js

View workflow job for this annotation

GitHub Actions / lint

`@dhis2/d2-i18n` import should occur before import of `prop-types`
import React from 'react'
import { typeReportParse } from '../helper.js'
import { SingleSummary } from '../SingleSummary/SingleSummary.js'
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, dryRun }) => {
if (dryRun) {
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 ⁠`

Check failure on line 34 in src/components/JobSummary/Summary/Summary.js

View workflow job for this annotation

GitHub Actions / lint

Irregular whitespace not allowed

Check failure on line 34 in src/components/JobSummary/Summary/Summary.js

View workflow job for this annotation

GitHub Actions / lint

Irregular whitespace not allowed
)}
</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,
dryRun: PropTypes.bool,

Check failure on line 110 in src/components/JobSummary/Summary/Summary.js

View workflow job for this annotation

GitHub Actions / lint

Prop types declarations should be sorted alphabetically
}

export { Summary }

0 comments on commit 310f912

Please sign in to comment.