diff --git a/geonode_mapstore_client/client/js/apps/gn-dashboard.js b/geonode_mapstore_client/client/js/apps/gn-dashboard.js index fcedaab487..2e27abc7dd 100644 --- a/geonode_mapstore_client/client/js/apps/gn-dashboard.js +++ b/geonode_mapstore_client/client/js/apps/gn-dashboard.js @@ -11,6 +11,7 @@ import main from '@mapstore/framework/components/app/main'; import MainLoader from '@js/components/MainLoader'; import ViewerRoute from '@js/routes/Viewer'; import Router, { withRoutes } from '@js/components/Router'; +import controls from '@mapstore/framework/reducers/controls'; import security from '@mapstore/framework/reducers/security'; import maptype from '@mapstore/framework/reducers/maptype'; import dashboard from '@mapstore/framework/reducers/dashboard'; @@ -27,7 +28,8 @@ import { setupConfiguration, initializeApp, getPluginsConfiguration, - getPluginsConfigOverride + getPluginsConfigOverride, + addQueryPlugins } from '@js/utils/AppUtils'; import { ResourceTypes } from '@js/utils/ResourceUtils'; import pluginsDefinition, { storeEpicsNamesToExclude, cleanEpics } from '@js/plugins/index'; @@ -73,7 +75,8 @@ document.addEventListener('DOMContentLoaded', function() { onStoreInit, geoNodePageConfig, targetId = 'ms-container', - settings + settings, + query }) => { const appEpics = cleanEpics({ @@ -86,7 +89,10 @@ document.addEventListener('DOMContentLoaded', function() { main({ targetId, appComponent: withRoutes(routes)(ConnectedRouter), - pluginsConfig: getPluginsConfigOverride(getPluginsConfiguration(localConfig.plugins, pluginsConfigKey)), + pluginsConfig: addQueryPlugins( + getPluginsConfigOverride(getPluginsConfiguration(localConfig.plugins, pluginsConfigKey)), + query + ), loaderComponent: MainLoader, pluginsDef: { plugins: { @@ -107,6 +113,7 @@ document.addEventListener('DOMContentLoaded', function() { }, themeCfg: null, appReducers: { + controls, dashboard, gnresource, gnsettings, diff --git a/geonode_mapstore_client/client/js/apps/gn-document.js b/geonode_mapstore_client/client/js/apps/gn-document.js index e1983b1209..4e79c59c26 100644 --- a/geonode_mapstore_client/client/js/apps/gn-document.js +++ b/geonode_mapstore_client/client/js/apps/gn-document.js @@ -10,6 +10,7 @@ import main from '@mapstore/framework/components/app/main'; import ViewerRoute from '@js/routes/Viewer'; import MainLoader from '@js/components/MainLoader'; import Router, { withRoutes } from '@js/components/Router'; +import controls from '@mapstore/framework/reducers/controls'; import security from '@mapstore/framework/reducers/security'; import gnresource from '@js/reducers/gnresource'; import gnsettings from '@js/reducers/gnsettings'; @@ -23,7 +24,8 @@ import { setupConfiguration, initializeApp, getPluginsConfiguration, - getPluginsConfigOverride + getPluginsConfigOverride, + addQueryPlugins } from '@js/utils/AppUtils'; import { ResourceTypes } from '@js/utils/ResourceUtils'; import pluginsDefinition, { storeEpicsNamesToExclude, cleanEpics } from '@js/plugins/index'; @@ -68,7 +70,8 @@ document.addEventListener('DOMContentLoaded', function() { onStoreInit, geoNodePageConfig, targetId = 'ms-container', - settings + settings, + query }) => { const appEpics = cleanEpics({ @@ -81,7 +84,10 @@ document.addEventListener('DOMContentLoaded', function() { main({ targetId, appComponent: withRoutes(routes)(ConnectedRouter), - pluginsConfig: getPluginsConfigOverride(getPluginsConfiguration(localConfig.plugins, pluginsConfigKey)), + pluginsConfig: addQueryPlugins( + getPluginsConfigOverride(getPluginsConfiguration(localConfig.plugins, pluginsConfigKey)), + query + ), loaderComponent: MainLoader, pluginsDef: { plugins: { @@ -99,6 +105,7 @@ document.addEventListener('DOMContentLoaded', function() { }, themeCfg: null, appReducers: { + controls, gnresource, gnsettings, security diff --git a/geonode_mapstore_client/client/js/apps/gn-geostory.js b/geonode_mapstore_client/client/js/apps/gn-geostory.js index 4e2fa88e88..4497636b7c 100644 --- a/geonode_mapstore_client/client/js/apps/gn-geostory.js +++ b/geonode_mapstore_client/client/js/apps/gn-geostory.js @@ -11,6 +11,7 @@ import main from '@mapstore/framework/components/app/main'; import MainLoader from '@js/components/MainLoader'; import ViewerRoute from '@js/routes/Viewer'; import Router, { withRoutes } from '@js/components/Router'; +import controls from '@mapstore/framework/reducers/controls'; import security from '@mapstore/framework/reducers/security'; import maptype from '@mapstore/framework/reducers/maptype'; import geostory from '@mapstore/framework/reducers/geostory'; @@ -29,7 +30,8 @@ import { setupConfiguration, initializeApp, getPluginsConfiguration, - getPluginsConfigOverride + getPluginsConfigOverride, + addQueryPlugins } from '@js/utils/AppUtils'; import { ResourceTypes } from '@js/utils/ResourceUtils'; import pluginsDefinition, { storeEpicsNamesToExclude, cleanEpics } from '@js/plugins/index'; @@ -76,7 +78,8 @@ document.addEventListener('DOMContentLoaded', function() { configEpics, onStoreInit, targetId = 'ms-container', - settings + settings, + query }) => { const appEpics = cleanEpics({ @@ -89,7 +92,10 @@ document.addEventListener('DOMContentLoaded', function() { main({ targetId, appComponent: withRoutes(routes)(ConnectedRouter), - pluginsConfig: getPluginsConfigOverride(getPluginsConfiguration(localConfig.plugins, pluginsConfigKey)), + pluginsConfig: addQueryPlugins( + getPluginsConfigOverride(getPluginsConfiguration(localConfig.plugins, pluginsConfigKey)), + query + ), loaderComponent: MainLoader, pluginsDef: { plugins: { @@ -114,6 +120,7 @@ document.addEventListener('DOMContentLoaded', function() { gnresource, gnsettings, security, + controls, maptype }, appEpics, diff --git a/geonode_mapstore_client/client/js/apps/gn-map.js b/geonode_mapstore_client/client/js/apps/gn-map.js index bf5db43f41..c031e81f23 100644 --- a/geonode_mapstore_client/client/js/apps/gn-map.js +++ b/geonode_mapstore_client/client/js/apps/gn-map.js @@ -49,7 +49,8 @@ import { setupConfiguration, initializeApp, getPluginsConfiguration, - getPluginsConfigOverride + getPluginsConfigOverride, + addQueryPlugins } from '@js/utils/AppUtils'; import { ResourceTypes } from '@js/utils/ResourceUtils'; import { requestResourceConfig } from '@js/actions/gnresource'; @@ -145,7 +146,10 @@ document.addEventListener('DOMContentLoaded', function() { } }, themeCfg: null, - pluginsConfig: getPluginsConfigOverride(getPluginsConfiguration(localConfig.plugins, pluginsConfigKey)), + pluginsConfig: addQueryPlugins( + getPluginsConfigOverride(getPluginsConfiguration(localConfig.plugins, pluginsConfigKey)), + query + ), pluginsDef: { plugins: { ...pluginsDefinition.plugins diff --git a/geonode_mapstore_client/client/js/components/Menu/MenuItem.js b/geonode_mapstore_client/client/js/components/Menu/MenuItem.js index 67e19c1e2f..5005eaee4c 100644 --- a/geonode_mapstore_client/client/js/components/Menu/MenuItem.js +++ b/geonode_mapstore_client/client/js/components/Menu/MenuItem.js @@ -81,6 +81,10 @@ const MenuItem = ({ item, menuItemsProps, containerNode, tabIndex, classItem = ' return
; } + if (type === 'placeholder') { + return ; + } + if (type === 'filter') { const active = castArray(query.f || []).find(value => value === item.id); return ( diff --git a/geonode_mapstore_client/client/js/plugins/ActionNavbar.jsx b/geonode_mapstore_client/client/js/plugins/ActionNavbar.jsx index 543af5d9df..d89f68bce7 100644 --- a/geonode_mapstore_client/client/js/plugins/ActionNavbar.jsx +++ b/geonode_mapstore_client/client/js/plugins/ActionNavbar.jsx @@ -12,7 +12,7 @@ import { connect, createPlugin } from '@mapstore/framework/utils/PluginsUtils'; import { createSelector } from 'reselect'; import ActionNavbar from '@js/components/ActionNavbar'; -import usePluginItems from '@js/hooks/usePluginItems'; +import usePluginItems from '@mapstore/framework/hooks/usePluginItems'; import { getResourcePerms, canAddResource, @@ -41,7 +41,8 @@ function ActionNavbarPlugin( resourcePerms, resource, isDirtyState, - selectedLayerPermissions + selectedLayerPermissions, + variant = 'primary' }, context ) { @@ -113,7 +114,7 @@ function ActionNavbarPlugin( diff --git a/geonode_mapstore_client/client/js/plugins/Share.jsx b/geonode_mapstore_client/client/js/plugins/Share.jsx index a359dc49a9..aaac579daa 100644 --- a/geonode_mapstore_client/client/js/plugins/Share.jsx +++ b/geonode_mapstore_client/client/js/plugins/Share.jsx @@ -40,6 +40,7 @@ import { getResourceTypesInfo } from '@js/utils/ResourceUtils'; import SharePageLink from '@js/plugins/share/SharePageLink'; +import ShareEmbedLink from '@js/plugins/share/ShareEmbedLink'; import { getCurrentResourcePermissionsLoading } from '@js/selectors/resourceservice'; const getEmbedUrl = (resource) => { @@ -152,9 +153,9 @@ function Share({
- } /> - {embedUrl && } />} - {(resourceType === 'document' && !!downloadUrl) && } />} + } /> + {embedUrl && } />} + {(resourceType === 'document' && !!downloadUrl) && } />} {canEdit && <> { const FullScreenButton = tooltip(Button); + const label = enabled ? : ; return ( : } + tooltip={ showText ? undefined : label } variant={variant} size={size} onClick={() => onClick(!enabled)} > - + {showText ? label : } ); }); diff --git a/geonode_mapstore_client/client/js/plugins/share/ShareEmbedLink.jsx b/geonode_mapstore_client/client/js/plugins/share/ShareEmbedLink.jsx new file mode 100644 index 0000000000..05c27cace3 --- /dev/null +++ b/geonode_mapstore_client/client/js/plugins/share/ShareEmbedLink.jsx @@ -0,0 +1,38 @@ +/* + * Copyright 2024, GeoSolutions Sas. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. + */ +import React, { useState } from 'react'; +import { Checkbox } from 'react-bootstrap'; +import SharePageLink from './SharePageLink'; +import Message from '@mapstore/framework/components/I18N/Message'; + +function ShareEmbedLink({ + embedUrl, + label +}) { + const [includeFullscreen, setIncludeFullscreen] = useState(false); + const getEmbedSnippet = () => { + return [ + '' + ].filter(value => value).join(' '); + }; + return ( + + setIncludeFullscreen(!!event.target.checked )}> + + + + ); +} + +export default ShareEmbedLink; diff --git a/geonode_mapstore_client/client/js/plugins/share/SharePageLink.jsx b/geonode_mapstore_client/client/js/plugins/share/SharePageLink.jsx index 2e6e61fa6e..96a81a7771 100644 --- a/geonode_mapstore_client/client/js/plugins/share/SharePageLink.jsx +++ b/geonode_mapstore_client/client/js/plugins/share/SharePageLink.jsx @@ -12,7 +12,7 @@ import FaIcon from '@js/components/FaIcon/FaIcon'; import CopyToClipboard from 'react-copy-to-clipboard'; -function SharePageLink({label, url}) { +function SharePageLink({label, value, children}) { const [copied, setCopied] = useState(false); useEffect(() => { if (copied) { @@ -31,10 +31,10 @@ function SharePageLink({label, url}) { readOnly rel="noopener noreferrer" target="_blank" - value={url} + value={value} /> {!copied && }
+ {children} diff --git a/geonode_mapstore_client/client/js/routes/MapViewer.jsx b/geonode_mapstore_client/client/js/routes/MapViewer.jsx index 40bf0f3bb1..772e47039c 100644 --- a/geonode_mapstore_client/client/js/routes/MapViewer.jsx +++ b/geonode_mapstore_client/client/js/routes/MapViewer.jsx @@ -54,7 +54,11 @@ function MapViewerRoute({ const selectPluginsConfig = () => { if (hasViewer === true && embed) { - return getPluginsConfiguration('desktop', viewerPluginsConfig); + return [ + ...getPluginsConfiguration(name, propPluginsConfig) + .filter((plugin) => !!plugin.mandatory), + ...getPluginsConfiguration('desktop', viewerPluginsConfig) + ]; } if (hasViewer === true && (resource?.pk === pk || pk === 'new')) { return uniqBy([ diff --git a/geonode_mapstore_client/client/js/utils/AppUtils.js b/geonode_mapstore_client/client/js/utils/AppUtils.js index 2832e8420a..610dd04b2e 100644 --- a/geonode_mapstore_client/client/js/utils/AppUtils.js +++ b/geonode_mapstore_client/client/js/utils/AppUtils.js @@ -350,3 +350,39 @@ export const getPluginsConfigOverride = (pluginsConfig) => isFunction(apiPlugins : isObject(apiPluginsConfig) ? apiPluginsConfig : pluginsConfig; + +/* this function adds plugin based on the current query, used mainly for embed pages*/ +export const addQueryPlugins = (pluginsConfig, query) => { + if (isArray(pluginsConfig)) { + return [ + ...(query?.allowFullscreen === 'true' + ? [{ + mandatory: true, // needed for custom viewers + name: 'FullScreen', + cfg: { + showText: true + } + }, + { + mandatory: true, // needed for custom viewers + name: 'ActionNavbar', + cfg: { + containerPosition: 'footer', + variant: 'default', + leftMenuItems: [{ + type: 'placeholder' + }], + rightMenuItems: [ + { + type: 'plugin', + name: 'FullScreen', + size: 'xs' + } + ] + } + }] : []), + ...pluginsConfig + ]; + } + return pluginsConfig; +}; diff --git a/geonode_mapstore_client/client/js/utils/__tests__/AppUtils-test.js b/geonode_mapstore_client/client/js/utils/__tests__/AppUtils-test.js new file mode 100644 index 0000000000..331883a904 --- /dev/null +++ b/geonode_mapstore_client/client/js/utils/__tests__/AppUtils-test.js @@ -0,0 +1,42 @@ +/* + * Copyright 2024, GeoSolutions Sas. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. + */ + +import expect from 'expect'; +import { addQueryPlugins } from '../AppUtils'; + +describe('Test AppUtils', () => { + it('addQueryPlugins', () => { + expect(addQueryPlugins({ map_viewer: [{ name: 'Map' }] })).toEqual({ map_viewer: [{ name: 'Map' }] }); + expect(addQueryPlugins([{ name: 'Map' }])).toEqual([{ name: 'Map' }]); + expect(addQueryPlugins([{ name: 'Map' }], { allowFullscreen: 'true' })).toEqual([{ + mandatory: true, + name: 'FullScreen', + cfg: { + showText: true + } + }, + { + mandatory: true, + name: 'ActionNavbar', + cfg: { + containerPosition: 'footer', + variant: 'default', + leftMenuItems: [{ + type: 'placeholder' + }], + rightMenuItems: [ + { + type: 'plugin', + name: 'FullScreen', + size: 'xs' + } + ] + } + }, { name: 'Map' }] ); + }); +}); diff --git a/geonode_mapstore_client/client/themes/geonode/less/_share.less b/geonode_mapstore_client/client/themes/geonode/less/_share.less index 9bd13a5224..a03576c6d8 100644 --- a/geonode_mapstore_client/client/themes/geonode/less/_share.less +++ b/geonode_mapstore_client/client/themes/geonode/less/_share.less @@ -313,6 +313,7 @@ flex: 1; border: none; font-family: @font-family-monospace; + text-overflow: ellipsis; } } @@ -325,5 +326,8 @@ font-size: 0.8rem; text-transform: capitalize; } + .checkbox { + font-size: @font-size-sm; + } } } diff --git a/geonode_mapstore_client/static/mapstore/gn-translations/data.de-DE.json b/geonode_mapstore_client/static/mapstore/gn-translations/data.de-DE.json index c7fef8954a..a8cf107dd2 100644 --- a/geonode_mapstore_client/static/mapstore/gn-translations/data.de-DE.json +++ b/geonode_mapstore_client/static/mapstore/gn-translations/data.de-DE.json @@ -412,7 +412,8 @@ } }, "allResources": "All resources", - "assets": "Assets" + "assets": "Assets", + "includeFullscreen": "Vollbild einschließen" } } } diff --git a/geonode_mapstore_client/static/mapstore/gn-translations/data.en-US.json b/geonode_mapstore_client/static/mapstore/gn-translations/data.en-US.json index 26fdc74d03..9629501e59 100644 --- a/geonode_mapstore_client/static/mapstore/gn-translations/data.en-US.json +++ b/geonode_mapstore_client/static/mapstore/gn-translations/data.en-US.json @@ -412,7 +412,8 @@ } }, "allResources": "All resources", - "assets": "Assets" + "assets": "Assets", + "includeFullscreen": "Include fullscreen" } } } diff --git a/geonode_mapstore_client/static/mapstore/gn-translations/data.es-ES.json b/geonode_mapstore_client/static/mapstore/gn-translations/data.es-ES.json index b257b8b5ef..6ad6d8b343 100644 --- a/geonode_mapstore_client/static/mapstore/gn-translations/data.es-ES.json +++ b/geonode_mapstore_client/static/mapstore/gn-translations/data.es-ES.json @@ -411,7 +411,8 @@ } }, "allResources": "All resources", - "assets": "Assets" + "assets": "Assets", + "includeFullscreen": "Incluir pantalla completa" } } } diff --git a/geonode_mapstore_client/static/mapstore/gn-translations/data.fi-FI.json b/geonode_mapstore_client/static/mapstore/gn-translations/data.fi-FI.json index c4bde3e09b..d3904969f5 100644 --- a/geonode_mapstore_client/static/mapstore/gn-translations/data.fi-FI.json +++ b/geonode_mapstore_client/static/mapstore/gn-translations/data.fi-FI.json @@ -381,7 +381,8 @@ } }, "allResources": "All resources", - "assets": "Assets" + "assets": "Assets", + "includeFullscreen": "Include fullscreen" } } } diff --git a/geonode_mapstore_client/static/mapstore/gn-translations/data.fr-FR.json b/geonode_mapstore_client/static/mapstore/gn-translations/data.fr-FR.json index aeca810449..953c8c03d3 100644 --- a/geonode_mapstore_client/static/mapstore/gn-translations/data.fr-FR.json +++ b/geonode_mapstore_client/static/mapstore/gn-translations/data.fr-FR.json @@ -412,7 +412,8 @@ } }, "allResources": "All resources", - "assets": "Assets" + "assets": "Assets", + "includeFullscreen": "Inclure le plein écran" } } } diff --git a/geonode_mapstore_client/static/mapstore/gn-translations/data.hr-HR.json b/geonode_mapstore_client/static/mapstore/gn-translations/data.hr-HR.json index 67311259bf..1aaceb5551 100644 --- a/geonode_mapstore_client/static/mapstore/gn-translations/data.hr-HR.json +++ b/geonode_mapstore_client/static/mapstore/gn-translations/data.hr-HR.json @@ -381,7 +381,8 @@ } }, "allResources": "All resources", - "assets": "Assets" + "assets": "Assets", + "includeFullscreen": "Include fullscreen" } } } diff --git a/geonode_mapstore_client/static/mapstore/gn-translations/data.it-IT.json b/geonode_mapstore_client/static/mapstore/gn-translations/data.it-IT.json index 7590d70254..a144e9b111 100644 --- a/geonode_mapstore_client/static/mapstore/gn-translations/data.it-IT.json +++ b/geonode_mapstore_client/static/mapstore/gn-translations/data.it-IT.json @@ -414,7 +414,8 @@ } }, "allResources": "All resources", - "assets": "Assets" + "assets": "Assets", + "includeFullscreen": "Includi fullscreen" } } } diff --git a/geonode_mapstore_client/static/mapstore/gn-translations/data.nl-NL.json b/geonode_mapstore_client/static/mapstore/gn-translations/data.nl-NL.json index 1b63937d29..d0f7d27832 100644 --- a/geonode_mapstore_client/static/mapstore/gn-translations/data.nl-NL.json +++ b/geonode_mapstore_client/static/mapstore/gn-translations/data.nl-NL.json @@ -381,7 +381,8 @@ } }, "allResources": "All resources", - "assets": "Assets" + "assets": "Assets", + "includeFullscreen": "Include fullscreen" } } } diff --git a/geonode_mapstore_client/static/mapstore/gn-translations/data.pt-PT.json b/geonode_mapstore_client/static/mapstore/gn-translations/data.pt-PT.json index 9d81c71308..e3699e1bc7 100644 --- a/geonode_mapstore_client/static/mapstore/gn-translations/data.pt-PT.json +++ b/geonode_mapstore_client/static/mapstore/gn-translations/data.pt-PT.json @@ -381,7 +381,8 @@ } }, "allResources": "All resources", - "assets": "Assets" + "assets": "Assets", + "includeFullscreen": "Include fullscreen" } } } diff --git a/geonode_mapstore_client/static/mapstore/gn-translations/data.sk-SK.json b/geonode_mapstore_client/static/mapstore/gn-translations/data.sk-SK.json index aee37b3dca..7fe386b0b3 100644 --- a/geonode_mapstore_client/static/mapstore/gn-translations/data.sk-SK.json +++ b/geonode_mapstore_client/static/mapstore/gn-translations/data.sk-SK.json @@ -381,7 +381,8 @@ } }, "allResources": "All resources", - "assets": "Assets" + "assets": "Assets", + "includeFullscreen": "Include fullscreen" } } } diff --git a/geonode_mapstore_client/static/mapstore/gn-translations/data.sv-SE.json b/geonode_mapstore_client/static/mapstore/gn-translations/data.sv-SE.json index aa740719bd..b6f9fe6688 100644 --- a/geonode_mapstore_client/static/mapstore/gn-translations/data.sv-SE.json +++ b/geonode_mapstore_client/static/mapstore/gn-translations/data.sv-SE.json @@ -382,7 +382,8 @@ } }, "allResources": "All resources", - "assets": "Assets" + "assets": "Assets", + "includeFullscreen": "Include fullscreen" } } } diff --git a/geonode_mapstore_client/static/mapstore/gn-translations/data.vi-VN.json b/geonode_mapstore_client/static/mapstore/gn-translations/data.vi-VN.json index 5285b1661b..54e9eedd3e 100644 --- a/geonode_mapstore_client/static/mapstore/gn-translations/data.vi-VN.json +++ b/geonode_mapstore_client/static/mapstore/gn-translations/data.vi-VN.json @@ -381,7 +381,8 @@ } }, "allResources": "All resources", - "assets": "Assets" + "assets": "Assets", + "includeFullscreen": "Include fullscreen" } } } diff --git a/geonode_mapstore_client/static/mapstore/gn-translations/data.zh-ZH.json b/geonode_mapstore_client/static/mapstore/gn-translations/data.zh-ZH.json index cd52a6522f..6dfcbf2279 100644 --- a/geonode_mapstore_client/static/mapstore/gn-translations/data.zh-ZH.json +++ b/geonode_mapstore_client/static/mapstore/gn-translations/data.zh-ZH.json @@ -381,7 +381,8 @@ } }, "allResources": "All resources", - "assets": "Assets" + "assets": "Assets", + "includeFullscreen": "Include fullscreen" } } }