Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Converting extension to use dynamic import by default (module plugin mode), updating upstream to the latest master branch #36

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion MapStore2
Submodule MapStore2 updated 118 files
52 changes: 3 additions & 49 deletions js/extension/plugins/Extension.jsx
Original file line number Diff line number Diff line change
@@ -1,50 +1,4 @@
import {connect} from "react-redux";
import { name } from '../../../config';
import {toModulePlugin} from "@mapstore/utils/ModulePluginsUtils";
import {name} from "../../../config";

import ExtensionComponent from "../components/Component";
import Rx from "rxjs";
import { changeZoomLevel } from "@mapstore/actions/map";

import '../assets/style.css';
export default {
name,
component: connect(state => ({
value: state.sampleExtension && state.sampleExtension.value
}), {
onIncrease: () => {
return {
type: 'INCREASE_COUNTER'
};
}, changeZoomLevel
})(ExtensionComponent),
reducers: {
sampleExtension: (state = { value: 1 }, action) => {
if (action.type === 'INCREASE_COUNTER') {
return { value: state.value + 1 };
}
return state;
}
},
epics: {
logCounterValue: (action$, store) => action$.ofType('INCREASE_COUNTER').switchMap(() => {
/* eslint-disable */
console.log('CURRENT VALUE: ' + store.getState().sampleExtension.value);
/* eslint-enable */
return Rx.Observable.empty();
})
},
containers: {
Toolbar: {
name: "sampleExtension",
position: 10,
text: "INC",
doNotHide: true,
action: () => {
return {
type: 'INCREASE_COUNTER'
};
},
priority: 1
}
}
};
export default toModulePlugin(name, () => import(/* webpackChunkName: 'extension' */ './Module'));
offtherailz marked this conversation as resolved.
Show resolved Hide resolved
51 changes: 51 additions & 0 deletions js/extension/plugins/Module.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import {connect} from "react-redux";
import { name } from '../../../config';

import {createPlugin} from "@mapstore/utils/PluginsUtils";
import ExtensionComponent from "../components/Component";
import Rx from "rxjs";

import { changeZoomLevel } from "@mapstore/actions/map";
import '../assets/style.css';

export default createPlugin(name, {
component: connect(state => ({
value: state.sampleExtension && state.sampleExtension.value
}), {
onIncrease: () => {
return {
type: 'INCREASE_COUNTER'
};
}, changeZoomLevel
})(ExtensionComponent),
reducers: {
sampleExtension: (state = { value: 1 }, action) => {
if (action.type === 'INCREASE_COUNTER') {
return { value: state.value + 1 };
}
return state;
}
},
epics: {
logCounterValue: (action$, store) => action$.ofType('INCREASE_COUNTER').switchMap(() => {
/* eslint-disable */
console.log('CURRENT VALUE: ' + store.getState().sampleExtension.value);
/* eslint-enable */
return Rx.Observable.empty();
})
},
containers: {
Toolbar: {
name: "sampleExtension",
position: 10,
text: "INC",
doNotHide: true,
action: () => {
return {
type: 'INCREASE_COUNTER'
};
},
priority: 1
}
}
});
3 changes: 1 addition & 2 deletions js/extensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@
* LICENSE file in the root directory of this source tree.
*/

import { createPlugin } from "@mapstore/utils/PluginsUtils";
import Extension from './extension/plugins/Extension';
import { name } from '../config';


export default {
[name]: createPlugin(name, Extension)
[name]: Extension
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now createPlugin is called directly in extension recall system in MapStore, isn't it?

I'd like to ask you, as a double check, if we can still use old extensions with the new MapStore, if the createPlugin has been moved.
Can you confirm we can install an old or a new extension in the new MapStore?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tdipisa @offtherailz Yes, there is an explicit check for the way of extension export. Old extensions just go through initialization process as before, while new extensions exported as a module will hit this check here geosolutions-it/MapStore2@4005b4e#diff-8940694ab1df4f2163502cdeaf4956a59db143ea8ebf133ddf771ea23d4250cfR157

Just to confirm, here is the context on dev running cadastrapp (it won't load layers because of missing backend path, but anyway, plugins is registered, rendered etc.) and sample extension converted to be registered as module plugin.
https://dev-mapstore.geosolutionsgroup.com/mapstore/#/context/cadastrapp_and_sample

};