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 new dashboard plugin architecture #396

Open
wants to merge 54 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
9013df3
refactor: use callback prop for installation status messaging
edoardo Jun 21, 2023
879f061
chore: update deps to latest alpha, remove postRobot
edoardo Oct 9, 2023
1c032e5
refactor: handle recording on first load and plugin cache clear
edoardo Oct 9, 2023
03b3cb0
chore: update app-runtime cli-app-scripts to latest
edoardo May 24, 2024
e329628
refactor: simplify the communication for offline caching
edoardo May 27, 2024
7b04638
refactor: move caching logic in shared component
edoardo May 29, 2024
3d687d2
fix: fix typo
edoardo May 30, 2024
62f7ae1
chore: rename shared component
edoardo Jun 3, 2024
8610a75
refactor: use shared dashboard plugin wrapper
edoardo Jun 3, 2024
faf7e31
chore: bump cli-app-scripts and app-runtime deps
edoardo Jul 1, 2024
b8f9097
chore: use analytics build from d2-ci for testing
edoardo Jul 3, 2024
67aef2a
test: ignore more ResizeObserver errors
edoardo Jul 4, 2024
37039b4
chore: remove unused component
edoardo Jul 4, 2024
7397f9e
fix: avoid ResizeObserver loop error
edoardo Jul 11, 2024
e60ca36
chore: remove debug logs
edoardo Jul 11, 2024
929e81c
chore: bump analytics with period selector fix
edoardo Jul 12, 2024
334f02d
chore: update cli-app-scripts, remove resolution for i18next-scanner
edoardo Jul 29, 2024
1138893
chore: bump app-runtime to avoid duplicate version
edoardo Jul 30, 2024
ae9fcf7
test: fix tests for 2.39
edoardo Jul 31, 2024
8cfe5c5
test: move cy.log inside tests
edoardo Jul 31, 2024
e755bcc
test: update skipRounding test
edoardo Jul 31, 2024
f7f0ed2
test: skip failing test on 40
edoardo Jul 31, 2024
008d22d
test: refactor tests for time dimensions, skip on 41
edoardo Jul 31, 2024
2d2583d
test: skip tests for 39 and 41
edoardo Jul 31, 2024
5569aa4
test: fix tag filtering
edoardo Aug 1, 2024
68614a5
chore: bump start-server-and-test
edoardo Aug 1, 2024
28dfcc6
chore: update analytics
edoardo Aug 5, 2024
8633759
fix: indicate the plugin is for dashboard
edoardo Aug 13, 2024
f7395e7
fix: use correct case for pluginType value
edoardo Aug 15, 2024
5cac399
chore: update yarn.lock
edoardo Aug 15, 2024
ed3c3fe
Merge remote-tracking branch 'origin/master' into refactor/use-platfo…
edoardo Aug 15, 2024
1066caf
chore: update cli-style and cypress deps to work with Cypress 13
edoardo Aug 15, 2024
d83e2ce
chore: run prettier
edoardo Aug 16, 2024
a60fe53
test: revert changes after backports
edoardo Aug 16, 2024
573093e
chore: remove resolution for @dhis2/ui
edoardo Aug 19, 2024
e969ff6
Merge remote-tracking branch 'origin/master' into refactor/use-platfo…
edoardo Oct 10, 2024
40757b4
Merge remote-tracking branch 'origin/master' into refactor/use-platfo…
edoardo Oct 30, 2024
bd9b7cb
chore: use latest analytics build for testing
edoardo Oct 30, 2024
0fd5a80
Merge branch 'master' into refactor/use-platform-plugin-components
edoardo Nov 4, 2024
12aeaf0
test: fix decimals in test
edoardo Nov 4, 2024
8d60178
chore: use latest test build of analytics
edoardo Nov 11, 2024
271f453
test: move tooltip open in tooltip assertion helper function
edoardo Nov 12, 2024
efc9139
fix: ensure the Tooltip is closed immediately
edoardo Nov 12, 2024
699a59d
test: fix tooltip tests for period chip
edoardo Nov 12, 2024
01a2841
fix: format date ranges in tooltip component
edoardo Nov 15, 2024
1b50879
chore: use latest analytics build for testing
edoardo Nov 15, 2024
e266932
Merge remote-tracking branch 'origin/master' into refactor/use-platfo…
edoardo Dec 4, 2024
913873a
Merge branch 'master' into refactor/use-platform-plugin-components
edoardo Dec 6, 2024
d22011c
Merge remote-tracking branch 'origin/master' into refactor/use-platfo…
edoardo Dec 11, 2024
41bfe70
test: fix arguments passed to helper
edoardo Dec 11, 2024
0e19e1a
test: use chip label constant
edoardo Dec 11, 2024
61245ea
chore: use latest analytics build for testing
edoardo Dec 11, 2024
0edc5de
chore: use latest analytics build for testing
edoardo Dec 16, 2024
ecfab31
chore: update ui dependency
edoardo Dec 16, 2024
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
36 changes: 2 additions & 34 deletions src/components/Dialogs/PeriodDimension/PeriodDimension.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import PropTypes from 'prop-types'
import React, { useState, useMemo } from 'react'
import { useDispatch, useSelector, useStore } from 'react-redux'
import { acSetUiItems } from '../../../actions/ui.js'
import { getStartEndDate, isStartEndDate } from '../../../modules/dates.js'
import {
extractDimensionIdParts,
formatDimensionId,
Expand All @@ -28,7 +29,6 @@ import {
SYSTEM_SETTINGS_HIDE_MONTHLY_PERIODS,
SYSTEM_SETTINGS_HIDE_BIMONTHLY_PERIODS,
} from '../../../modules/systemSettings.js'
import { USER_SETTINGS_UI_LOCALE } from '../../../modules/userSettings.js'
import {
sGetDimensionIdsFromLayout,
sGetUiItemsByDimension,
Expand All @@ -41,18 +41,6 @@ import { StartEndDate } from './StartEndDate.js'
export const OPTION_PRESETS = 'PRESETS'
export const OPTION_START_END_DATES = 'START_END_DATES'

const getStartEndDate = (id) => {
const { dimensionId: periodId } = extractDimensionIdParts(id)
const parts = periodId.split('_')
return parts.length === 2 &&
!isNaN(Date.parse(parts[0])) &&
!isNaN(Date.parse(parts[1]))
? parts
: []
}

const isStartEndDate = (id) => getStartEndDate(id).length === 2

const useIsInLayout = (dimensionId) => {
const allDimensionIds = useSelector(sGetDimensionIdsFromLayout)
return useMemo(
Expand All @@ -61,25 +49,6 @@ const useIsInLayout = (dimensionId) => {
)
}

const useLocalizedStartEndDateFormatter = () => {
const { currentUser } = useCachedDataQuery()
const formatter = new Intl.DateTimeFormat(
currentUser.settings[USER_SETTINGS_UI_LOCALE],
{
dateStyle: 'long',
}
)
return (startEndDate) => {
if (isStartEndDate(startEndDate)) {
return getStartEndDate(startEndDate)
.map((dateStr) => formatter.format(new Date(dateStr)))
.join(' - ')
} else {
return ''
}
}
}

const useMetadataNameGetter = () => {
const store = useStore()

Expand Down Expand Up @@ -111,7 +80,6 @@ const useExcludedPeriods = () => {
}

export const PeriodDimension = ({ dimension, onClose }) => {
const formatStartEndDate = useLocalizedStartEndDateFormatter()
const getNameFromMetadata = useMetadataNameGetter()
const dispatch = useDispatch()
const isInLayout = useIsInLayout(dimension?.id)
Expand Down Expand Up @@ -145,7 +113,7 @@ export const PeriodDimension = ({ dimension, onClose }) => {
if (isStartEndDate(item.id)) {
acc.metadata[item.id] = {
id: item.id,
name: formatStartEndDate(item.id),
name: item.id.replace('_', ' - '),
HendrikThePendric marked this conversation as resolved.
Show resolved Hide resolved
}
} else {
acc.metadata[item.id] = item
Expand Down
10 changes: 9 additions & 1 deletion src/components/Layout/TooltipContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ import i18n from '@dhis2/d2-i18n'
import PropTypes from 'prop-types'
import React from 'react'
import { useSelector } from 'react-redux'
import {
isStartEndDate,
useLocalizedStartEndDateFormatter,
} from '../../modules/dates.js'
import { DIMENSION_TYPE_STATUS } from '../../modules/dimensionConstants.js'
import { extractDimensionIdParts } from '../../modules/dimensionId.js'
import { sGetMetadata } from '../../reducers/metadata.js'
Expand All @@ -26,6 +30,8 @@ export const TooltipContent = ({ dimension, conditionsTexts, axisId }) => {
const itemIds = useSelector((state) =>
sGetUiItemsByDimension(state, dimension.id)
)
const formatStartEndDate = useLocalizedStartEndDateFormatter()

const { programStageId, programId } = extractDimensionIdParts(
dimension.id,
inputType
Expand Down Expand Up @@ -56,7 +62,9 @@ export const TooltipContent = ({ dimension, conditionsTexts, axisId }) => {
} else {
const { dimensionId } = extractDimensionIdParts(id, inputType)
itemDisplayNames.push(
metadata[dimensionId] ? metadata[dimensionId].name : id
isStartEndDate(dimensionId)
? formatStartEndDate(dimensionId)
: metadata[dimensionId]?.name ?? id
)
}
})
Expand Down
11 changes: 11 additions & 0 deletions src/components/Layout/__tests__/TooltipContent.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@ import { TooltipContent } from '../TooltipContent.js'

const mockStore = configureMockStore()

jest.mock('@dhis2/analytics', () => ({
...jest.requireActual('@dhis2/analytics'),
useCachedDataQuery: () => ({
currentUser: {
settings: {
keyUiLocale: 'en',
},
},
}),
}))

const inputTypeEvent = {
input: {
type: OUTPUT_TYPE_EVENT,
Expand Down
29 changes: 29 additions & 0 deletions src/modules/dates.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { useCachedDataQuery } from '@dhis2/analytics'
import { USER_SETTINGS_UI_LOCALE } from './userSettings.js'

export const getStartEndDate = (dimensionId) => {
const parts = dimensionId.split('_')
return parts.length === 2 &&
!isNaN(Date.parse(parts[0])) &&
!isNaN(Date.parse(parts[1]))
? parts
: []
}

export const isStartEndDate = (id) => getStartEndDate(id).length === 2

export const useLocalizedStartEndDateFormatter = () => {
const { currentUser } = useCachedDataQuery()

const formatter = new Intl.DateTimeFormat(
currentUser.settings[USER_SETTINGS_UI_LOCALE],
{
dateStyle: 'long',
}
)

return (startEndDate) =>
getStartEndDate(startEndDate)
.map((dateStr) => formatter.format(new Date(dateStr)))
.join(' - ')
}
Loading