Skip to content

Commit

Permalink
fix: lack of access show the generic "something went wrong" error (DH…
Browse files Browse the repository at this point in the history
…IS2-15737) (#429)
  • Loading branch information
martinkrulltott authored Oct 2, 2023
1 parent 7f0fee4 commit 995ae74
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 9 deletions.
22 changes: 16 additions & 6 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: 2023-06-27T14:37:02.617Z\n"
"PO-Revision-Date: 2023-06-27T14:37:02.617Z\n"
"POT-Creation-Date: 2023-09-05T07:20:57.111Z\n"
"PO-Revision-Date: 2023-09-05T07:20:57.111Z\n"

msgid "Add to {{axisName}}"
msgstr "Add to {{axisName}}"
Expand Down Expand Up @@ -622,11 +622,21 @@ msgstr ""
msgid "There's a problem with at least one selected indicator"
msgstr "There's a problem with at least one selected indicator"

msgid "No access"
msgstr "No access"
msgid "Restricted access"
msgstr "Restricted access"

msgid "You don't have access to the requested data"
msgstr "You don't have access to the requested data"
msgid ""
"You don’t have access to the data in this visualization. Contact a system "
"administrator."
msgstr ""
"You don’t have access to the data in this visualization. Contact a system "
"administrator."

msgid "You don’t have access to one or more of the chosen organisation units."
msgstr "You don’t have access to one or more of the chosen organisation units."

msgid "You don’t have access to event analytics. Contact a system administrator."
msgstr "You don’t have access to event analytics. Contact a system administrator."

msgid "Something went wrong"
msgstr "Something went wrong"
Expand Down
9 changes: 9 additions & 0 deletions src/components/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ import { EVENT_TYPE } from '../modules/dataStatistics.js'
import {
dataAccessError,
emptyResponseError,
eventAccessError,
genericServerError,
indicatorError,
orgUnitAccessError,
visualizationNotFoundError,
} from '../modules/error.js'
import history from '../modules/history.js'
Expand Down Expand Up @@ -216,8 +218,15 @@ const App = () => {
output = indicatorError()
break
case 'E7121':
case 'E7123':
output = dataAccessError()
break
case 'E7120':
output = orgUnitAccessError()
break
case 'E7217':
output = eventAccessError()
break
default:
output = genericServerError()
}
Expand Down
26 changes: 23 additions & 3 deletions src/modules/error.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,29 @@ export const indicatorError = () =>

export const dataAccessError = () =>
visualizationError(
GenericError,
i18n.t('No access'),
i18n.t("You don't have access to the requested data")
DataError,
i18n.t('Restricted access'),
i18n.t(
'You don’t have access to the data in this visualization. Contact a system administrator.'
)
)

export const orgUnitAccessError = () =>
visualizationError(
DataError,
i18n.t('Restricted access'),
i18n.t(
'You don’t have access to one or more of the chosen organisation units.'
)
)

export const eventAccessError = () =>
visualizationError(
DataError,
i18n.t('Restricted access'),
i18n.t(
'You don’t have access to event analytics. Contact a system administrator.'
)
)

export const getAlertTypeByStatusCode = (statusCode) =>
Expand Down

0 comments on commit 995ae74

Please sign in to comment.