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/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/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": { diff --git a/src/components/Interpretations/InterpretationModal/InterpretationThread.js b/src/components/Interpretations/InterpretationModal/InterpretationThread.js index e3473d2fd..eb5a3a6d3 100644 --- a/src/components/Interpretations/InterpretationModal/InterpretationThread.js +++ b/src/components/Interpretations/InterpretationModal/InterpretationThread.js @@ -17,6 +17,7 @@ const InterpretationThread = ({ initialFocus, onThreadUpdated, downloadMenuComponent: DownloadMenu, + dashboardRedirectUrl, }) => { const { fromServerDate } = useTimeZoneConversion() const focusRef = useRef() @@ -35,7 +36,12 @@ const InterpretationThread = ({ ) return ( -
+
{moment(fromServerDate(interpretation.created)).format('LLL')} @@ -55,6 +61,7 @@ const InterpretationThread = ({ } onUpdated={() => onThreadUpdated(true)} onDeleted={onInterpretationDeleted} + dashboardRedirectUrl={dashboardRedirectUrl} isInThread={true} />
@@ -85,6 +92,10 @@ const InterpretationThread = ({ scroll-behavior: smooth; } + .dashboard .thread { + overflow-y: hidden; + } + .container { position: relative; overflow: auto; @@ -93,6 +104,10 @@ const InterpretationThread = ({ flex-direction: column; } + .container.dashboard { + max-height: none; + } + .container.fetching::before { content: ''; position: absolute; @@ -154,6 +169,7 @@ InterpretationThread.propTypes = { interpretation: PropTypes.object.isRequired, onInterpretationDeleted: PropTypes.func.isRequired, onLikeToggled: 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 3782bb2d1..99c806aaa 100644 --- a/src/components/Interpretations/InterpretationsUnit/InterpretationList.js +++ b/src/components/Interpretations/InterpretationsUnit/InterpretationList.js @@ -26,6 +26,7 @@ export const InterpretationList = ({ onReplyIconClick, refresh, disabled, + dashboardRedirectUrl, }) => { const { fromServerDate } = useTimeZoneConversion() const interpretationsByDate = interpretations.reduce( @@ -70,6 +71,9 @@ export const InterpretationList = ({ onDeleted={refresh} onUpdated={refresh} disabled={disabled} + dashboardRedirectUrl={ + dashboardRedirectUrl + } /> ))} @@ -120,5 +124,6 @@ InterpretationList.propTypes = { onInterpretationClick: PropTypes.func.isRequired, onLikeToggled: 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 f4264101f..33311fceb 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 ) => { @@ -143,6 +144,7 @@ export const InterpretationsUnit = forwardRef( onReplyIconClick={onReplyIconClick} refresh={onCompleteAction} disabled={disabled} + dashboardRedirectUrl={dashboardRedirectUrl} /> )} @@ -204,6 +206,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 545f01d40..8167aa244 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, onLikeToggled, }) => { @@ -41,7 +44,9 @@ export const Interpretation = ({ likedBy, }), }) - const shouldShowButton = !!onClick && !disabled + const shouldShowButton = Boolean( + !!onClick && !disabled & !dashboardRedirectUrl + ) const interpretationAccess = getInterpretationAccess( interpretation, @@ -61,6 +66,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)} @@ -102,6 +113,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 && (