From 7880f7e9ed2a39da4b2ccc95e44971ce17b8aa01 Mon Sep 17 00:00:00 2001 From: stefano bovio Date: Thu, 29 Jul 2021 16:38:00 +0200 Subject: [PATCH] Add overlay panel for detail viewer (#392) --- .../components/ActionNavbar/ActionNavbar.jsx | 5 ++-- .../client/js/plugins/ActionNavbar.jsx | 21 ++++++++++++----- .../client/js/plugins/DetailViewer.jsx | 6 ++--- .../client/js/plugins/ViewerLayout.jsx | 13 +++++++++++ .../client/js/selectors/resource.js | 4 ++++ .../static/mapstore/configs/localConfig.json | 12 ++++------ .../client/themes/geonode/less/_menu.less | 7 ++++++ .../client/themes/geonode/less/ms-theme.less | 23 +++++++++++++++++++ 8 files changed, 72 insertions(+), 19 deletions(-) diff --git a/geonode_mapstore_client/client/js/components/ActionNavbar/ActionNavbar.jsx b/geonode_mapstore_client/client/js/components/ActionNavbar/ActionNavbar.jsx index e96a142741..d9c59d0889 100644 --- a/geonode_mapstore_client/client/js/components/ActionNavbar/ActionNavbar.jsx +++ b/geonode_mapstore_client/client/js/components/ActionNavbar/ActionNavbar.jsx @@ -105,7 +105,8 @@ const ActionNavbar = forwardRef(({ formatHref, cfg, variant, - size + size, + children }, ref) => { return ( @@ -130,7 +131,7 @@ const ActionNavbar = forwardRef(({ size={size} /> } - + {children} { rightItems.length > 0 && diff --git a/geonode_mapstore_client/client/js/plugins/ActionNavbar.jsx b/geonode_mapstore_client/client/js/plugins/ActionNavbar.jsx index 1c786cf07f..a6bb2a7df2 100644 --- a/geonode_mapstore_client/client/js/plugins/ActionNavbar.jsx +++ b/geonode_mapstore_client/client/js/plugins/ActionNavbar.jsx @@ -12,9 +12,11 @@ import { createPlugin } from '@mapstore/framework/utils/PluginsUtils'; import { connect } from 'react-redux'; import { createSelector } from 'reselect'; import ActionNavbar from '@js/components/ActionNavbar'; +import FaIcon from '@js/components/FaIcon'; import usePluginItems from '@js/hooks/usePluginItems'; -import { getResourcePerms, canAddResource } from '@js/selectors/resource'; +import { getResourcePerms, canAddResource, getResourceData } from '@js/selectors/resource'; import { hasPermissionsTo, reduceArrayRecursive } from '@js/utils/MenuUtils'; +import { getResourceTypesInfo } from '@js/utils/ResourceUtils'; function checkResourcePerms(menuItem, resourcePerms) { if (menuItem.type && menuItem.perms) { @@ -26,9 +28,12 @@ function checkResourcePerms(menuItem, resourcePerms) { function ActionNavbarPlugin({ items, leftMenuItems, - resourcePerms + resourcePerms, + resource }, context) { + const types = getResourceTypesInfo(); + const { icon } = types[resource?.resource_type] || {}; const { loadedPlugins } = context; const configuredItems = usePluginItems({ items, loadedPlugins }); @@ -51,7 +56,9 @@ function ActionNavbarPlugin({ leftItems={leftItems} variant="default" size="sm" - /> + > +

{icon && }{' '}{resource?.title}

+ ); } @@ -68,11 +75,13 @@ ActionNavbarPlugin.defaultProps = { const ConnectedActionNavbarPlugin = connect( createSelector([ getResourcePerms, - canAddResource - ], (resourcePerms, userCanAddResource) => ({ + canAddResource, + getResourceData + ], (resourcePerms, userCanAddResource, resource) => ({ resourcePerms: (resourcePerms.length > 0 ) ? resourcePerms : ((userCanAddResource) - ? [ "change_resourcebase"] : [] ) + ? [ "change_resourcebase"] : [] ), + resource })) )(ActionNavbarPlugin); diff --git a/geonode_mapstore_client/client/js/plugins/DetailViewer.jsx b/geonode_mapstore_client/client/js/plugins/DetailViewer.jsx index ffd1343d75..b72766dc69 100644 --- a/geonode_mapstore_client/client/js/plugins/DetailViewer.jsx +++ b/geonode_mapstore_client/client/js/plugins/DetailViewer.jsx @@ -114,11 +114,11 @@ function DetailViewer({ height: '100%' }}> - { !enabled && )} +
+ {configuredItems + .filter(({ target }) => target === 'rightOverlay') + .map(({ Component, name }) => )} +