From 4baf32b2bf749a7bcc7ec995d77590e76a7439ee Mon Sep 17 00:00:00 2001 From: HendrikThePendric Date: Tue, 5 Sep 2023 15:34:38 +0200 Subject: [PATCH 1/9] fix: show warning text below RichTextEditor when unable to show snapshot --- src/__demo__/RichTextEditor.stories.js | 28 +++++++++++++++++++ .../InterpretationsUnit/InterpretationForm.js | 9 ++++++ .../InterpretationsUnit.js | 7 +++++ .../common/RichTextEditor/RichTextEditor.js | 10 +++++-- 4 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 src/__demo__/RichTextEditor.stories.js diff --git a/src/__demo__/RichTextEditor.stories.js b/src/__demo__/RichTextEditor.stories.js new file mode 100644 index 000000000..e4b669cd7 --- /dev/null +++ b/src/__demo__/RichTextEditor.stories.js @@ -0,0 +1,28 @@ +import { CustomDataProvider } from '@dhis2/app-runtime' +import { storiesOf } from '@storybook/react' +import React, { useState } from 'react' +import { RichTextEditor } from '../components/Interpretations/common/index.js' + +storiesOf('RichTextEditor', module).add('Default', () => { + const [value, setValue] = useState('') + + return ( + + + + ) +}) + +storiesOf('RichTextEditor', module).add('Long warning text', () => { + const [value, setValue] = useState('') + + return ( + + + + ) +}) diff --git a/src/components/Interpretations/InterpretationsUnit/InterpretationForm.js b/src/components/Interpretations/InterpretationsUnit/InterpretationForm.js index 1fa8b471d..9babb1ec2 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, + showNoTimeDimensionWarning, onSave, }) => { const [showRichTextEditor, setShowRichTextEditor] = useState(false) @@ -51,6 +52,13 @@ export const InterpretationForm = ({ inputPlaceholder={inputPlaceholder} onChange={setInterpretationText} value={interpretationText} + warningText={ + showNoTimeDimensionWarning + ? i18n.t( + 'Unable to create a snapshot of this visualization, because it contains no time dimension. Beware that others viewing this interpretation in the future may see more data than currently available.' + ) + : undefined + } />