Skip to content

Commit

Permalink
fix: adapt error message to specific dimension (DHIS2-12915) (#2009)
Browse files Browse the repository at this point in the history
* fix: adapt error message to specific dimension

* fix: prevent fixed dimensions from getting the 'all' item
  • Loading branch information
martinkrulltott authored and janhenrikoverland committed Apr 5, 2022
1 parent 090fbc0 commit 30e94e0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
15 changes: 13 additions & 2 deletions packages/app/src/actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ import {
getDisplayNameByVisType,
convertOuLevelsToUids,
ALL_DYNAMIC_DIMENSION_ITEMS,
DIMENSION_ID_DATA,
DIMENSION_ID_PERIOD,
DIMENSION_ID_ORGUNIT,
DIMENSION_ID_ASSIGNED_CATEGORIES,
} from '@dhis2/analytics'
import i18n from '@dhis2/d2-i18n'
import { apiPostDataStatistics } from '../api/dataStatistics.js'
Expand Down Expand Up @@ -58,12 +62,19 @@ const adaptAxisItems = (axis) =>
...ai,
items: ai?.items?.length
? ai.items
: [
: ![
DIMENSION_ID_DATA,
DIMENSION_ID_PERIOD,
DIMENSION_ID_ORGUNIT,
DIMENSION_ID_ASSIGNED_CATEGORIES,
].includes(ai.dimension)
? [
{
id: ALL_DYNAMIC_DIMENSION_ITEMS,
name: i18n.t('All items'),
},
],
]
: null,
}))

// visualization, current, ui
Expand Down
14 changes: 12 additions & 2 deletions packages/app/src/components/Visualization/Visualization.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
NoDataOrDataElementGroupSetError,
CombinationDEGSRRError,
NoOrgUnitResponseError,
NoDataError,
} from '../../modules/error.js'
import { removeLastPathSegment } from '../../modules/orgUnit.js'
import { sGetCurrent } from '../../reducers/current.js'
Expand Down Expand Up @@ -63,9 +64,18 @@ export class UnconnectedVisualization extends Component {
error = new CombinationDEGSRRError()
break
case 'E7124':
error = new NoOrgUnitResponseError()
{
if (response?.message?.includes('`dx`')) {
error = new NoDataError(
this.props.visualization.type
)
} else if (response?.message?.includes('`ou`')) {
error = new NoOrgUnitResponseError()
} else {
error = new GenericServerError()
}
}
break

default:
error = response
}
Expand Down

0 comments on commit 30e94e0

Please sign in to comment.