From 7abcafbe821bcdc949e434d63388c45580ba3382 Mon Sep 17 00:00:00 2001 From: David Quartey <42542676+DavidQuartz@users.noreply.github.com> Date: Thu, 7 Jul 2022 09:44:57 +0000 Subject: [PATCH] [Backport 4.x][Fixes #1053] Include base support for localization in gn-document app entry (#1061) --- .../client/js/apps/gn-document.js | 112 +++++++++++++++--- geonode_mapstore_client/client/package.json | 2 +- .../static/mapstore/configs/localConfig.json | 5 + 3 files changed, 102 insertions(+), 17 deletions(-) diff --git a/geonode_mapstore_client/client/js/apps/gn-document.js b/geonode_mapstore_client/client/js/apps/gn-document.js index f0ffd9eb46..232930e0d1 100644 --- a/geonode_mapstore_client/client/js/apps/gn-document.js +++ b/geonode_mapstore_client/client/js/apps/gn-document.js @@ -5,22 +5,57 @@ * 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 from 'react'; -import ReactDOM from 'react-dom'; +import { connect } from 'react-redux'; +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 security from '@mapstore/framework/reducers/security'; +import gnresource from '@js/reducers/gnresource'; +import gnsettings from '@js/reducers/gnsettings'; +import { updateGeoNodeSettings } from '@js/actions/gnsettings'; import { getEndpoints, getConfiguration, - getAccountInfo, - getDocumentByPk + getAccountInfo } from '@js/api/geonode/v2'; import { setupConfiguration, - initializeApp + initializeApp, + getPluginsConfiguration, + storeEpicsCache } from '@js/utils/AppUtils'; -import MediaViewer from '@js/components/MediaViewer'; +import { ResourceTypes } from '@js/utils/ResourceUtils'; +import pluginsDefinition from '@js/plugins/index'; +import ReactSwipe from 'react-swipeable-views'; +import SwipeHeader from '@mapstore/framework/components/data/identify/SwipeHeader'; +import { requestResourceConfig } from '@js/actions/gnresource'; +import gnresourceEpics from '@js/epics/gnresource'; +const requires = { + ReactSwipe, + SwipeHeader +}; +import '@js/observables/persistence'; initializeApp(); +const DEFAULT_LOCALE = {}; +const ConnectedRouter = connect((state) => ({ + locale: state?.locale || DEFAULT_LOCALE +}))(Router); + + +const routes = [{ + name: 'document_embed', + path: [ + '/' + ], + pageConfig: { + resourceType: ResourceTypes.DOCUMENT + }, + component: ViewerRoute +}]; + document.addEventListener('DOMContentLoaded', function() { getEndpoints().then(() => { Promise.all([ @@ -30,18 +65,63 @@ document.addEventListener('DOMContentLoaded', function() { .then(([localConfig, user]) => { setupConfiguration({ localConfig, user }) .then(({ + securityState, + geoNodeConfiguration, + pluginsConfigKey, + configEpics, + onStoreInit, geoNodePageConfig, - targetId = 'ms-container' + targetId = 'ms-container', + settings }) => { - getDocumentByPk(geoNodePageConfig.resourceId) - .then((resource) => { - ReactDOM.render( -