From 163abf60326a97248daa019c65b4658c78701780 Mon Sep 17 00:00:00 2001 From: Jen Jones Arnesen Date: Mon, 4 Mar 2024 14:47:55 +0100 Subject: [PATCH 1/2] feat: update interpretations component so it can be used in dashboard items (#1510) --- i18n/en.pot | 9 ++++-- .../InterpretationThread.js | 18 ++++++++++- .../InterpretationModal/index.js | 1 + .../InterpretationsUnit/InterpretationList.js | 5 +++ .../InterpretationsUnit.js | 3 ++ .../common/Interpretation/Interpretation.js | 32 ++++++++++++++++++- src/index.js | 7 ++-- 7 files changed, 68 insertions(+), 7 deletions(-) diff --git a/i18n/en.pot b/i18n/en.pot index bfd246658..846edbd29 100644 --- a/i18n/en.pot +++ b/i18n/en.pot @@ -400,12 +400,15 @@ msgstr "Unlike" msgid "Like" msgstr "Like" -msgid "Share" -msgstr "Share" - msgid "See interpretation" msgstr "See interpretation" +msgid "Open in app" +msgstr "Open in app" + +msgid "Share" +msgstr "Share" + msgid "Manage sharing" msgstr "Manage sharing" diff --git a/src/components/Interpretations/InterpretationModal/InterpretationThread.js b/src/components/Interpretations/InterpretationModal/InterpretationThread.js index 03686cd7b..fd7b52e00 100644 --- a/src/components/Interpretations/InterpretationModal/InterpretationThread.js +++ b/src/components/Interpretations/InterpretationModal/InterpretationThread.js @@ -16,6 +16,7 @@ const InterpretationThread = ({ initialFocus, onThreadUpdated, downloadMenuComponent: DownloadMenu, + dashboardRedirectUrl, }) => { const { fromServerDate } = useTimeZoneConversion() const focusRef = useRef() @@ -34,7 +35,12 @@ const InterpretationThread = ({ ) return ( -
+
{moment(fromServerDate(interpretation.created)).format('LLL')} @@ -53,6 +59,7 @@ const InterpretationThread = ({ } onUpdated={() => onThreadUpdated(true)} onDeleted={onInterpretationDeleted} + dashboardRedirectUrl={dashboardRedirectUrl} isInThread={true} />
@@ -83,6 +90,10 @@ const InterpretationThread = ({ scroll-behavior: smooth; } + .dashboard .thread { + overflow-y: hidden; + } + .container { position: relative; overflow: auto; @@ -91,6 +102,10 @@ const InterpretationThread = ({ flex-direction: column; } + .container.dashboard { + max-height: none; + } + .container.fetching::before { content: ''; position: absolute; @@ -151,6 +166,7 @@ InterpretationThread.propTypes = { fetching: PropTypes.bool.isRequired, interpretation: PropTypes.object.isRequired, onInterpretationDeleted: PropTypes.func.isRequired, + dashboardRedirectUrl: PropTypes.string, downloadMenuComponent: PropTypes.oneOfType([ PropTypes.object, PropTypes.func, diff --git a/src/components/Interpretations/InterpretationModal/index.js b/src/components/Interpretations/InterpretationModal/index.js index 8ff513ae2..6e1b43713 100644 --- a/src/components/Interpretations/InterpretationModal/index.js +++ b/src/components/Interpretations/InterpretationModal/index.js @@ -1 +1,2 @@ export { InterpretationModal } from './InterpretationModal.js' +export { InterpretationThread } from './InterpretationThread.js' diff --git a/src/components/Interpretations/InterpretationsUnit/InterpretationList.js b/src/components/Interpretations/InterpretationsUnit/InterpretationList.js index f16d78514..7a63175e1 100644 --- a/src/components/Interpretations/InterpretationsUnit/InterpretationList.js +++ b/src/components/Interpretations/InterpretationsUnit/InterpretationList.js @@ -25,6 +25,7 @@ export const InterpretationList = ({ onReplyIconClick, refresh, disabled, + dashboardRedirectUrl, }) => { const { fromServerDate } = useTimeZoneConversion() const interpretationsByDate = interpretations.reduce( @@ -68,6 +69,9 @@ export const InterpretationList = ({ onDeleted={refresh} onUpdated={refresh} disabled={disabled} + dashboardRedirectUrl={ + dashboardRedirectUrl + } /> ))} @@ -117,5 +121,6 @@ InterpretationList.propTypes = { refresh: PropTypes.func.isRequired, onInterpretationClick: PropTypes.func.isRequired, onReplyIconClick: PropTypes.func.isRequired, + dashboardRedirectUrl: PropTypes.string, disabled: PropTypes.bool, } diff --git a/src/components/Interpretations/InterpretationsUnit/InterpretationsUnit.js b/src/components/Interpretations/InterpretationsUnit/InterpretationsUnit.js index 8acb12d7b..df03d7d41 100644 --- a/src/components/Interpretations/InterpretationsUnit/InterpretationsUnit.js +++ b/src/components/Interpretations/InterpretationsUnit/InterpretationsUnit.js @@ -49,6 +49,7 @@ export const InterpretationsUnit = forwardRef( onReplyIconClick, disabled, renderId, + dashboardRedirectUrl, }, ref ) => { @@ -133,6 +134,7 @@ export const InterpretationsUnit = forwardRef( onReplyIconClick={onReplyIconClick} refresh={onCompleteAction} disabled={disabled} + dashboardRedirectUrl={dashboardRedirectUrl} /> )} @@ -194,6 +196,7 @@ InterpretationsUnit.propTypes = { currentUser: PropTypes.object.isRequired, id: PropTypes.string.isRequired, type: PropTypes.string.isRequired, + dashboardRedirectUrl: PropTypes.string, disabled: PropTypes.bool, renderId: PropTypes.number, visualizationHasTimeDimension: PropTypes.bool, diff --git a/src/components/Interpretations/common/Interpretation/Interpretation.js b/src/components/Interpretations/common/Interpretation/Interpretation.js index cd6965dd9..caf15a273 100644 --- a/src/components/Interpretations/common/Interpretation/Interpretation.js +++ b/src/components/Interpretations/common/Interpretation/Interpretation.js @@ -6,6 +6,8 @@ import { IconShare16, IconThumbUp16, IconEdit16, + IconLaunch16, + IconView16, } from '@dhis2/ui' import PropTypes from 'prop-types' import React, { useState } from 'react' @@ -27,6 +29,7 @@ export const Interpretation = ({ onDeleted, disabled, onReplyIconClick, + dashboardRedirectUrl, isInThread, }) => { const [isUpdateMode, setIsUpdateMode] = useState(false) @@ -36,7 +39,9 @@ export const Interpretation = ({ currentUser, onComplete: onUpdated, }) - const shouldShowButton = !!onClick && !disabled + const shouldShowButton = Boolean( + !!onClick && !disabled & !dashboardRedirectUrl + ) const interpretationAccess = getInterpretationAccess( interpretation, @@ -56,6 +61,12 @@ export const Interpretation = ({ } } + // Maps still uses old url style /?id= instead of hash + const getAppInterpretationUrl = () => + dashboardRedirectUrl.includes('?') + ? `${dashboardRedirectUrl}&interpretationId=${interpretation.id}` + : `${dashboardRedirectUrl}?interpretationId=${interpretation.id}` + return isUpdateMode ? ( setIsUpdateMode(false)} @@ -97,6 +108,24 @@ export const Interpretation = ({ dataTest="interpretation-reply-button" viewOnly={isInThread && !interpretationAccess.comment} /> + {dashboardRedirectUrl && !isInThread && ( + onClick(interpretation.id)} + dataTest="interpretation-view-button" + /> + )} + {dashboardRedirectUrl && ( + + window.open(getAppInterpretationUrl(), '_blank') + } + dataTest="interpretation-launch-in-app-button" + /> + )} {interpretationAccess.share && ( Date: Mon, 4 Mar 2024 13:55:08 +0000 Subject: [PATCH 2/2] chore(release): cut 26.4.0 [skip ci] # [26.4.0](https://github.com/dhis2/analytics/compare/v26.3.1...v26.4.0) (2024-03-04) ### Features * update interpretations component so it can be used in dashboard items ([#1510](https://github.com/dhis2/analytics/issues/1510)) ([163abf6](https://github.com/dhis2/analytics/commit/163abf60326a97248daa019c65b4658c78701780)) --- CHANGELOG.md | 7 +++++++ package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6b2dadd7b..1b3c67239 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +# [26.4.0](https://github.com/dhis2/analytics/compare/v26.3.1...v26.4.0) (2024-03-04) + + +### Features + +* update interpretations component so it can be used in dashboard items ([#1510](https://github.com/dhis2/analytics/issues/1510)) ([163abf6](https://github.com/dhis2/analytics/commit/163abf60326a97248daa019c65b4658c78701780)) + ## [26.3.1](https://github.com/dhis2/analytics/compare/v26.3.0...v26.3.1) (2024-02-28) diff --git a/package.json b/package.json index a6e953aa4..f45c63d43 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@dhis2/analytics", - "version": "26.3.1", + "version": "26.4.0", "main": "./build/cjs/index.js", "module": "./build/es/index.js", "exports": {