From 438fd11ae79ec35a6eededfd691c43e510973954 Mon Sep 17 00:00:00 2001 From: Alexander Date: Tue, 17 May 2022 16:09:10 +0300 Subject: [PATCH] Properly toggle urbanisme tool when another drawing tool is activated (#54) --- MapStore2 | 2 +- build/extension/commons.js | 8 +- build/extension/module.app.webpack.config.js | 10 +- build/extension/prod-webpack.config.js | 5 +- build/extension/webpack.config.js | 9 +- config.json => configs/config.json | 0 localConfig.json => configs/localConfig.json | 2 +- index.html | 6 +- js/app.jsx | 1 - .../epics/__tests__/urbanisme-test.js | 64 ++++------- js/extension/epics/urbanisme.js | 100 ++++++++---------- js/extension/plugins/Extension.jsx | 8 +- .../plugins/urbanisme/UrbanismeToolbar.js | 6 +- js/extension/reducers/urbanisme.js | 3 +- karma.conf.continuous-test.js | 1 + karma.conf.single-run.js | 12 +-- package.json | 28 ++--- prod-webpack.config.js | 1 + webpack.config.js | 1 + 19 files changed, 114 insertions(+), 153 deletions(-) rename config.json => configs/config.json (100%) rename localConfig.json => configs/localConfig.json (99%) diff --git a/MapStore2 b/MapStore2 index 307918e..8026a5f 160000 --- a/MapStore2 +++ b/MapStore2 @@ -1 +1 @@ -Subproject commit 307918e97587c7497795578ce2eddf491dcecb36 +Subproject commit 8026a5f02cc258bbc0a663ba393822d8805bece7 diff --git a/build/extension/commons.js b/build/extension/commons.js index 9a3b7c8..56fe53f 100644 --- a/build/extension/commons.js +++ b/build/extension/commons.js @@ -1,4 +1,6 @@ const path = require("path"); +const NormalModuleReplacementPlugin = require("webpack/lib/NormalModuleReplacementPlugin"); + // common configuration between production and development for webpack module.exports = { @@ -10,7 +12,11 @@ module.exports = { destination: path.join(__dirname, '..', '..', "dist"), // to compile properly also mapstore dependencies alias: { + "@mapstore/patcher": path.resolve(__dirname, '..', '..', "node_modules", "@mapstore", "patcher"), "@mapstore": path.resolve(__dirname, '..', '..', "MapStore2", "web", "client"), "@js": path.resolve(__dirname, '..', '..', "js") - } + }, + plugins: [ + new NormalModuleReplacementPlugin(/^cesium\/index\.css$/, path.join(__dirname, "..", "..", "node_modules", "cesium/Build/Cesium/Widgets/widgets.css")) + ] }; diff --git a/build/extension/module.app.webpack.config.js b/build/extension/module.app.webpack.config.js index b497509..4ad4cde 100644 --- a/build/extension/module.app.webpack.config.js +++ b/build/extension/module.app.webpack.config.js @@ -5,18 +5,18 @@ const webpackConfig = require("../../webpack.config"); const { name } = require('../../config'); // emulate the extension root directory -webpackConfig.devServer.proxy["/extension/"] = { +webpackConfig.devServer.proxy["/extensions/"] = { target: "http://localhost:8082" }; // emulate the extensions.json webpackConfig.devServer.before = function(app) { - app.get("/extensions.json", function(req, res) { + app.get("/extensions/extensions.json", function(req, res) { res.json({ [name]: { - "bundle": "extension/index.js", - "translations": "extension/translations" + "bundle": "index.js", + "translations": "translations" } }); }); -}, +}; module.exports = webpackConfig; diff --git a/build/extension/prod-webpack.config.js b/build/extension/prod-webpack.config.js index 9057fed..4971b53 100644 --- a/build/extension/prod-webpack.config.js +++ b/build/extension/prod-webpack.config.js @@ -5,7 +5,7 @@ const createExtensionWebpackConfig = require('../../MapStore2/build/createExtens const CopyPlugin = require('copy-webpack-plugin'); const ZipPlugin = require('zip-webpack-plugin'); const {name} = require('../../config'); -const commons = require('./commons'); +const { plugins: commonsPlugins, ...commons} = require('./commons'); // the build configuration for production allow to create the final zip file, compressed accordingly const plugins = [ @@ -22,7 +22,8 @@ const plugins = [ // other files have to be placed in the root, with the same name return path.basename(assetPath); } - }) + }), + ...commonsPlugins ]; // Temporary TODO: Has to be updated in createExtensionWebpackConfig diff --git a/build/extension/webpack.config.js b/build/extension/webpack.config.js index c746774..4b5319a 100644 --- a/build/extension/webpack.config.js +++ b/build/extension/webpack.config.js @@ -2,7 +2,7 @@ const createExtensionWebpackConfig = require('../../MapStore2/build/createExtensionWebpackConfig'); const { name } = require('../../config'); -const commons = require('./commons'); +const { plugins: commonsPlugins, ...commons } = require('./commons'); const webpackConfig = createExtensionWebpackConfig({ prod: false, name, @@ -10,11 +10,12 @@ const webpackConfig = createExtensionWebpackConfig({ overrides: { // serve translations (and index.json) devServer: { - publicPath: "/extension/", + publicPath: "/extensions/", contentBase: './assets', - contentBasePublicPath: '/extension/' + contentBasePublicPath: '/extensions/' } - } + }, + plugins: [ ...commonsPlugins ] }); module.exports = webpackConfig; diff --git a/config.json b/configs/config.json similarity index 100% rename from config.json rename to configs/config.json diff --git a/localConfig.json b/configs/localConfig.json similarity index 99% rename from localConfig.json rename to configs/localConfig.json index f81f0e9..1a7b8d7 100644 --- a/localConfig.json +++ b/configs/localConfig.json @@ -481,7 +481,7 @@ "declineUrl" : "http://www.google.com" } }, - "OmniBar", "Login", "Save", "SaveAs", "BurgerMenu", "Expander", "Undo", "Redo", "FullScreen", "GlobeViewSwitcher", "SearchServicesConfig", "SearchByBookmark", "WidgetsBuilder", "Widgets", + "OmniBar", "Login", "Save", "SaveAs", "SidebarMenu", "Expander", "Undo", "Redo", "FullScreen", "GlobeViewSwitcher", "SearchServicesConfig", "SearchByBookmark", "WidgetsBuilder", "Widgets", "WidgetsTray", "Timeline", "Playback", diff --git a/index.html b/index.html index 74a17ec..17a5e80 100644 --- a/index.html +++ b/index.html @@ -15,7 +15,7 @@ left: 0; bottom: 0; right: 0; - overflow: show; + overflow: visible; margin: auto; display: flex; align-items: center; @@ -92,10 +92,6 @@ - - - - diff --git a/js/app.jsx b/js/app.jsx index 4174723..1a95fef 100644 --- a/js/app.jsx +++ b/js/app.jsx @@ -24,7 +24,6 @@ ConfigUtils.setConfigProp('themePrefix', 'MapStoreExtension'); * * ConfigUtils.setLocalConfigurationFile('localConfig.json'); */ -ConfigUtils.setLocalConfigurationFile('localConfig.json'); /** * Use a custom application configuration file with: diff --git a/js/extension/epics/__tests__/urbanisme-test.js b/js/extension/epics/__tests__/urbanisme-test.js index 340dac4..910fcac 100644 --- a/js/extension/epics/__tests__/urbanisme-test.js +++ b/js/extension/epics/__tests__/urbanisme-test.js @@ -8,8 +8,8 @@ import expect from 'expect'; import { testEpic, addTimeoutEpic } from '@mapstore/epics/__tests__/epicTestUtils'; -import { toggleControl, TOGGLE_CONTROL, setControlProperty } from '@mapstore/actions/controls'; -import { clickOnMap } from '@mapstore/actions/map'; +import { toggleControl, TOGGLE_CONTROL } from '@mapstore/actions/controls'; +import {clickOnMap, registerEventListener} from '@mapstore/actions/map'; import { PURGE_MAPINFO_RESULTS, TOGGLE_MAPINFO_STATE, loadFeatureInfo } from '@mapstore/actions/mapInfo'; import { @@ -17,11 +17,12 @@ import { toggleLandPlanningEpic, cleanUpUrbanismeEpic, clickOnMapEventEpic, - deactivateOnMeasureEnabledEpic, getFeatureInfoEpic, onClosePanelEpic, onToogleToolEpic, - updateAdditionalLayerEpic, highlightFeatureEpic + updateAdditionalLayerEpic, + highlightFeatureEpic, + tearDownUrbanismeOnDrawToolActive } from '../urbanisme'; import { setUp, @@ -99,16 +100,16 @@ describe('Urbanisme EPICS', () => { it('toggleLandPlanningEpic when Urbanisme tool enabled', (done) => { const state = { - controls: { urbanisme: { enabled: true }, measure: {enabled: true}}, + controls: { urbanisme: { enabled: true }}, urbanisme: { config: { cadastreWMSURL: "/cadastreWMSURL"}}, mapInfo: {enabled: true} }; testEpic( toggleLandPlanningEpic, - 4, + 3, toggleControl('urbanisme', null), actions => { - expect(actions.length).toBe(4); + expect(actions.length).toBe(3); actions.map(action=> { switch (action.type) { case UPDATE_ADDITIONAL_LAYER: @@ -226,35 +227,17 @@ describe('Urbanisme EPICS', () => { state); }); - it('cleanUpUrbanismeEpic opening annotation when urbanisme plugin is opened', (done) => { - const state = { controls: { urbanisme: { enabled: true}, annotations: { enabled: true}}}; - testEpic( - cleanUpUrbanismeEpic, - 1, - toggleControl("annotations"), - actions => { - expect(actions.length).toBe(1); - actions.map(action=>{ - switch (action.type) { - case TOGGLE_CONTROL: - break; - default: - expect(true).toBe(false); - } - }); - done(); - }, - state); - }); - - it('closeOnMeasureEnabledEpic close when urbanisme plugin when measurement is opened', (done) => { - const state = { controls: { measure: { enabled: true}, urbanisme: { enabled: true}}}; + it('tearDownUrbanismeOnDrawToolActive toggle off urbanisme tool when measurement is opened', (done) => { + const state = { + controls: { measure: { enabled: true}, urbanisme: { enabled: true}}, + urbanisme: { activeTool: "ADS"} + }; testEpic( - deactivateOnMeasureEnabledEpic, - 3, - setControlProperty("measure", "enabled", true), + tearDownUrbanismeOnDrawToolActive, + 2, + registerEventListener('click', 'measure'), actions => { - expect(actions.length).toBe(3); + expect(actions.length).toBe(2); actions.map(action=>{ switch (action.type) { case TOGGLE_TOOL: @@ -263,8 +246,6 @@ describe('Urbanisme EPICS', () => { case TOGGLE_VIEWER_PANEL: expect(action.enabled).toBe(false); break; - case PURGE_MAPINFO_RESULTS: - break; default: expect(true).toBe(false); } @@ -300,7 +281,7 @@ describe('Urbanisme EPICS', () => { mockAxios.onGet(`${CADASTRAPP_URL}/getParcelle`).reply(200, [{parcelle: "parcelle", ccopre: "ccopre", ccosec: "ccosec", dnupla: "dnupla", dnvoiri: "dnvoiri", cconvo: "cconvo", dvoilib: "dvoilib", dcntpa: "dcntpa"}]); mockAxios.onGet(`${URBANISMEAPP_URL}/renseignUrba`).reply(200, {libelles: [{libelle: "Test"}]}); - mockAxios.onGet(`${CADASTRAPP_URL}/getFIC`, ).reply((config)=>{ + mockAxios.onGet(`${CADASTRAPP_URL}/getFIC` ).reply((config)=>{ if (config.params.onglet === 0) return [200, [{surfc: "surfc"}]]; return [200, [{comptecommunal: "codeProprio"}]]; }); @@ -347,7 +328,7 @@ describe('Urbanisme EPICS', () => { mockAxios.onGet(`${CADASTRAPP_URL}/getCommune`).reply(200, []); mockAxios.onGet(`${CADASTRAPP_URL}/getParcelle`).reply(200, []); mockAxios.onGet(`${URBANISMEAPP_URL}/renseignUrba`).reply(200, {}); - mockAxios.onGet(`${CADASTRAPP_URL}/getFIC`, ).reply((config)=>{ + mockAxios.onGet(`${CADASTRAPP_URL}/getFIC` ).reply((config)=>{ if (config.params.onglet === 0) return [200, []]; return [200, []]; }); @@ -440,10 +421,10 @@ describe('Urbanisme EPICS', () => { }; testEpic( onToogleToolEpic, - 4, + 3, toggleUrbanismeTool('NRU'), actions => { - expect(actions.length).toBe(4); + expect(actions.length).toBe(3); actions.map(action=>{ switch (action.type) { case URBANISME_RESET_FEATURE_HIGHLIGHT: @@ -454,9 +435,6 @@ describe('Urbanisme EPICS', () => { case TOGGLE_VIEWER_PANEL: expect(action.enabled).toBe(false); break; - case TOGGLE_CONTROL: - expect(action.control).toBe("measure"); - break; default: expect(true).toBe(false); } diff --git a/js/extension/epics/urbanisme.js b/js/extension/epics/urbanisme.js index 87f93ab..80c5658 100644 --- a/js/extension/epics/urbanisme.js +++ b/js/extension/epics/urbanisme.js @@ -10,10 +10,11 @@ import * as Rx from "rxjs"; import {get, isEmpty, omit} from "lodash"; import uuid from 'uuid'; -import {SET_CONTROL_PROPERTY, TOGGLE_CONTROL, toggleControl} from "@mapstore/actions/controls"; -import {ANNOTATIONS} from "@mapstore/utils/AnnotationsUtils"; +import { + TOGGLE_CONTROL +} from "@mapstore/actions/controls"; import {error} from "@mapstore/actions/notifications"; -import {CLICK_ON_MAP} from "@mapstore/actions/map"; +import {CLICK_ON_MAP, registerEventListener, unRegisterEventListener} from "@mapstore/actions/map"; import {removeAdditionalLayer, updateAdditionalLayer} from '@mapstore/actions/additionallayers'; import { closeIdentify, @@ -35,7 +36,6 @@ import { import {localConfigSelector} from '@mapstore/selectors/localConfig'; import proj4 from 'proj4'; -import {createControlEnabledSelector, measureSelector} from "@mapstore/selectors/controls"; import {wrapStartStop} from "@mapstore/observables/epics"; import { @@ -98,13 +98,14 @@ import { mapTriggerSelector, showMarkerSelector } from "@mapstore/selectors/mapInfo"; -import {styleFeatures} from "@js/extension/utils/UrbanismeUtils"; +import {styleFeatures} from "../utils/UrbanismeUtils"; import {resolutionsSelector} from "@mapstore/selectors/map"; import { registerHook, RESOLUTION_HOOK } from "@mapstore/utils/MapUtils"; - +import {shutdownToolOnAnotherToolDrawing} from "@mapstore/utils/ControlUtils"; +import {setAPIURL} from "@js/extension/api"; /** * Ensures that config for the urbanisme tool is fetched and loaded * @memberof epics.urbanisme @@ -112,9 +113,10 @@ import { * @return {observable} */ export const setUpPluginEpic = (action$, store) => - action$.ofType(SET_UP).switchMap(() => { + action$.ofType(SET_UP).switchMap((action) => { const state = store.getState(); const isConfigLoaded = configLoadSelector(state); + setAPIURL(action.initConfig); // adds projections from localConfig.json // The extension do not see the state proj4 of MapStore (can not reproject in custom CRS as mapstore does) // so they have to be registered again in the extension. @@ -141,10 +143,10 @@ export const setUpPluginEpic = (action$, store) => loading(false, 'configLoading'), e => { console.log(e); // eslint-disable-line no-console - return Rx.Observable.of(error({ + return Rx.Observable.from([error({ title: "Error", message: "Unable to setup urbanisme app" - }), loading(false, 'configLoading')); + }), loading(false, 'configLoading')]); } ) @@ -167,7 +169,6 @@ export const toggleLandPlanningEpic = (action$, store) => const {cadastreWMSURL: url, layer: name = DEFAULT_URBANISME_LAYER} = configSelector(state) || {}; const enabled = urbanimseControlSelector(state); const mapInfoEnabled = get(state, "mapInfo.enabled"); - const isMeasureEnabled = measureSelector(state); const mapHoverTrigger = mapTriggerSelector(state); if (enabled) { return Rx.Observable.from([ @@ -196,7 +197,6 @@ export const toggleLandPlanningEpic = (action$, store) => }) ]).concat([ ...(mapInfoEnabled ? [toggleMapInfoState()] : []), - ...(isMeasureEnabled ? [toggleControl("measure")] : []), ...(mapHoverTrigger === 'hover' ? [setMapTrigger("click")] : []) ]); } @@ -204,8 +204,7 @@ export const toggleLandPlanningEpic = (action$, store) => return !isEmpty(layer) ? Rx.Observable.from([ removeAdditionalLayer({id: URBANISME_RASTER_LAYER_ID, owner: URBANISME_OWNER}), - removeAdditionalLayer({id: URBANISME_VECTOR_LAYER_ID, owner: URBANISME_OWNER}), - purgeMapInfoResults() + removeAdditionalLayer({id: URBANISME_VECTOR_LAYER_ID, owner: URBANISME_OWNER}) ]).concat(!mapInfoEnabled ? [toggleMapInfoState()] : []) : Rx.Observable.empty(); }); @@ -231,6 +230,7 @@ export const clickOnMapEventEpic = (action$, {getState}) => ? Rx.Observable.of(toggleUrbanismeTool(null)) : Rx.Observable.empty(); } + return !isEmpty(activeTool) && !isPrinting ? Rx.Observable.of( featureInfoClick(point, layer), @@ -251,13 +251,7 @@ export const cleanUpUrbanismeEpic = (action$, {getState}) => .ofType(TOGGLE_CONTROL) .filter(({control}) => { const isUrbanismeEnabled = urbanimseControlSelector(getState()); - const isAnnotationsEnabled = createControlEnabledSelector(ANNOTATIONS)( - getState() - ); - return ( - (control === CONTROL_NAME && !isUrbanismeEnabled) || - (control === ANNOTATIONS && isAnnotationsEnabled && isUrbanismeEnabled) - ); + return control === CONTROL_NAME && !isUrbanismeEnabled; }) .switchMap(({control}) => { const state = getState(); @@ -271,34 +265,26 @@ export const cleanUpUrbanismeEpic = (action$, {getState}) => setAttributes(null), resetFeatureHighlight() ]); - } else if (control === ANNOTATIONS) { - observable$ = Rx.Observable.of(toggleControl(CONTROL_NAME)); } return observable$; }); /** - * Ensures that the urbanisme plugin is deactivated when measurement tool is activated - * @memberof epics.urbanisme - * @param {observable} action$ manages `SET_CONTROL_PROPERTY` - * @return {observable} + * Toggle urbanisme tool off when one of the drawing tools takes control + * @param action$ + * @param store + * @returns {Observable} */ -export const deactivateOnMeasureEnabledEpic = (action$, {getState}) => - action$ - .ofType(SET_CONTROL_PROPERTY) - .filter( - ({control}) => control === "measure" && measureSelector(getState()) - ) - .switchMap(() => { - const urbanismeEnabled = urbanimseControlSelector(getState()); - return urbanismeEnabled - ? Rx.Observable.from([ - toggleGFIPanel(false), - toggleUrbanismeTool(null), - purgeMapInfoResults() - ]) - : Rx.Observable.empty(); - }); +export const tearDownUrbanismeOnDrawToolActive = (action$, store) => shutdownToolOnAnotherToolDrawing(action$, store, 'urbanisme', + () => { + return Rx.Observable.from([ + toggleGFIPanel(false), + toggleUrbanismeTool(null) + ]); + }, + (state) => activeToolSelector(state) +); + /** * Ensures that the urbanisme plugin active tool is getting deactivated when Identify tool is activated @@ -366,24 +352,23 @@ export const onClosePanelEpic = action$ => export const onToogleToolEpic = (action$, {getState}) => action$ .ofType(TOGGLE_TOOL) - .filter(() => { - const state = getState(); - return activeToolSelector(state); - }) .switchMap(() => { const state = getState(); + const activeTool = activeToolSelector(state); const mapInfoEnabled = !mapInfoDisabledSelector(state); const infoMarkerIsShown = showMarkerSelector(state); - const isMeasureEnabled = measureSelector(state); const mapHoverTrigger = mapTriggerSelector(state); return Rx.Observable.from([ resetFeatureHighlight(), setAttributes(null), toggleGFIPanel(false), - ...(mapInfoEnabled ? [toggleMapInfoState(), purgeMapInfoResults()] : []), - ...(isMeasureEnabled ? [toggleControl("measure")] : []), - ...(mapHoverTrigger === 'hover' ? [setMapTrigger("click")] : []), - ...(infoMarkerIsShown ? [hideMapinfoMarker()] : []) + ...(activeTool && mapInfoEnabled ? [toggleMapInfoState(), purgeMapInfoResults()] : []), + ...(activeTool && mapHoverTrigger === 'hover' ? [setMapTrigger("click")] : []), + ...(infoMarkerIsShown ? [hideMapinfoMarker()] : []), + ...(activeTool + ? [registerEventListener('click', 'urbanisme')] + : [unRegisterEventListener('click', 'urbanisme')] + ) ]); } ); @@ -403,9 +388,10 @@ export const getFeatureInfoEpic = (action$, {getState}) => !isEmpty(activeToolSelector(getState())) ) .switchMap(({layerMetadata}) => { - const {idParcelleKey} = configSelector(getState()) ?? {}; + const state = getState(); + const {idParcelleKey} = configSelector(state) ?? {}; const parcelleId = layerMetadata.features?.[0]?.properties?.[idParcelleKey ?? "id_parc"] || ""; - const activeTool = activeToolSelector(getState()); + const activeTool = activeToolSelector(state); if (isEmpty(parcelleId)) { return Rx.Observable.of( loading(false, "dataLoading"), @@ -493,7 +479,7 @@ export const highlightFeatureEpic = (action$, {getState}) => const parcelleId = layerMetadata.features?.[0]?.properties?.[idParcelleKey ?? "id_parc"] || ""; if (isEmpty(parcelleId)) { return Rx.Observable.of( - resetFeatureHighlight(), + resetFeatureHighlight() ); } return Rx.Observable.of( @@ -588,7 +574,7 @@ export const updateAdditionalLayerEpic = (action$, { const styledFeatures = styleFeatures(feature, omit(highlightStyleSelector(state), ["radius"])); const features = styledFeatures && featureCrs ? styledFeatures.map( f => reprojectGeoJson( f, - featureCrs, + featureCrs )) : styledFeatures; const markerFeature = clickedPointToGeoJson(point.latlng); return Rx.Observable.of( @@ -633,7 +619,7 @@ export default { getUrbanismeFeatureInfoOnFeatureInfoClick, highlightFeatureEpic, updateAdditionalLayerEpic, - deactivateOnMeasureEnabledEpic, deactivateOnMapHoverEnabledEpic, - deactivateOnIdentifyEnabledEpic + deactivateOnIdentifyEnabledEpic, + tearDownUrbanismeOnDrawToolActive }; diff --git a/js/extension/plugins/Extension.jsx b/js/extension/plugins/Extension.jsx index 4adb302..79ca01a 100644 --- a/js/extension/plugins/Extension.jsx +++ b/js/extension/plugins/Extension.jsx @@ -93,8 +93,8 @@ const UrbanismePlugin = { action: toggleControl.bind(null, CONTROL_NAME, null), selector: createSelector( configSelector, - (configLoaded) => ({ - style: !!configLoaded ? {} : { display: "none" } // Hide when config failed to load + (config) => ({ + style: !!config?.cadastreWMSURL ? {} : { display: "none" } // Hide when config failed to load }) ), position: 1501, @@ -109,8 +109,8 @@ const UrbanismePlugin = { action: toggleControl.bind(null, CONTROL_NAME, null), selector: createSelector( configSelector, - (configLoaded) => ({ - style: !!configLoaded ? {} : { display: "none" } // Hide when config failed to load + (config) => ({ + style: !!config?.cadastreWMSURL ? {} : { display: "none" } // Hide when config failed to load }) ), position: 1501, diff --git a/js/extension/plugins/urbanisme/UrbanismeToolbar.js b/js/extension/plugins/urbanisme/UrbanismeToolbar.js index 6ad0cec..d9533bb 100644 --- a/js/extension/plugins/urbanisme/UrbanismeToolbar.js +++ b/js/extension/plugins/urbanisme/UrbanismeToolbar.js @@ -16,7 +16,6 @@ import { HELP_LINK_DEFAULT } from "@js/extension/constants"; import LandPlanning from "@js/extension/components/LandPlanningViewer"; -import {setAPIURL} from "@js/extension/api"; import classnames from "classnames"; /** @@ -46,9 +45,8 @@ const UrbanismeToolbar = ({ const { activeTool = '', showGFIPanel = false } = urbanisme; useEffect(() => { const { cadastrappUrl, layer, urbanismeappUrl, idParcelleKey} = props; - setAPIURL({cadastrappUrl, urbanismeappUrl}); - onSetUp({ layer, idParcelleKey }); - }, [setAPIURL, onSetUp]); + onSetUp({ layer, idParcelleKey, cadastrappUrl, urbanismeappUrl }); + }, [onSetUp]); const { NRU, ADS } = URBANISME_TOOLS; const panelStyle = { diff --git a/js/extension/reducers/urbanisme.js b/js/extension/reducers/urbanisme.js index 427f68f..2b00c09 100644 --- a/js/extension/reducers/urbanisme.js +++ b/js/extension/reducers/urbanisme.js @@ -25,7 +25,8 @@ const initialState = { export default function urbanisme(state = initialState, action) { switch (action.type) { case SET_UP: - return set('config', action.initConfig, state); + const { cadastrappUrl, urbanismeappUrl, ...initConfig } = action.initConfig; + return set('config', initConfig, state); case SET_CONFIG: return { ...state, config: {...state.config, ...action.config }}; case TOGGLE_TOOL: diff --git a/karma.conf.continuous-test.js b/karma.conf.continuous-test.js index 80249f1..02e1ed1 100644 --- a/karma.conf.continuous-test.js +++ b/karma.conf.continuous-test.js @@ -11,6 +11,7 @@ module.exports = function karmaConfig(config) { testFile: 'tests.webpack.js', singleRun: false, alias: { + "@mapstore/patcher": path.resolve(__dirname, "node_modules", "@mapstore", "patcher"), "@mapstore": path.resolve(__dirname, "MapStore2", "web", "client"), "@js": path.resolve(__dirname, "js") } diff --git a/karma.conf.single-run.js b/karma.conf.single-run.js index 4b91871..50d3f10 100644 --- a/karma.conf.single-run.js +++ b/karma.conf.single-run.js @@ -10,20 +10,10 @@ module.exports = function karmaConfig(config) { testFile: 'tests.webpack.js', singleRun: true, alias: { + "@mapstore/patcher": path.resolve(__dirname, "node_modules", "@mapstore", "patcher"), "@mapstore": path.resolve(__dirname, "MapStore2", "web", "client"), "@js": path.resolve(__dirname, "js") } }); - testConfig.webpack.module.rules = [{ - test: /\.jsx?$/, - exclude: /(__tests__|node_modules|legacy|libs\\Cesium|libs\\html2canvas)\\|(__tests__|node_modules|legacy|libs\/Cesium|libs\/html2canvas)\/|webpack\.js|utils\/(openlayers|leaflet)/, - enforce: "post", - use: [ - { - loader: 'istanbul-instrumenter-loader', - options: { esModules: true } - } - ] - }, ...testConfig.webpack.module.rules]; config.set(testConfig); }; diff --git a/package.json b/package.json index 0b91211..6158619 100644 --- a/package.json +++ b/package.json @@ -27,19 +27,21 @@ "@babel/plugin-syntax-dynamic-import": "7.8.3", "@babel/preset-env": "7.8.7", "@babel/preset-react": "7.8.3", + "@babel/runtime": "7.11.2", "@geosolutions/acorn-jsx": "4.0.2", "@geosolutions/jsdoc": "3.4.4", "@geosolutions/mocha": "6.2.1-3", - "@mapstore/eslint-config-mapstore": "1.0.1", + "@mapstore/eslint-config-mapstore": "1.0.3", "axios-mock-adapter": "1.16.0", - "babel-istanbul-loader": "0.1.0", "babel-loader": "8.0.5", "babel-plugin-add-module-exports": "0.1.4", + "babel-plugin-istanbul": "6.0.0", "babel-plugin-object-assign": "1.2.1", "babel-plugin-react-transform": "2.0.2", - "cesium": "1.17.0", + "babel-plugin-transform-imports": "2.0.0", "copy-webpack-plugin": "^5.1.2", - "css-loader": "0.19.0", + "css-loader": "5.1.2", + "css-minimizer-webpack-plugin": "3.0.2", "denodeify": "1.2.1", "docma": "1.5.1", "download-cli": "1.0.1", @@ -67,16 +69,16 @@ "karma-mocha-reporter": "2.2.5", "karma-sourcemap-loader": "0.3.8", "karma-webpack": "^5.0.0-alpha.5", - "less": "2.7.1", - "less-loader": "4.1.0", - "mini-css-extract-plugin": "0.5.0", + "less": "4.1.1", + "less-loader": "8.0.0", + "mini-css-extract-plugin": "1.3.9", "mkdirp": "0.5.1", "ncp": "2.0.0", "parallelshell": "1.2.0", - "postcss": "7.0.14", - "postcss-loader": "3.0.0", - "postcss-prefix-selector": "1.7.1", - "process": "^0.11.10", + "postcss": "8.3.5", + "postcss-loader": "6.1.0", + "postcss-prefix-selector": "1.10.0", + "process": "0.11.10", "progress-bar-webpack-plugin": "1.12.1", "raw-loader": "0.5.1", "react-motion": "0.5.0", @@ -89,12 +91,12 @@ "redux-mock-store": "1.2.2", "rimraf": "2.5.2", "simple-git": "2.20.1", - "style-loader": "0.12.4", + "style-loader": "2.0.0", "url-loader": "0.5.7", "vusion-webfonts-generator": "0.4.1", "webpack": "5.9.0", "webpack-bundle-size-analyzer": "2.0.2", - "webpack-cli": "4.3.1", + "webpack-cli": "^4.9.0", "webpack-dev-server": "3.11.0", "zip-webpack-plugin": "^3.0.0" }, diff --git a/prod-webpack.config.js b/prod-webpack.config.js index 950d1c7..b5ddfc1 100644 --- a/prod-webpack.config.js +++ b/prod-webpack.config.js @@ -47,6 +47,7 @@ module.exports = require('./MapStore2/build/buildConfig')( }) ], { + "@mapstore/patcher": path.resolve(__dirname, "node_modules", "@mapstore", "patcher"), "@mapstore": path.resolve(__dirname, "MapStore2", "web", "client"), "@js": path.resolve(__dirname, "js") } diff --git a/webpack.config.js b/webpack.config.js index 28bda2b..bcdf835 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -26,6 +26,7 @@ const cfg = buildConfig( '.MapStoreExtension', [], { + "@mapstore/patcher": path.resolve(__dirname, "node_modules", "@mapstore", "patcher"), "@mapstore": path.resolve(__dirname, "MapStore2", "web", "client"), "@js": path.resolve(__dirname, "js") },