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: update interpretations component so it can be used in dashboard items #1510

Merged
merged 27 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
3928ec2
feat: inline interpretations reply for dashboard
jenniferarnesen Jun 19, 2023
3f5f08a
feat: open in app button
jenniferarnesen Jun 20, 2023
f9599aa
fix: move InlineReplyForm to dashboard app
jenniferarnesen Jun 22, 2023
1af2137
fix: explicitly list props and use only appUrl for dashboard config
jenniferarnesen Jun 23, 2023
d4583eb
fix: remove view button when in thread
jenniferarnesen Jun 23, 2023
08c44e9
fix: disablescrollbox not needed, and clean up exports
jenniferarnesen Jun 23, 2023
8b56cb0
fix: restore original
jenniferarnesen Jun 23, 2023
1783a20
fix: onInterpretationClick is back
jenniferarnesen Jun 23, 2023
440eb7e
fix: a little more cleanup
jenniferarnesen Jun 23, 2023
0915a84
Merge branch 'master' into feat/interpretations-for-dashboard
jenniferarnesen Jun 23, 2023
97621f8
chore: disable scrollbox when inline
jenniferarnesen Jun 27, 2023
6c3758f
Merge branch 'feat/interpretations-for-dashboard' of github.com:dhis2…
jenniferarnesen Jun 27, 2023
ce92c44
chore: rename appUrl to dashboardRedirectUrl for slightly better clarity
jenniferarnesen Jun 27, 2023
96aea30
fix: rename to inThreadView
jenniferarnesen Jun 28, 2023
109278c
Merge branch 'master' into feat/interpretations-for-dashboard
jenniferarnesen Aug 7, 2023
6d47aa8
fix: overflow property was causing the reply update and cancel button…
jenniferarnesen Aug 18, 2023
574ef6e
Merge branch 'master' into feat/interpretations-for-dashboard
jenniferarnesen Dec 20, 2023
72bc81d
chore: updates due to changes in scrolling
jenniferarnesen Dec 20, 2023
0d33d0a
fix: interpretation url adjustment for maps urls
jenniferarnesen Dec 20, 2023
11df583
fix: remove unused prop
jenniferarnesen Dec 21, 2023
1a8a917
chore: dont limit height for replies. Parent scroll will handle scrol…
jenniferarnesen Dec 21, 2023
d85fefa
fix: preserve paragraphs in interpretation and replies
jenniferarnesen Dec 21, 2023
895b955
Merge branch 'master' into feat/interpretations-for-dashboard
jenniferarnesen Jan 2, 2024
3072e4f
Merge branch 'feat/interpretations-for-dashboard' of github.com:dhis2…
jenniferarnesen Jan 4, 2024
286f57d
Merge branch 'master' into feat/interpretations-for-dashboard
edoardo Mar 1, 2024
b449818
fix: compute url only when needed (used in dashboard app)
edoardo Mar 1, 2024
2ff0fc3
fix: use correct variable for conditionally render the Share button
edoardo Mar 4, 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
9 changes: 6 additions & 3 deletions i18n/en.pot
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const InterpretationThread = ({
initialFocus,
onThreadUpdated,
downloadMenuComponent: DownloadMenu,
dashboardRedirectUrl,
}) => {
const { fromServerDate } = useTimeZoneConversion()
const focusRef = useRef()
Expand All @@ -34,7 +35,12 @@ const InterpretationThread = ({
)

return (
<div className={cx('container', { fetching })}>
<div
className={cx('container', {
fetching,
dashboard: !!dashboardRedirectUrl,
})}
>
<div className={'title'}>
<IconClock16 color={colors.grey700} />
{moment(fromServerDate(interpretation.created)).format('LLL')}
Expand All @@ -53,6 +59,7 @@ const InterpretationThread = ({
}
onUpdated={() => onThreadUpdated(true)}
onDeleted={onInterpretationDeleted}
dashboardRedirectUrl={dashboardRedirectUrl}
isInThread={true}
/>
<div className={'comments'}>
Expand Down Expand Up @@ -83,6 +90,10 @@ const InterpretationThread = ({
scroll-behavior: smooth;
}

.dashboard .thread {
overflow-y: hidden;
}

.container {
position: relative;
overflow: auto;
Expand All @@ -91,6 +102,10 @@ const InterpretationThread = ({
flex-direction: column;
}

.container.dashboard {
max-height: none;
}

.container.fetching::before {
content: '';
position: absolute;
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export { InterpretationModal } from './InterpretationModal.js'
export { InterpretationThread } from './InterpretationThread.js'
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export const InterpretationList = ({
onReplyIconClick,
refresh,
disabled,
dashboardRedirectUrl,
}) => {
const { fromServerDate } = useTimeZoneConversion()
const interpretationsByDate = interpretations.reduce(
Expand Down Expand Up @@ -68,6 +69,9 @@ export const InterpretationList = ({
onDeleted={refresh}
onUpdated={refresh}
disabled={disabled}
dashboardRedirectUrl={
dashboardRedirectUrl
}
/>
))}
</ol>
Expand Down Expand Up @@ -117,5 +121,6 @@ InterpretationList.propTypes = {
refresh: PropTypes.func.isRequired,
onInterpretationClick: PropTypes.func.isRequired,
onReplyIconClick: PropTypes.func.isRequired,
dashboardRedirectUrl: PropTypes.string,
disabled: PropTypes.bool,
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export const InterpretationsUnit = forwardRef(
onReplyIconClick,
disabled,
renderId,
dashboardRedirectUrl,
},
ref
) => {
Expand Down Expand Up @@ -133,6 +134,7 @@ export const InterpretationsUnit = forwardRef(
onReplyIconClick={onReplyIconClick}
refresh={onCompleteAction}
disabled={disabled}
dashboardRedirectUrl={dashboardRedirectUrl}
/>
</>
)}
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import {
IconShare16,
IconThumbUp16,
IconEdit16,
IconLaunch16,
IconView16,
} from '@dhis2/ui'
import PropTypes from 'prop-types'
import React, { useState } from 'react'
Expand All @@ -27,6 +29,7 @@ export const Interpretation = ({
onDeleted,
disabled,
onReplyIconClick,
dashboardRedirectUrl,
isInThread,
}) => {
const [isUpdateMode, setIsUpdateMode] = useState(false)
Expand All @@ -36,7 +39,9 @@ export const Interpretation = ({
currentUser,
onComplete: onUpdated,
})
const shouldShowButton = !!onClick && !disabled
const shouldShowButton = Boolean(
!!onClick && !disabled & !dashboardRedirectUrl
)

const interpretationAccess = getInterpretationAccess(
interpretation,
Expand All @@ -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 ? (
<InterpretationUpdateForm
close={() => setIsUpdateMode(false)}
Expand Down Expand Up @@ -97,6 +108,24 @@ export const Interpretation = ({
dataTest="interpretation-reply-button"
viewOnly={isInThread && !interpretationAccess.comment}
/>
{dashboardRedirectUrl && !isInThread && (
<MessageIconButton
tooltipContent={i18n.t('See interpretation')}
iconComponent={IconView16}
onClick={() => onClick(interpretation.id)}
dataTest="interpretation-view-button"
/>
)}
{dashboardRedirectUrl && (
<MessageIconButton
tooltipContent={i18n.t('Open in app')}
iconComponent={IconLaunch16}
onClick={() =>
window.open(getAppInterpretationUrl(), '_blank')
}
dataTest="interpretation-launch-in-app-button"
/>
)}
{interpretationAccess.share && (
<MessageIconButton
iconComponent={IconShare16}
Expand Down Expand Up @@ -153,6 +182,7 @@ Interpretation.propTypes = {
onDeleted: PropTypes.func.isRequired,
onReplyIconClick: PropTypes.func.isRequired,
onUpdated: PropTypes.func.isRequired,
dashboardRedirectUrl: PropTypes.string,
disabled: PropTypes.bool,
isInThread: PropTypes.bool,
onClick: PropTypes.func,
Expand Down
7 changes: 5 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,11 @@ export { default as LegendKey } from './components/LegendKey/LegendKey.js'

export { default as AboutAOUnit } from './components/AboutAOUnit/AboutAOUnit.js'

export { InterpretationsUnit } from './components/Interpretations/InterpretationsUnit/InterpretationsUnit.js'
export { InterpretationModal } from './components/Interpretations/InterpretationModal/InterpretationModal.js'
export { InterpretationsUnit } from './components/Interpretations/InterpretationsUnit/index.js'
export {
InterpretationModal,
InterpretationThread,
} from './components/Interpretations/InterpretationModal/index.js'

export * from './components/Toolbar/index.js'

Expand Down
Loading