From d9883b1435d01f74755cef0c31900f5c87d15c10 Mon Sep 17 00:00:00 2001 From: Thomas Zemp Date: Tue, 9 Feb 2021 20:17:28 +0100 Subject: [PATCH 1/5] feat: handle dashboard views with system settings [DHIS2-7630] conditions ItemHeaderButtons display based on system settings --- src/api/settings.js | 12 +++- .../VisualizationItem/ItemHeaderButtons.js | 66 +++++++++++++------ .../__tests__/ItemHeaderButtons.spec.js | 13 ++++ 3 files changed, 69 insertions(+), 22 deletions(-) diff --git a/src/api/settings.js b/src/api/settings.js index 6ed0672cd..7de570d90 100644 --- a/src/api/settings.js +++ b/src/api/settings.js @@ -1,9 +1,19 @@ export const DEFAULT_SETTINGS = { displayNameProperty: 'displayName', + keyDashboardContextMenuItemOpenInRelevantApp: true, + keyDashboardContextMenuItemShowInterpretationsAndDetails: true, + keyDashboardContextMenuItemSwitchViewType: true, + keyDashboardContextMenuItemViewFullscreen: true, keyGatherAnalyticalObjectStatisticsInDashboardViews: false, } -const SYSTEM_SETTINGS = ['keyGatherAnalyticalObjectStatisticsInDashboardViews'] +const SYSTEM_SETTINGS = [ + 'keyDashboardContextMenuItemOpenInRelevantApp', + 'keyDashboardContextMenuItemShowInterpretationsAndDetails', + 'keyDashboardContextMenuItemSwitchViewType', + 'keyDashboardContextMenuItemViewFullscreen', + 'keyGatherAnalyticalObjectStatisticsInDashboardViews', +] const query = { resource: 'systemSettings', diff --git a/src/components/Item/VisualizationItem/ItemHeaderButtons.js b/src/components/Item/VisualizationItem/ItemHeaderButtons.js index cb5f8576d..c35bdb8a0 100644 --- a/src/components/Item/VisualizationItem/ItemHeaderButtons.js +++ b/src/components/Item/VisualizationItem/ItemHeaderButtons.js @@ -31,6 +31,7 @@ import { hasMapView, getAppName, } from '../../../modules/itemTypes' +import { useSystemSettings } from '../../SystemSettingsProvider' const iconFill = { fill: colors.grey600 } @@ -41,6 +42,8 @@ const ItemHeaderButtons = props => { const { item, visualization, onSelectActiveType, activeType } = props + const { settings } = useSystemSettings() + const isTrackerType = isTrackerDomainType(item.type) const onViewTable = () => { @@ -117,6 +120,18 @@ const ItemHeaderButtons = props => { const buttonRef = createRef() + const fullscreenAllowed = + props.fullscreenSupported && + settings.keyDashboardContextMenuItemViewFullscreen + + if ( + !settings.keyDashboardContextMenuItemOpenInRelevantApp && + !settings.keyDashboardContextMenuItemShowInterpretationsAndDetails && + !settings.keyDashboardContextMenuItemSwitchViewType && + !fullscreenAllowed + ) { + return null + } return props.isFullscreen ? ( + + + + + + + } + label="Open in Data Visualizer app" + target="_blank" + /> + } + label="Show interpretations and details" + onClick={[Function]} + /> + } + label="View fullscreen" + onClick={[Function]} + /> + + + +`; + exports[`renders correctly when fullscreen 1`] = `