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: support outlier table plugin (DHIS2-16751) #2912

Merged
merged 4 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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-06-22T08:57:46.931Z\n"
"PO-Revision-Date: 2023-06-22T08:57:46.931Z\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 @@ -89,14 +89,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
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
"private": true,
"license": "BSD-3-Clause",
"dependencies": {
"@dhis2/analytics": "^26.4.0",
"@dhis2/analytics": "999.9.9-outlier-table.alpha.4",
"@dhis2/app-runtime": "^3.10.2",
"@dhis2/app-runtime-adapter-d2": "^1.1.0",
"@dhis2/d2-i18n": "^1.1.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 @@ -61,5 +61,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'
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
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ test('renders just the button when menu closed', () => {
expect(getByRole('button')).toBeTruthy()
expect(queryByText('View as Map')).toBeNull()
expect(queryByText('View as Chart')).toBeNull()
expect(queryByText('View as Table')).toBeNull()
expect(queryByText('View as Pivot table')).toBeNull()
expect(queryByTestId('divider')).toBeNull()
expect(queryByText('Open in Data Visualizer app')).toBeNull()
expect(queryByText('Show details and interpretations')).toBeNull()
Expand Down Expand Up @@ -113,7 +113,7 @@ test('renders popover menu for BAR chart', async () => {
await waitFor(() => {
expect(queryByText('View as Map')).toBeTruthy()
expect(queryByText('View as Chart')).toBeNull()
expect(queryByText('View as Table')).toBeTruthy()
expect(queryByText('View as Pivot table')).toBeTruthy()
expect(queryByTestId('divider')).toBeTruthy()
expect(queryByText('Open in Data Visualizer app')).toBeTruthy()
expect(queryByText('Show details and interpretations')).toBeTruthy()
Expand All @@ -140,7 +140,7 @@ test('renders popover menu for SINGLE_VALUE chart', async () => {
await waitFor(() => {
expect(queryByText('View as Map')).toBeNull()
expect(queryByText('View as Chart')).toBeNull()
expect(queryByText('View as Table')).toBeNull()
expect(queryByText('View as Pivot table')).toBeNull()
expect(queryByTestId('divider')).toBeNull()
expect(queryByText('Open in Data Visualizer app')).toBeTruthy()
expect(queryByText('Show details and interpretations')).toBeTruthy()
Expand All @@ -167,7 +167,7 @@ test('renders popover menu for YEAR_OVER_YEAR_LINE chart', async () => {
await waitFor(() => {
expect(queryByText('View as Map')).toBeNull()
expect(queryByText('View as Chart')).toBeNull()
expect(queryByText('View as Table')).toBeNull()
expect(queryByText('View as Pivot table')).toBeNull()
expect(queryByTestId('divider')).toBeNull()
expect(queryByText('Open in Data Visualizer app')).toBeTruthy()
expect(queryByText('Show details and interpretations')).toBeTruthy()
Expand All @@ -194,7 +194,7 @@ test('renders popover menu for GAUGE chart', async () => {
await waitFor(() => {
expect(queryByText('View as Map')).toBeNull()
expect(queryByText('View as Chart')).toBeNull()
expect(queryByText('View as Table')).toBeNull()
expect(queryByText('View as Pivot table')).toBeNull()
expect(queryByTestId('divider')).toBeNull()
expect(queryByText('Open in Data Visualizer app')).toBeTruthy()
expect(queryByText('Show details and interpretations')).toBeTruthy()
Expand All @@ -221,7 +221,7 @@ test('renders popover menu for PIE chart', async () => {
await waitFor(() => {
expect(queryByText('View as Map')).toBeNull()
expect(queryByText('View as Chart')).toBeNull()
expect(queryByText('View as Table')).toBeNull()
expect(queryByText('View as Pivot table')).toBeNull()
expect(queryByTestId('divider')).toBeNull()
expect(queryByText('Open in Data Visualizer app')).toBeTruthy()
expect(queryByText('Show details and interpretations')).toBeTruthy()
Expand Down Expand Up @@ -252,7 +252,7 @@ test('renders popover menu for PIVOT_TABLE', async () => {
await waitFor(() => {
expect(queryByText('View as Map')).toBeTruthy()
expect(queryByText('View as Chart')).toBeTruthy()
expect(queryByText('View as Table')).toBeNull()
expect(queryByText('View as Pivot table')).toBeNull()
expect(queryByTestId('divider')).toBeTruthy()
expect(queryByText('Open in Data Visualizer app')).toBeTruthy()
expect(queryByText('Show details and interpretations')).toBeTruthy()
Expand Down Expand Up @@ -281,7 +281,7 @@ test('renders popover menu for MAP', async () => {
await waitFor(() => {
expect(queryByText('View as Map')).toBeNull()
expect(queryByText('View as Chart')).toBeTruthy()
expect(queryByText('View as Table')).toBeTruthy()
expect(queryByText('View as Pivot table')).toBeTruthy()
expect(queryByTestId('divider')).toBeTruthy()
expect(queryByText('Open in Maps app')).toBeTruthy()
expect(queryByText('Show details and interpretations')).toBeTruthy()
Expand Down Expand Up @@ -379,7 +379,7 @@ test('renders only View in App when item load failed', async () => {
await waitFor(() => {
expect(queryByText('View as Map')).toBeNull()
expect(queryByText('View as Chart')).toBeNull()
expect(queryByText('View as Table')).toBeNull()
expect(queryByText('View as Pivot table')).toBeNull()
expect(queryByTestId('divider')).toBeNull()
expect(queryByText('Open in Maps app')).toBeTruthy()
expect(queryByText('Show details and interpretations')).toBeNull()
Expand Down Expand Up @@ -467,7 +467,7 @@ test('renders correct options for BAR in small screen', async () => {
await waitFor(() => {
expect(queryByText('View as Map')).toBeTruthy()
expect(queryByText('View as Chart')).toBeNull()
expect(queryByText('View as Table')).toBeTruthy()
expect(queryByText('View as Pivot table')).toBeTruthy()
expect(queryByTestId('divider')).toBeTruthy()
expect(queryByText('Open in Data Visualizer app')).toBeNull()
expect(queryByText('Show details and interpretations')).toBeTruthy()
Expand Down Expand Up @@ -498,7 +498,7 @@ test('renders correct options for PIE in small screen', async () => {
await waitFor(() => {
expect(queryByText('View as Map')).toBeNull()
expect(queryByText('View as Chart')).toBeNull()
expect(queryByText('View as Table')).toBeNull()
expect(queryByText('View as Pivot table')).toBeNull()
expect(queryByTestId('divider')).toBeNull()
expect(queryByText('Open in Data Visualizer app')).toBeNull()
expect(queryByText('Show details and interpretations')).toBeTruthy()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ test('renders just the button when menu closed', () => {
expect(getByRole('button')).toBeTruthy()
expect(queryByText('View as Map')).toBeNull()
expect(queryByText('View as Chart')).toBeNull()
expect(queryByText('View as Table')).toBeNull()
expect(queryByText('View as Pivot table')).toBeNull()
expect(queryByTestId('divider')).toBeNull()
expect(queryByText('Open in Data Visualizer app')).toBeNull()
expect(queryByText('Show details and interpretations')).toBeNull()
Expand Down Expand Up @@ -113,7 +113,7 @@ test('renders popover menu for BAR chart', async () => {
await waitFor(() => {
expect(queryByText('View as Map')).toBeTruthy()
expect(queryByText('View as Chart')).toBeNull()
expect(queryByText('View as Table')).toBeTruthy()
expect(queryByText('View as Pivot table')).toBeTruthy()
expect(queryByTestId('divider')).toBeTruthy()
expect(queryByText('Open in Data Visualizer app')).toBeTruthy()
expect(queryByText('Show details and interpretations')).toBeTruthy()
Expand All @@ -140,7 +140,7 @@ test('renders popover menu for SINGLE_VALUE chart', async () => {
await waitFor(() => {
expect(queryByText('View as Map')).toBeNull()
expect(queryByText('View as Chart')).toBeNull()
expect(queryByText('View as Table')).toBeNull()
expect(queryByText('View as Pivot table')).toBeNull()
expect(queryByTestId('divider')).toBeNull()
expect(queryByText('Open in Data Visualizer app')).toBeTruthy()
expect(queryByText('Show details and interpretations')).toBeTruthy()
Expand All @@ -167,7 +167,7 @@ test('renders popover menu for YEAR_OVER_YEAR_LINE chart', async () => {
await waitFor(() => {
expect(queryByText('View as Map')).toBeNull()
expect(queryByText('View as Chart')).toBeNull()
expect(queryByText('View as Table')).toBeNull()
expect(queryByText('View as Pivot table')).toBeNull()
expect(queryByTestId('divider')).toBeNull()
expect(queryByText('Open in Data Visualizer app')).toBeTruthy()
expect(queryByText('Show details and interpretations')).toBeTruthy()
Expand All @@ -194,7 +194,7 @@ test('renders popover menu for GAUGE chart', async () => {
await waitFor(() => {
expect(queryByText('View as Map')).toBeNull()
expect(queryByText('View as Chart')).toBeNull()
expect(queryByText('View as Table')).toBeNull()
expect(queryByText('View as Pivot table')).toBeNull()
expect(queryByTestId('divider')).toBeNull()
expect(queryByText('Open in Data Visualizer app')).toBeTruthy()
expect(queryByText('Show details and interpretations')).toBeTruthy()
Expand All @@ -221,7 +221,7 @@ test('renders popover menu for PIE chart', async () => {
await waitFor(() => {
expect(queryByText('View as Map')).toBeNull()
expect(queryByText('View as Chart')).toBeNull()
expect(queryByText('View as Table')).toBeNull()
expect(queryByText('View as Pivot table')).toBeNull()
expect(queryByTestId('divider')).toBeNull()
expect(queryByText('Open in Data Visualizer app')).toBeTruthy()
expect(queryByText('Show details and interpretations')).toBeTruthy()
Expand Down Expand Up @@ -252,7 +252,7 @@ test('renders popover menu for PIVOT_TABLE', async () => {
await waitFor(() => {
expect(queryByText('View as Map')).toBeTruthy()
expect(queryByText('View as Chart')).toBeTruthy()
expect(queryByText('View as Table')).toBeNull()
expect(queryByText('View as Pivot table')).toBeNull()
expect(queryByTestId('divider')).toBeTruthy()
expect(queryByText('Open in Data Visualizer app')).toBeTruthy()
expect(queryByText('Show details and interpretations')).toBeTruthy()
Expand Down Expand Up @@ -281,7 +281,7 @@ test('renders popover menu for MAP', async () => {
await waitFor(() => {
expect(queryByText('View as Map')).toBeNull()
expect(queryByText('View as Chart')).toBeTruthy()
expect(queryByText('View as Table')).toBeTruthy()
expect(queryByText('View as Pivot table')).toBeTruthy()
expect(queryByTestId('divider')).toBeTruthy()
expect(queryByText('Open in Maps app')).toBeTruthy()
expect(queryByText('Show details and interpretations')).toBeTruthy()
Expand Down Expand Up @@ -379,7 +379,7 @@ test('renders only View in App when item load failed', async () => {
await waitFor(() => {
expect(queryByText('View as Map')).toBeNull()
expect(queryByText('View as Chart')).toBeNull()
expect(queryByText('View as Table')).toBeNull()
expect(queryByText('View as Pivot table')).toBeNull()
expect(queryByTestId('divider')).toBeNull()
expect(queryByText('Open in Maps app')).toBeTruthy()
expect(queryByText('Show details and interpretations')).toBeNull()
Expand Down Expand Up @@ -467,7 +467,7 @@ test('renders correct options for BAR in small screen', async () => {
await waitFor(() => {
expect(queryByText('View as Map')).toBeTruthy()
expect(queryByText('View as Chart')).toBeNull()
expect(queryByText('View as Table')).toBeTruthy()
expect(queryByText('View as Pivot table')).toBeTruthy()
expect(queryByTestId('divider')).toBeTruthy()
expect(queryByText('Open in Data Visualizer app')).toBeNull()
expect(queryByText('Show details and interpretations')).toBeTruthy()
Expand Down Expand Up @@ -498,7 +498,7 @@ test('renders correct options for PIE in small screen', async () => {
await waitFor(() => {
expect(queryByText('View as Map')).toBeNull()
expect(queryByText('View as Chart')).toBeNull()
expect(queryByText('View as Table')).toBeNull()
expect(queryByText('View as Pivot table')).toBeNull()
expect(queryByTestId('divider')).toBeNull()
expect(queryByText('Open in Data Visualizer app')).toBeNull()
expect(queryByText('Show details and interpretations')).toBeTruthy()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ test('renders menu for active type MAP and type CHART', async () => {
const props = Object.assign({}, defaultProps, {
type: CHART,
activeType: MAP,
visualization: {
type: 'COLUMN',
},
})

const { container } = render(<ViewAsMenuItems {...props} />)
Expand All @@ -49,6 +52,9 @@ test('renders disabled menu items when offline', () => {
const props = Object.assign({}, defaultProps, {
type: CHART,
activeType: MAP,
visualization: {
type: 'COLUMN',
},
})

const { container } = render(<ViewAsMenuItems {...props} />)
Expand Down Expand Up @@ -105,7 +111,7 @@ test('renders menu for active type REPORT_TABLE and type CHART', async () => {
const props = Object.assign({}, defaultProps, {
type: CHART,
activeType: REPORT_TABLE,
visualization: {},
visualization: { type: 'COLUMN' },
})

const { container } = render(<ViewAsMenuItems {...props} />)
Expand All @@ -118,7 +124,7 @@ test('renders menu for active type CHART and type REPORT_TABLE', async () => {
const props = Object.assign({}, defaultProps, {
type: REPORT_TABLE,
activeType: CHART,
visualization: {},
visualization: { type: 'PIVOT_TABLE' },
})

const { container } = render(<ViewAsMenuItems {...props} />)
Expand Down
Loading
Loading