Skip to content

Commit

Permalink
fix: support outlier table plugin (DHIS2-16751)
Browse files Browse the repository at this point in the history
  • Loading branch information
edoardo committed Feb 26, 2024
1 parent c2798d0 commit 4724007
Show file tree
Hide file tree
Showing 4 changed files with 474 additions and 450 deletions.
20 changes: 13 additions & 7 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-05-03T11:08:21.315Z\n"
"PO-Revision-Date: 2023-05-03T11:08:21.315Z\n"
"POT-Creation-Date: 2024-02-26T14:42:02.563Z\n"
"PO-Revision-Date: 2024-02-26T14:42:02.563Z\n"

msgid "Untitled dashboard"
msgstr "Untitled dashboard"
Expand Down Expand Up @@ -86,14 +86,20 @@ msgstr "View fullscreen"
msgid "This map can't be displayed as a chart"
msgstr "This map can't be displayed as a chart"

msgid "This map can't be displayed as a pivot table"
msgstr "This map can't be displayed as a pivot table"

msgid "This visualization can't be displayed as a pivot table"
msgstr "This visualization can't be displayed as a pivot table"

msgid "This visualization can't be displayed as a map"
msgstr "This visualization can't be displayed as a map"

msgid "View as Chart"
msgstr "View as Chart"

msgid "This map can't be displayed as a table"
msgstr "This map can't be displayed as a table"

msgid "View as Table"
msgstr "View as Table"
msgid "View as Pivot table"
msgstr "View as Pivot table"

msgid "View as Map"
msgstr "View as Map"
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"@dhis2/d2-ui-interpretations": "^7.4.3",
"@dhis2/d2-ui-mentions-wrapper": "^7.4.3",
"@dhis2/d2-ui-rich-text": "^7.4.3",
"@dhis2/ui": "^8.14.0",
"@dhis2/ui": "^9.2.0",
"@krakenjs/post-robot": "^11.0.0",
"classnames": "^2.3.2",
"d2": "^31.10.0",
Expand Down Expand Up @@ -64,5 +64,8 @@
"moduleNameMapper": {
"^.+\\.(css|sass|scss)$": "identity-obj-proxy"
}
},
"resolutions": {
"@dhis2/ui": "^9.2.0"
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { VIS_TYPE_OUTLIER_TABLE } from '@dhis2/analytics'

Check failure on line 1 in src/components/Item/VisualizationItem/ItemContextMenu/ViewAsMenuItems.js

View workflow job for this annotation

GitHub Actions / lint

VIS_TYPE_OUTLIER_TABLE not found in '@dhis2/analytics'

Check failure on line 1 in src/components/Item/VisualizationItem/ItemContextMenu/ViewAsMenuItems.js

View workflow job for this annotation

GitHub Actions / lint

VIS_TYPE_OUTLIER_TABLE not found in '@dhis2/analytics'
import i18n from '@dhis2/d2-i18n'
import { IconVisualizationColumn16, IconTable16, IconWorld16 } from '@dhis2/ui'
import PropTypes from 'prop-types'
Expand Down Expand Up @@ -31,17 +32,33 @@ const ViewAsMenuItems = ({

const onViewMap = () => onActiveTypeChanged(MAP)

const notSupported = type === MAP && !getThematicMapViews(visualization)
const notSupported =
(type === MAP && !getThematicMapViews(visualization)) ||
(type === CHART && visualization.type === VIS_TYPE_OUTLIER_TABLE)

const getNotSupportedMessage = (viewAs) => {
if (type === MAP && !getThematicMapViews(visualization)) {
return viewAs === 'chart'
? i18n.t("This map can't be displayed as a chart")
: i18n.t("This map can't be displayed as a pivot table")
}

if (type === CHART && visualization.type === VIS_TYPE_OUTLIER_TABLE) {
return viewAs === 'table'
? i18n.t(
"This visualization can't be displayed as a pivot table"
)
: i18n.t("This visualization can't be displayed as a map")
}

return null
}

return (
<>
{![CHART, EVENT_CHART].includes(activeType) && (
<MenuItem
tooltip={
notSupported
? i18n.t("This map can't be displayed as a chart")
: null
}
tooltip={getNotSupportedMessage('chart')}
label={i18n.t('View as Chart')}
onClick={onViewChart}
disabled={notSupported}
Expand All @@ -52,21 +69,19 @@ const ViewAsMenuItems = ({
activeType
) && (
<MenuItem
tooltip={
notSupported
? i18n.t("This map can't be displayed as a table")
: null
}
label={i18n.t('View as Table')}
tooltip={getNotSupportedMessage('table')}
label={i18n.t('View as Pivot table')}
onClick={onViewTable}
disabled={notSupported}
icon={<IconTable16 />}
/>
)}
{hasMapView(type) && activeType !== MAP && (
<MenuItem
tooltip={getNotSupportedMessage('map')}
label={i18n.t('View as Map')}
onClick={onViewMap}
disabled={notSupported}
icon={<IconWorld16 />}
/>
)}
Expand Down
Loading

0 comments on commit 4724007

Please sign in to comment.