From 8e60f266bd55f8dee9745ad1930f6525e3ca96f3 Mon Sep 17 00:00:00 2001
From: Jen Jones Arnesen
Date: Fri, 8 Sep 2023 13:22:07 +0200
Subject: [PATCH 1/4] fix: interpretation panel display date and timestamps
according to client time zone (DHIS2-15825)
---
src/components/AboutAOUnit/AboutAOUnit.js | 17 ++-
.../InterpretationThread.js | 6 +-
.../InterpretationsUnit/InterpretationList.js | 4 +-
.../Interpretations/common/Message/Message.js | 104 +++++++++---------
4 files changed, 76 insertions(+), 55 deletions(-)
diff --git a/src/components/AboutAOUnit/AboutAOUnit.js b/src/components/AboutAOUnit/AboutAOUnit.js
index 0fb7fb78e..76002a453 100644
--- a/src/components/AboutAOUnit/AboutAOUnit.js
+++ b/src/components/AboutAOUnit/AboutAOUnit.js
@@ -1,4 +1,8 @@
-import { useDataQuery, useDataMutation } from '@dhis2/app-runtime'
+import {
+ useDataQuery,
+ useDataMutation,
+ useTimeZoneConversion,
+} from '@dhis2/app-runtime'
import i18n from '@dhis2/d2-i18n'
import { Parser as RichTextParser } from '@dhis2/d2-ui-rich-text'
import {
@@ -57,6 +61,7 @@ const getUnsubscribeMutation = (type, id) => ({
const AboutAOUnit = forwardRef(({ type, id, renderId }, ref) => {
const [isExpanded, setIsExpanded] = useState(true)
+ const { fromServerDate } = useTimeZoneConversion()
const queries = useMemo(() => getQueries(type), [type])
@@ -208,7 +213,7 @@ const AboutAOUnit = forwardRef(({ type, id, renderId }, ref) => {
{i18n.t('Last updated {{time}}', {
time: moment(
- data.ao.lastUpdated
+ fromServerDate(data.ao.lastUpdated)
).fromNow(),
})}
@@ -219,7 +224,9 @@ const AboutAOUnit = forwardRef(({ type, id, renderId }, ref) => {
'Created {{time}} by {{author}}',
{
time: moment(
- data.ao.created
+ fromServerDate(
+ data.ao.created
+ )
).fromNow(),
author: data.ao.createdBy
.displayName,
@@ -227,7 +234,9 @@ const AboutAOUnit = forwardRef(({ type, id, renderId }, ref) => {
)
: i18n.t('Created {{time}}', {
time: moment(
- data.ao.created
+ fromServerDate(
+ data.ao.created
+ )
).fromNow(),
})}
diff --git a/src/components/Interpretations/InterpretationModal/InterpretationThread.js b/src/components/Interpretations/InterpretationModal/InterpretationThread.js
index 03540290d..f1d5779e2 100644
--- a/src/components/Interpretations/InterpretationModal/InterpretationThread.js
+++ b/src/components/Interpretations/InterpretationModal/InterpretationThread.js
@@ -1,3 +1,4 @@
+import { useTimeZoneConversion } from '@dhis2/app-runtime'
import { IconClock16, colors } from '@dhis2/ui'
import cx from 'classnames'
import moment from 'moment'
@@ -16,6 +17,7 @@ const InterpretationThread = ({
onThreadUpdated,
downloadMenuComponent: DownloadMenu,
}) => {
+ const { fromServerDate } = useTimeZoneConversion()
const focusRef = useRef()
useEffect(() => {
@@ -36,7 +38,9 @@ const InterpretationThread = ({
- {moment(interpretation.created).format('LLL')}
+ {moment(fromServerDate(interpretation.created)).format(
+ 'LLL'
+ )}
{DownloadMenu && (
diff --git a/src/components/Interpretations/InterpretationsUnit/InterpretationList.js b/src/components/Interpretations/InterpretationsUnit/InterpretationList.js
index 22de9c3a0..f16d78514 100644
--- a/src/components/Interpretations/InterpretationsUnit/InterpretationList.js
+++ b/src/components/Interpretations/InterpretationsUnit/InterpretationList.js
@@ -1,3 +1,4 @@
+import { useTimeZoneConversion } from '@dhis2/app-runtime'
import { IconCalendar24, colors, spacers } from '@dhis2/ui'
import moment from 'moment'
import PropTypes from 'prop-types'
@@ -25,6 +26,7 @@ export const InterpretationList = ({
refresh,
disabled,
}) => {
+ const { fromServerDate } = useTimeZoneConversion()
const interpretationsByDate = interpretations.reduce(
(groupedInterpretations, interpretation) => {
const date = interpretation.created.split('T')[0]
@@ -50,7 +52,7 @@ export const InterpretationList = ({
diff --git a/src/components/Interpretations/common/Message/Message.js b/src/components/Interpretations/common/Message/Message.js
index 0253cb5cb..a965d2965 100644
--- a/src/components/Interpretations/common/Message/Message.js
+++ b/src/components/Interpretations/common/Message/Message.js
@@ -1,63 +1,69 @@
+import { useTimeZoneConversion } from '@dhis2/app-runtime'
import { Parser as RichTextParser } from '@dhis2/d2-ui-rich-text'
import { UserAvatar, spacers, colors } from '@dhis2/ui'
import moment from 'moment'
import PropTypes from 'prop-types'
import React from 'react'
-const Message = ({ children, text, created, username }) => (
- -
-
-
- {username}
-
-
-
- {text}
-
- {children}
-
-
-)
+ .footer {
+ display: flex;
+ flex-direction: column;
+ align-items: flex-start;
+ gap: ${spacers.dp8};
+ }
+ `}
+
+ )
+}
Message.propTypes = {
children: PropTypes.node.isRequired,
From f27bc38e5cf47840971eb685f0ee705f174eadc0 Mon Sep 17 00:00:00 2001
From: HendrikThePendric
Date: Tue, 5 Sep 2023 15:34:38 +0200
Subject: [PATCH 2/4] fix: show warning text below RichTextEditor when unable
to show snapshot (DHIS2-15781)
---
i18n/en.pot | 7 ++-
src/__demo__/InterpretationsUnit.stories.js | 51 +++++++++++++++++++
.../InterpretationsUnit/InterpretationForm.js | 9 ++++
.../InterpretationsUnit.js | 8 +++
.../common/RichTextEditor/RichTextEditor.js | 9 +++-
5 files changed, 80 insertions(+), 4 deletions(-)
create mode 100644 src/__demo__/InterpretationsUnit.stories.js
diff --git a/i18n/en.pot b/i18n/en.pot
index 52645c02d..bfd246658 100644
--- a/i18n/en.pot
+++ b/i18n/en.pot
@@ -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-07-06T08:30:33.216Z\n"
-"PO-Revision-Date: 2023-07-06T08:30:33.216Z\n"
+"POT-Creation-Date: 2023-09-27T14:15:13.876Z\n"
+"PO-Revision-Date: 2023-09-27T14:15:13.876Z\n"
msgid "view only"
msgstr "view only"
@@ -374,6 +374,9 @@ msgstr "Hide interpretation"
msgid "Write an interpretation"
msgstr "Write an interpretation"
+msgid "Other people viewing this interpretation in the future may see more data."
+msgstr "Other people viewing this interpretation in the future may see more data."
+
msgid "Post interpretation"
msgstr "Post interpretation"
diff --git a/src/__demo__/InterpretationsUnit.stories.js b/src/__demo__/InterpretationsUnit.stories.js
new file mode 100644
index 000000000..f1c786f57
--- /dev/null
+++ b/src/__demo__/InterpretationsUnit.stories.js
@@ -0,0 +1,51 @@
+import { CustomDataProvider } from '@dhis2/app-runtime'
+import { storiesOf } from '@storybook/react'
+import React from 'react'
+import { InterpretationsUnit } from '../components/Interpretations/InterpretationsUnit/index.js'
+
+storiesOf('IntepretationsUnit', module).add('Default', () => {
+ return (
+
+
+
+ )
+})
+
+storiesOf('IntepretationsUnit', module).add(
+ 'With no time dimensions warning',
+ () => {
+ return (
+
+
+
+ )
+ }
+)
diff --git a/src/components/Interpretations/InterpretationsUnit/InterpretationForm.js b/src/components/Interpretations/InterpretationsUnit/InterpretationForm.js
index 1fa8b471d..2b7e9d02c 100644
--- a/src/components/Interpretations/InterpretationsUnit/InterpretationForm.js
+++ b/src/components/Interpretations/InterpretationsUnit/InterpretationForm.js
@@ -14,6 +14,7 @@ export const InterpretationForm = ({
id,
currentUser,
disabled,
+ showNoTimeDimensionHelpText,
onSave,
}) => {
const [showRichTextEditor, setShowRichTextEditor] = useState(false)
@@ -51,6 +52,13 @@ export const InterpretationForm = ({
inputPlaceholder={inputPlaceholder}
onChange={setInterpretationText}
value={interpretationText}
+ helpText={
+ showNoTimeDimensionHelpText
+ ? i18n.t(
+ 'Other people viewing this interpretation in the future may see more data.'
+ )
+ : undefined
+ }
/>
) : (
-
+
Date: Thu, 6 Jul 2023 09:51:41 +0200
Subject: [PATCH 3/4] fix: interpretations modal height (DHIS2-15558)
---
.../InterpretationModal/InterpretationModal.js | 8 +++++---
.../InterpretationModal/InterpretationThread.js | 13 ++++++++-----
2 files changed, 13 insertions(+), 8 deletions(-)
diff --git a/src/components/Interpretations/InterpretationModal/InterpretationModal.js b/src/components/Interpretations/InterpretationModal/InterpretationModal.js
index 4f02eaefa..6853ed4ed 100644
--- a/src/components/Interpretations/InterpretationModal/InterpretationModal.js
+++ b/src/components/Interpretations/InterpretationModal/InterpretationModal.js
@@ -24,14 +24,14 @@ const modalCSS = css.resolve`
max-width: calc(100vw - 128px) !important;
max-height: calc(100vh - 128px) !important;
width: auto !important;
- height: auto !important;
+ height: calc(100vw - 128px) !important;
overflow-y: hidden;
}
aside.hidden {
display: none;
}
aside > :global(div) > :global(div) {
- max-height: none;
+ height: 100%;
}
`
@@ -39,6 +39,7 @@ function getModalContentCSS(width) {
return css.resolve`
div {
width: ${width}px;
+ overflow-y: visible;
}
`
}
@@ -216,12 +217,14 @@ const InterpretationModal = ({
.container {
display: flex;
flex-direction: column;
+ height: 100%;
}
.row {
display: flex;
flex-direction: row;
gap: 16px;
+ height: 100%;
}
.visualisation-wrap {
@@ -233,7 +236,6 @@ const InterpretationModal = ({
padding-right: ${spacers.dp4};
flex-basis: 300px;
flex-shrink: 0;
- overflow-y: auto;
}
`}
diff --git a/src/components/Interpretations/InterpretationModal/InterpretationThread.js b/src/components/Interpretations/InterpretationModal/InterpretationThread.js
index f1d5779e2..ec4a8b624 100644
--- a/src/components/Interpretations/InterpretationModal/InterpretationThread.js
+++ b/src/components/Interpretations/InterpretationModal/InterpretationThread.js
@@ -80,9 +80,17 @@ const InterpretationThread = ({
)}
+ onThreadUpdated(true)}
+ focusRef={focusRef}
+ />