From e8b5d3a1d6c1cf892a421eca81960687528fb357 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=A9mie=20Treff?= Date: Thu, 21 Nov 2024 14:22:07 +0100 Subject: [PATCH] fix: make metadata configurable --- src/bootstrap.tsx | 6 +++++- .../ToolMenu/LayerTree/LayerTreeContextMenu/index.tsx | 11 +++++++---- src/store/layerTree/index.ts | 10 ++++++++-- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/bootstrap.tsx b/src/bootstrap.tsx index d5a7afb0a..83c5dd462 100644 --- a/src/bootstrap.tsx +++ b/src/bootstrap.tsx @@ -97,7 +97,8 @@ import { import { setFeatureInfoActiveCopyTools } from './store/featureInfo'; import { setLayerTreeActiveUploadTools, - setLayerTreeShowLegends + setLayerTreeShowLegends, + setMetadataVisible } from './store/layerTree'; import { setLegal @@ -281,6 +282,9 @@ const setApplicationToStore = async (application?: Application) => { if (tool.name === 'tree' && tool.config.showLegends) { store.dispatch(setLayerTreeShowLegends(tool.config.showLegends)); } + if (tool.name === 'tree' && typeof tool.config.metadataVisible !== 'undefined') { + store.dispatch(setMetadataVisible(tool.config.metadataVisible)); + } }); store.dispatch(setAvailableTools(availableTools)); } diff --git a/src/components/ToolMenu/LayerTree/LayerTreeContextMenu/index.tsx b/src/components/ToolMenu/LayerTree/LayerTreeContextMenu/index.tsx index 7ff1c7352..345f562af 100644 --- a/src/components/ToolMenu/LayerTree/LayerTreeContextMenu/index.tsx +++ b/src/components/ToolMenu/LayerTree/LayerTreeContextMenu/index.tsx @@ -104,6 +104,7 @@ export const LayerTreeContextMenu: React.FC = ({ const allowedEditMode = useAppSelector( state => state.editFeature.userEditMode ); + const metadataVisible = useAppSelector(state => state.layerTree.metadataVisible); const onContextMenuItemClick = (evt: MenuInfo): void => { if (evt?.key.startsWith('downloadLayer')) { @@ -292,10 +293,12 @@ export const LayerTreeContextMenu: React.FC = ({ }); } - dropdownMenuItems.push({ - label: t('LayerTreeContextMenu.layerDetails'), - key: 'layerDetails' - }); + if (metadataVisible) { + dropdownMenuItems.push({ + label: t('LayerTreeContextMenu.layerDetails'), + key: 'layerDetails' + }); + } return (
) { state.showLegends = action.payload; + }, + setMetadataVisible(state, action: PayloadAction) { + state.metadataVisible = action.payload; } } }); @@ -42,7 +47,8 @@ export const slice = createSlice({ export const { setLayerTreeEnabled, setLayerTreeActiveUploadTools, - setLayerTreeShowLegends + setLayerTreeShowLegends, + setMetadataVisible } = slice.actions; export default slice.reducer;