Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(DHIS2-16133): migrate to new tracker API #1951

Merged
merged 12 commits into from
Mar 6, 2024
Merged
2 changes: 1 addition & 1 deletion src/components/Inputs/AtomicMode.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { RadioGroupField } from '../index.js'

const atomicModeOptions = [
{ value: 'ALL', label: i18n.t('Do not import') },
{ value: 'NONE', label: i18n.t('Import') },
{ value: 'OBJECT', label: i18n.t('Import') },
]
const defaultAtomicModeOption = atomicModeOptions[0].value

Expand Down
12 changes: 9 additions & 3 deletions src/components/Inputs/EndDate.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import i18n from '@dhis2/d2-i18n'
import { hasValue, composeValidators } from '@dhis2/ui'
import PropTypes from 'prop-types'
import React from 'react'
import { DATE_VALIDATOR } from '../DatePicker/DatePickerField.js'
import { DatePickerField } from '../index.js'
Expand All @@ -9,13 +10,18 @@ const DATATEST = 'input-end-date'
const LABEL = i18n.t('End date')
const VALIDATOR = composeValidators(hasValue, DATE_VALIDATOR)

const EndDate = () => (
const EndDate = ({ name, label }) => (
<DatePickerField
name={NAME}
name={name ?? NAME}
validator={VALIDATOR}
label={LABEL}
label={label ?? LABEL}
dataTest={DATATEST}
/>
)

EndDate.propTypes = {
label: PropTypes.string,
name: PropTypes.string,
}

export { EndDate }
6 changes: 3 additions & 3 deletions src/components/Inputs/FollowUpStatus.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import { RadioGroupField } from '../index.js'

const followUpStatusOptions = [
{ value: 'ALL', label: i18n.t('All') },
{ value: 'TRUE', label: i18n.t('Marked for follow-up') },
{ value: 'FALSE', label: i18n.t('Not marked for follow-up') },
{ value: 'true', label: i18n.t('Marked for follow-up') },
{ value: 'false', label: i18n.t('Not marked for follow-up') },
]
const defaultFollowUpStatusOption = followUpStatusOptions[0].value

const NAME = 'followUpStatus'
const NAME = 'followup'
const DATATEST = 'input-follow-up-status'
const LABEL = i18n.t('Include only entities with follow-up status')

Expand Down
2 changes: 1 addition & 1 deletion src/components/Inputs/LastUpdatedDuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import React from 'react'
import { DURATION_VALIDATOR } from '../Duration/DurationField.js'
import { DurationField } from '../index.js'

const NAME = 'lastUpdatedDuration'
const NAME = 'updatedWithin'
const DATATEST = 'input-last-updated-duration'
const LABEL = i18n.t('Last updated duration')
const VALIDATOR = composeValidators(hasValue, DURATION_VALIDATOR)
Expand Down
2 changes: 1 addition & 1 deletion src/components/Inputs/LastUpdatedEndDate.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import React from 'react'
import { OPTIONAL_DATE_VALIDATOR } from '../DatePicker/DatePickerField.js'
import { DatePickerField } from '../index.js'

const NAME = 'lastUpdatedEndDate'
const NAME = 'updatedBefore'
const DATATEST = 'input-last-updated-end-date'
const LABEL = i18n.t('Last updated end date')
const VALIDATOR = composeValidators(OPTIONAL_DATE_VALIDATOR)
Expand Down
2 changes: 1 addition & 1 deletion src/components/Inputs/LastUpdatedStartDate.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import React from 'react'
import { OPTIONAL_DATE_VALIDATOR } from '../DatePicker/DatePickerField.js'
import { DatePickerField } from '../index.js'

const NAME = 'lastUpdatedStartDate'
const NAME = 'updatedAfter'
const DATATEST = 'input-last-updated-start-date'
const LABEL = i18n.t('Last updated start date')
const VALIDATOR = composeValidators(OPTIONAL_DATE_VALIDATOR)
Expand Down
2 changes: 1 addition & 1 deletion src/components/Inputs/ProgramEndDate.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import React from 'react'
import { OPTIONAL_DATE_VALIDATOR } from '../DatePicker/DatePickerField.js'
import { DatePickerField } from '../index.js'

const NAME = 'programEndDate'
const NAME = 'enrollmentEnrolledBefore'
const DATATEST = 'input-program-end-date'
const LABEL = i18n.t('End date')
const VALIDATOR = composeValidators(OPTIONAL_DATE_VALIDATOR)
Expand Down
2 changes: 1 addition & 1 deletion src/components/Inputs/ProgramStartDate.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import React from 'react'
import { OPTIONAL_DATE_VALIDATOR } from '../DatePicker/DatePickerField.js'
import { DatePickerField } from '../index.js'

const NAME = 'programStartDate'
const NAME = 'enrollmentEnrolledAfter'
const DATATEST = 'input-program-start-date'
const LABEL = i18n.t('Start date')
const VALIDATOR = composeValidators(OPTIONAL_DATE_VALIDATOR)
Expand Down
11 changes: 8 additions & 3 deletions src/components/Inputs/StartDate.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import i18n from '@dhis2/d2-i18n'
import { hasValue, composeValidators } from '@dhis2/ui'
import PropTypes from 'prop-types'
import React from 'react'
import { DATE_VALIDATOR } from '../DatePicker/DatePickerField.js'
import { DatePickerField } from '../index.js'
Expand All @@ -9,13 +10,17 @@ const DATATEST = 'input-start-date'
const LABEL = i18n.t('Start date')
const VALIDATOR = composeValidators(hasValue, DATE_VALIDATOR)

const StartDate = () => (
const StartDate = ({ name, label }) => (
<DatePickerField
name={NAME}
name={name ?? NAME}
validator={VALIDATOR}
label={LABEL}
label={label ?? LABEL}
dataTest={DATATEST}
/>
)

StartDate.propTypes = {
label: PropTypes.string,
name: PropTypes.string,
}
export { StartDate }
1 change: 0 additions & 1 deletion src/components/Inputs/TEITypeFilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import React from 'react'
import { RadioGroupField } from '../index.js'

const teiTypeFilterOptions = [
{ value: 'NONE', label: i18n.t('None') },
{ value: 'PROGRAM', label: i18n.t('Program') },
{ value: 'TE', label: i18n.t('Tracked entity type') },
]
Expand Down
76 changes: 70 additions & 6 deletions src/components/JobSummary/SingleSummary/SingleSummary.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const SingleSummary = ({
status,
description,
conflicts,
validationReport,
id,
}) => (
<div>
Expand All @@ -29,7 +30,7 @@ const SingleSummary = ({
name="summary"
>
<>
{status && (
{status && description && (
<SingleStatusTable
description={description}
status={status}
Expand All @@ -47,16 +48,61 @@ const SingleSummary = ({
</TableHead>
<TableBody>
<TableRow>
<TableCell>{importCount.imported}</TableCell>
<TableCell>{importCount.deleted}</TableCell>
<TableCell>{importCount.ignored}</TableCell>
<TableCell>{importCount.updated}</TableCell>
<TableCell>{importCount.total}</TableCell>
<TableCell>
{importCount?.imported ?? '0'}
</TableCell>
<TableCell>{importCount?.deleted}</TableCell>
<TableCell>{importCount?.ignored}</TableCell>
<TableCell>{importCount?.updated}</TableCell>
<TableCell>{importCount?.total}</TableCell>
</TableRow>
</TableBody>
</Table>
</>
</FormField>
{!!validationReport?.errorReports?.length && (
<FormField
label={`${i18n.t('Reports')}`}
dataTest="tracker-summary-reports"
name="tracker-reports"
>
<Table>
<TableHead>
<TableRowHead>
<TableCellHead>{i18n.t('UID')}</TableCellHead>
<TableCellHead>
{i18n.t('Error Code')}
</TableCellHead>
<TableCellHead>{i18n.t('Message')}</TableCellHead>
<TableCellHead>
{i18n.t('Tracker Type')}
</TableCellHead>
{/* <TableCellHead>{i18n.t('')}</TableCellHead> */}
</TableRowHead>
</TableHead>
<TableBody>
{validationReport.errorReports.map((c, i) => (
<TableRow
key={`job-summary-report-${c.object}-${i}`}
>
<TableCell>{c.uid}</TableCell>
<TableCell>
<a
target="_blank"
rel="noreferrer"
href="https://docs.dhis2.org/en/develop/using-the-api/dhis-core-version-master/tracker.html#webapi_nti_error_codes"
>
{c.warningCode ?? c.errorCode}
</a>
</TableCell>
<TableCell>{c.message}</TableCell>
<TableCell>{c.trackerType}</TableCell>
</TableRow>
))}
</TableBody>
</Table>
</FormField>
)}
{conflicts && (
<FormField
label={`${i18n.t('Conflicts')}`}
Expand Down Expand Up @@ -107,6 +153,24 @@ SingleSummary.propTypes = {
id: PropTypes.string,
importType: PropTypes.string,
status: PropTypes.string,
validationReport: PropTypes.shape({
errorReports: PropTypes.arrayOf(
PropTypes.shape({
errorCode: PropTypes.string,
message: PropTypes.string,
trackerType: PropTypes.string,
uid: PropTypes.string,
})
),
warningReports: PropTypes.arrayOf(
PropTypes.shape({
errorCode: PropTypes.string,
message: PropTypes.string,
trackerType: PropTypes.string,
uid: PropTypes.string,
})
),
}),
}

export { SingleSummary }
1 change: 1 addition & 0 deletions src/components/JobSummary/Summary/Summary.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const Summary = ({ summary, importType }) => {
importCount={importCount}
status={summary.status}
description={summary.description}
validationReport={summary.validationReport}
conflicts={
summary.conflicts &&
(summary.conflicts.length || null) &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,51 +172,6 @@ exports[`different job type summaries matches snapshot - EVENT_IMPORT 1`] = `
>
Summary
</span>
<table
class="jsx-2430604489 "
data-test="dhis2-uicore-table"
>
<thead
data-test="dhis2-uicore-tablehead"
>
<tr
class="jsx-3124144591 zebraStriping"
data-test="dhis2-uicore-tablerowhead"
>
<th
class="jsx-1796049005 "
data-test="dhis2-uicore-tablecellhead"
>
Status
</th>
<th
class="jsx-1796049005 "
data-test="dhis2-uicore-tablecellhead"
>
Description
</th>
</tr>
</thead>
<tbody
data-test="dhis2-uicore-tablebody"
>
<tr
class="jsx-3124144591 zebraStriping"
data-test="dhis2-uicore-tablerow"
>
<td
class="jsx-996330601 "
data-test="dhis2-uicore-tablecell"
>
ERROR
</td>
<td
class="jsx-996330601 "
data-test="dhis2-uicore-tablecell"
/>
</tr>
</tbody>
</table>
<table
class="jsx-2430604489 "
data-test="dhis2-uicore-table"
Expand Down Expand Up @@ -758,51 +713,6 @@ exports[`different job type summaries matches snapshot - METADATA_IMPORT 1`] = `
>
Summary
</span>
<table
class="jsx-2430604489 "
data-test="dhis2-uicore-table"
>
<thead
data-test="dhis2-uicore-tablehead"
>
<tr
class="jsx-3124144591 zebraStriping"
data-test="dhis2-uicore-tablerowhead"
>
<th
class="jsx-1796049005 "
data-test="dhis2-uicore-tablecellhead"
>
Status
</th>
<th
class="jsx-1796049005 "
data-test="dhis2-uicore-tablecellhead"
>
Description
</th>
</tr>
</thead>
<tbody
data-test="dhis2-uicore-tablebody"
>
<tr
class="jsx-3124144591 zebraStriping"
data-test="dhis2-uicore-tablerow"
>
<td
class="jsx-996330601 "
data-test="dhis2-uicore-tablecell"
>
OK
</td>
<td
class="jsx-996330601 "
data-test="dhis2-uicore-tablecell"
/>
</tr>
</tbody>
</table>
<table
class="jsx-2430604489 "
data-test="dhis2-uicore-table"
Expand Down Expand Up @@ -856,7 +766,9 @@ exports[`different job type summaries matches snapshot - METADATA_IMPORT 1`] = `
<td
class="jsx-996330601 "
data-test="dhis2-uicore-tablecell"
/>
>
0
</td>
<td
class="jsx-996330601 "
data-test="dhis2-uicore-tablecell"
Expand Down
4 changes: 2 additions & 2 deletions src/components/Sidebar/Sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const metadataImportPage = {
icon: <MetadataImportIcon />,
}
const teiImportPage = {
name: i18n.t('TEI import'),
name: i18n.t('Tracked entity import'),
code: 'tei-import',
path: '/import/tei',
icon: <TEIIcon />,
Expand Down Expand Up @@ -88,7 +88,7 @@ const metadataExportPage = {
}

const teiExportPage = {
name: i18n.t('TEI export'),
name: i18n.t('Tracked entity export'),
code: 'tei-export',
path: '/export/tei',
icon: <TEIIcon />,
Expand Down
Loading
Loading