From e1b79003a75c796e365f7e672f12790aa15c56af Mon Sep 17 00:00:00 2001 From: stefano bovio Date: Wed, 14 Jul 2021 16:10:38 +0200 Subject: [PATCH] refactor of templates and add new theme in geonode pages (#325) --- geonode_mapstore_client/apps.py | 2 +- .../client/js/api/geonode/config/index.js | 1 - .../{adapter => v2}/__tests__/index-test.js | 2 +- .../js/apps/{gn-viewer.js => gn-catalogue.js} | 36 +- .../client/js/apps/gn-home.jsx | 29 +- .../components/ActionNavbar/ActionNavbar.jsx | 50 +- .../__test__/ActionNavbar-test.jsx | 6 +- .../{home => CardGrid}/CardGrid.jsx | 68 +- .../client/js/components/CardGrid/index.js | 1 + .../ContentsEditable/ThumbnailEditable.jsx | 2 +- .../{home => DetailsPanel}/DetailsPanel.jsx | 2 +- .../js/components/DetailsPanel/index.js | 1 + .../js/components/{home => FaIcon}/FaIcon.jsx | 0 .../client/js/components/FaIcon/index.js | 1 + .../{home => FeaturedList}/FeaturedList.jsx | 4 +- .../js/components/FeaturedList/index.js | 1 + .../js/components/FiltersForm/FiltersForm.jsx | 2 +- .../{home => FiltersMenu}/FiltersMenu.jsx | 66 +- .../client/js/components/FiltersMenu/index.js | 1 + .../client/js/components/Menu/BurgerMenu.jsx | 3 +- .../js/components/Menu/DropdownList.jsx | 2 +- .../client/js/components/Menu/MenuItem.js | 24 +- .../{home => ResourceCard}/ResourceCard.jsx | 4 +- .../js/components/ResourceCard/index.js | 1 + .../client/js/components/Router/Router.jsx | 3 +- .../js/components/{home => Tag}/Tag.jsx | 2 +- .../client/js/components/Tag/index.js | 1 + .../client/js/components/home/BrandNavbar.jsx | 91 --- .../client/js/components/home/Footer.jsx | 34 - .../client/js/components/home/Hero.jsx | 44 -- .../js/components/home/LanguageSelector.jsx | 90 --- .../client/js/components/home/MenuIndex.jsx | 81 --- .../client/js/components/home/SearchBar.jsx | 154 ----- .../client/js/plugins/ActionNavbar.jsx | 2 + .../client/js/plugins/BrandNavbar.jsx | 79 --- .../client/js/plugins/DetailViewer.jsx | 18 +- .../client/js/plugins/Save.jsx | 4 +- .../client/js/plugins/SaveAs.jsx | 4 +- .../client/js/plugins/Share.jsx | 4 +- .../client/js/plugins/ViewerLayout.jsx | 2 +- .../js/plugins/actionnavbar/buttons.jsx | 36 +- .../client/js/plugins/index.js | 4 - .../client/js/routes/Detail.jsx | 256 +++++++- .../client/js/routes/Home.jsx | 524 ++-------------- .../client/js/routes/Search.jsx | 364 ++++++++++- .../client/js/utils/AppUtils.js | 2 +- .../client/js/utils/GNSearchUtils.js | 12 +- .../static/mapstore/configs/localConfig.json | 34 +- .../themes/geonode/less/_action-navbar.less | 158 ----- .../client/themes/geonode/less/_base.less | 49 ++ .../themes/geonode/less/_brand-navbar.less | 79 --- .../themes/geonode/less/_card-grid.less | 15 + .../themes/geonode/less/_details-panel.less | 26 +- .../themes/geonode/less/_filter-form.less | 34 +- .../themes/geonode/less/_filter-menu.less | 68 -- .../themes/geonode/less/_home-container.less | 8 +- .../themes/geonode/less/_menu-index.less | 96 --- .../client/themes/geonode/less/_menu.less | 165 ++++- .../themes/geonode/less/_search-bar.less | 12 + .../themes/geonode/less/geonode-legacy.less | 588 +++++++++++++++++- .../client/themes/geonode/less/geonode.less | 4 - geonode_mapstore_client/hooksets.py | 4 +- geonode_mapstore_client/templates/base.html | 28 + .../geonode-mapstore-client/catalogue.html | 59 ++ .../snippets/brand_navbar.html | 34 + .../snippets/footer.html | 21 + .../snippets/header.html | 29 + .../snippets/hero.html | 11 + .../snippets/language_selector.html | 90 +++ .../snippets/loader.html | 0 .../snippets/loader_style.html | 57 ++ .../snippets/menu_item.html | 59 ++ .../snippets/menu_item_compact.html | 34 + .../snippets/search_bar.html | 238 +++++++ .../snippets/topbar.html | 107 ++++ .../geonode-mapstore-client/viewer.html | 96 --- geonode_mapstore_client/templates/index.html | 112 ++-- .../templatetags/get_menu_json.py | 211 +++++++ .../templatetags/local_config.py | 29 + 79 files changed, 2830 insertions(+), 1845 deletions(-) rename geonode_mapstore_client/client/js/api/geonode/{adapter => v2}/__tests__/index-test.js (97%) rename geonode_mapstore_client/client/js/apps/{gn-viewer.js => gn-catalogue.js} (90%) rename geonode_mapstore_client/client/js/components/{home => CardGrid}/CardGrid.jsx (77%) create mode 100644 geonode_mapstore_client/client/js/components/CardGrid/index.js rename geonode_mapstore_client/client/js/components/{home => DetailsPanel}/DetailsPanel.jsx (99%) create mode 100644 geonode_mapstore_client/client/js/components/DetailsPanel/index.js rename geonode_mapstore_client/client/js/components/{home => FaIcon}/FaIcon.jsx (100%) create mode 100644 geonode_mapstore_client/client/js/components/FaIcon/index.js rename geonode_mapstore_client/client/js/components/{home => FeaturedList}/FeaturedList.jsx (98%) create mode 100644 geonode_mapstore_client/client/js/components/FeaturedList/index.js rename geonode_mapstore_client/client/js/components/{home => FiltersMenu}/FiltersMenu.jsx (69%) create mode 100644 geonode_mapstore_client/client/js/components/FiltersMenu/index.js rename geonode_mapstore_client/client/js/components/{home => ResourceCard}/ResourceCard.jsx (98%) create mode 100644 geonode_mapstore_client/client/js/components/ResourceCard/index.js rename geonode_mapstore_client/client/js/components/{home => Tag}/Tag.jsx (94%) create mode 100644 geonode_mapstore_client/client/js/components/Tag/index.js delete mode 100644 geonode_mapstore_client/client/js/components/home/BrandNavbar.jsx delete mode 100644 geonode_mapstore_client/client/js/components/home/Footer.jsx delete mode 100644 geonode_mapstore_client/client/js/components/home/Hero.jsx delete mode 100644 geonode_mapstore_client/client/js/components/home/LanguageSelector.jsx delete mode 100644 geonode_mapstore_client/client/js/components/home/MenuIndex.jsx delete mode 100644 geonode_mapstore_client/client/js/components/home/SearchBar.jsx delete mode 100644 geonode_mapstore_client/client/js/plugins/BrandNavbar.jsx delete mode 100644 geonode_mapstore_client/client/themes/geonode/less/_action-navbar.less delete mode 100644 geonode_mapstore_client/client/themes/geonode/less/_brand-navbar.less delete mode 100644 geonode_mapstore_client/client/themes/geonode/less/_filter-menu.less delete mode 100644 geonode_mapstore_client/client/themes/geonode/less/_menu-index.less create mode 100644 geonode_mapstore_client/templates/base.html create mode 100644 geonode_mapstore_client/templates/geonode-mapstore-client/catalogue.html create mode 100644 geonode_mapstore_client/templates/geonode-mapstore-client/snippets/brand_navbar.html create mode 100644 geonode_mapstore_client/templates/geonode-mapstore-client/snippets/footer.html create mode 100644 geonode_mapstore_client/templates/geonode-mapstore-client/snippets/header.html create mode 100644 geonode_mapstore_client/templates/geonode-mapstore-client/snippets/hero.html create mode 100644 geonode_mapstore_client/templates/geonode-mapstore-client/snippets/language_selector.html create mode 100644 geonode_mapstore_client/templates/geonode-mapstore-client/snippets/loader.html create mode 100644 geonode_mapstore_client/templates/geonode-mapstore-client/snippets/loader_style.html create mode 100644 geonode_mapstore_client/templates/geonode-mapstore-client/snippets/menu_item.html create mode 100644 geonode_mapstore_client/templates/geonode-mapstore-client/snippets/menu_item_compact.html create mode 100644 geonode_mapstore_client/templates/geonode-mapstore-client/snippets/search_bar.html create mode 100644 geonode_mapstore_client/templates/geonode-mapstore-client/snippets/topbar.html delete mode 100644 geonode_mapstore_client/templates/geonode-mapstore-client/viewer.html create mode 100644 geonode_mapstore_client/templatetags/local_config.py diff --git a/geonode_mapstore_client/apps.py b/geonode_mapstore_client/apps.py index a6fe8bb542..ff8163106d 100644 --- a/geonode_mapstore_client/apps.py +++ b/geonode_mapstore_client/apps.py @@ -23,7 +23,7 @@ def run_setup_hooks(*args, **kwargs): urlpatterns += [ url(r'^mapstore/', include('mapstore2_adapter.urls')), url(r'^', include('mapstore2_adapter.geoapps.geostories.api.urls')), - url(r'^viewer/', TemplateView.as_view(template_name='geonode-mapstore-client/viewer.html')), + url(r'^catalogue/', TemplateView.as_view(template_name='geonode-mapstore-client/catalogue.html')), ] diff --git a/geonode_mapstore_client/client/js/api/geonode/config/index.js b/geonode_mapstore_client/client/js/api/geonode/config/index.js index a7c6c32fcd..b2957e93c7 100644 --- a/geonode_mapstore_client/client/js/api/geonode/config/index.js +++ b/geonode_mapstore_client/client/js/api/geonode/config/index.js @@ -22,4 +22,3 @@ export default { getNewMapConfiguration, getNewGeoStoryConfig }; - diff --git a/geonode_mapstore_client/client/js/api/geonode/adapter/__tests__/index-test.js b/geonode_mapstore_client/client/js/api/geonode/v2/__tests__/index-test.js similarity index 97% rename from geonode_mapstore_client/client/js/api/geonode/adapter/__tests__/index-test.js rename to geonode_mapstore_client/client/js/api/geonode/v2/__tests__/index-test.js index 7083a3faac..8cba169427 100644 --- a/geonode_mapstore_client/client/js/api/geonode/adapter/__tests__/index-test.js +++ b/geonode_mapstore_client/client/js/api/geonode/v2/__tests__/index-test.js @@ -16,7 +16,7 @@ import { let mockAxios; -describe('GeoNode adapter api', () => { +describe('GeoNode v2 api', () => { beforeEach(done => { global.__DEVTOOLS__ = true; mockAxios = new MockAdapter(axios); diff --git a/geonode_mapstore_client/client/js/apps/gn-viewer.js b/geonode_mapstore_client/client/js/apps/gn-catalogue.js similarity index 90% rename from geonode_mapstore_client/client/js/apps/gn-viewer.js rename to geonode_mapstore_client/client/js/apps/gn-catalogue.js index 67e12ce091..81e40befae 100644 --- a/geonode_mapstore_client/client/js/apps/gn-viewer.js +++ b/geonode_mapstore_client/client/js/apps/gn-catalogue.js @@ -36,11 +36,14 @@ import searchconfig from '@mapstore/framework/reducers/searchconfig'; import widgets from '@mapstore/framework/reducers/widgets'; // end +import SearchRoute from '@js/routes/Search'; +import DetailRoute from '@js/routes/Detail'; import LayerViewerRoute from '@js/routes/LayerViewer'; import MapViewerRoute from '@js/routes/MapViewer'; import GeoStoryViewerRoute from '@js/routes/GeoStoryViewer'; import DocumentViewerRoute from '@js/routes/DocumentViewer'; +import gnsearch from '@js/reducers/gnsearch'; import gnresource from '@js/reducers/gnresource'; import gnsettings from '@js/reducers/gnsettings'; @@ -52,7 +55,6 @@ import { import { setupConfiguration, - getVersion, initializeApp, getPluginsConfiguration } from '@js/utils/AppUtils'; @@ -64,6 +66,8 @@ import { gnSetLayersPermissions } from '@js/epics'; import gnviewerEpics from '@js/epics/gnviewer'; +import gnsearchEpics from '@js/epics/gnsearch'; +import gnlocaleEpics from '@js/epics/gnlocale'; import maplayout from '@mapstore/framework/reducers/maplayout'; import pluginsDefinition from '@js/plugins/index'; @@ -126,6 +130,23 @@ const routes = [ '/document/:pk' ], component: DocumentViewerRoute + }, + { + name: 'resources', + path: [ + '/', + '/search/', + '/search/filter' + ], + component: SearchRoute + }, + { + name: 'detail', + path: [ + '/detail/:pk', + '/detail/:ctype/:pk' + ], + component: DetailRoute } ]; @@ -172,13 +193,7 @@ Promise.all([ } } }, - themeCfg: { - path: '/static/mapstore/dist/themes', - prefixContainer: undefined, - version: getVersion(), - prefix: 'msgapi', - theme: 'geonode' - }, + themeCfg: null, pluginsConfig: getPluginsConfiguration(localConfig.plugins, pluginsConfigKey), lazyPlugins: pluginsDefinition.lazyPlugins, pluginsDef: { @@ -210,6 +225,7 @@ Promise.all([ searchconfig, widgets, geostory, + gnsearch, ...pluginsDefinition.reducers }, appEpics: { @@ -218,7 +234,9 @@ Promise.all([ gnCheckSelectedLayerPermissions, gnSetLayersPermissions, ...pluginsDefinition.epics, - ...gnviewerEpics + ...gnviewerEpics, + ...gnsearchEpics, + ...gnlocaleEpics }, geoNodeConfiguration, initialActions: [ diff --git a/geonode_mapstore_client/client/js/apps/gn-home.jsx b/geonode_mapstore_client/client/js/apps/gn-home.jsx index 22b169516a..c16cc2e2ac 100644 --- a/geonode_mapstore_client/client/js/apps/gn-home.jsx +++ b/geonode_mapstore_client/client/js/apps/gn-home.jsx @@ -15,8 +15,6 @@ import security from '@mapstore/framework/reducers/security'; import controls from '@mapstore/framework/reducers/controls'; import Home from '@js/routes/Home'; -import SearchRoute from '@js/routes/Search'; -import DetailRoute from '@js/routes/Detail'; import gnsearch from '@js/reducers/gnsearch'; import gnresource from '@js/reducers/gnresource'; @@ -33,8 +31,7 @@ import { import { setupConfiguration, - initializeApp, - getVersion + initializeApp } from '@js/utils/AppUtils'; const DEFAULT_LOCALE = {}; @@ -47,23 +44,7 @@ const routes = [ name: 'homepage', path: '/', component: Home - }, - { - name: 'resources', - path: [ - '/search/' - ], - component: SearchRoute - }, - { - name: 'detail', - path: [ - '/detail/:pk', - '/detail/:ctype/:pk' - ], - component: DetailRoute } - ]; initializeApp(); @@ -94,13 +75,7 @@ Promise.all([ } }, pluginsConfig: localConfig.plugins || [], - themeCfg: { - path: '/static/mapstore/dist/themes', - prefixContainer: 'body', - version: getVersion(), - prefix: 'msgapi', - theme: 'geonode' - }, + themeCfg: null, appReducers: { gnsearch, gnresource, diff --git a/geonode_mapstore_client/client/js/components/ActionNavbar/ActionNavbar.jsx b/geonode_mapstore_client/client/js/components/ActionNavbar/ActionNavbar.jsx index c89adb84a5..e96a142741 100644 --- a/geonode_mapstore_client/client/js/components/ActionNavbar/ActionNavbar.jsx +++ b/geonode_mapstore_client/client/js/components/ActionNavbar/ActionNavbar.jsx @@ -13,7 +13,7 @@ import BurgerMenu from '@js/components/Menu/BurgerMenu'; import useResizeElement from '@js/hooks/useResizeElement'; -const LeftContentMenu = ({ items, formatHref, query }) => { +const LeftContentMenu = ({ items, formatHref, query, variant, size }) => { const navbarContentLeft = useRef(); const navbarLeft = useRef(); @@ -26,11 +26,11 @@ const LeftContentMenu = ({ items, formatHref, query }) => { return (
{ - (switchToBurgerMenu) && items && + (switchToBurgerMenu) && items && } { (!switchToBurgerMenu) && items && @@ -38,11 +38,11 @@ const LeftContentMenu = ({ items, formatHref, query }) => { } @@ -52,7 +52,7 @@ const LeftContentMenu = ({ items, formatHref, query }) => { }; -const RightContentMenu = ({ items, formatHref, query, parentRef, cfg }) => { +const RightContentMenu = ({ items, formatHref, query, parentRef, cfg, variant, size }) => { const navbarContentRight = useRef(); const navbarRight = useRef(); @@ -68,24 +68,24 @@ const RightContentMenu = ({ items, formatHref, query, parentRef, cfg }) => { return (
{ - (switchToBurgerMenu) && items && + (switchToBurgerMenu) && items && } {(!switchToBurgerMenu) && items && } @@ -103,20 +103,21 @@ const ActionNavbar = forwardRef(({ rightItems, query, formatHref, - tools, - cfg + cfg, + variant, + size }, ref) => { return (