-
Notifications
You must be signed in to change notification settings - Fork 410
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
8423 Modular plugins #8457
8423 Modular plugins #8457
Conversation
- ReducerManager, updated StandardStore to use it.
Passing lazy plugins into PluginsContainer component.
Share plugin definition fix.
Re-use plugins cache whenever hook is used by a new PluginsContainer instance. Cleanup, making user manager page works again.
- Moving Module plugin utils into separate file - Naming conventions: Lazy loaded plugins are "Module plugins"
MapViewerCmp was dispatching INIT_MAP action unconditionally on component mount. This was happening prior to the dynamically imported epics were registered. Therefore, some epics missed INIT_MAP action and were not running when they should. This behavior is slightly changed, MapViewerCmp will instead set a state variable holding a function that needs to run whenever plugins are mounted. State value is passed down to the withModulePlugins wrapper of PluginsContainer and function is running whenever PluginsContainer is ready to be rendered.
…ded whenever MapsPlugin is converted into lazy one. The problem was caused by loadMaps action being dispatched on page mount, again, while dynamically loaded epics are not registered yet. With the change, action will be dispatched by PluginsContainer, when it is mounted on the page. And this will happen after module plugins are successfully loaded.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The implementation seems good, most of the comments are related to naming, questions or typos.
Before to proceed with the issue related with specific plugin I would suggest to complete the support for extension, once we have also that support I'll do another round of test.
We should also verify the final bundles sizes with the webpack analyzer after this initial work
@@ -101,10 +101,10 @@ function withExtensions(AppComponent) { | |||
}; | |||
|
|||
render() { | |||
const { plugins, requires } = this.props.pluginsDef; | |||
const { plugins, ...rest } = this.props.pluginsDef; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const { plugins, ...rest } = this.props.pluginsDef; | |
const { plugins, requires } = this.props.pluginsDef; |
export default compose( | ||
connect((state) => ({ | ||
mode: urlQuery.mode || (urlQuery.mobile || state.browser && state.browser.mobile ? 'mobile' : 'desktop') | ||
})), | ||
withModulePlugins() | ||
)(PluginsContainer); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should add connect or redux in components folder. So please remove all the connect.
Could we also export plugin without HOC?
export const PluginsContainer;
export default withModulePlugins(PluginsContainer);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you mean we should not add? I removed connect and moved it instead into HOC.
Export with HOC allows to simplify usage of resulting component on a list of pages. In a few places import + usage of connect is replaced now with only import; another places doing connect to a fewer list of state values. It also makes code a bit more error-proof.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need the connect also in the HOC?
We are already connecting everything in the page, both hook, HOC and component should not have connect
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As agreed in a call, applied solution with having separate container "ModulePluginsContainer" specifically for MapStore pages. This container is wrapped by a "withModulePlugins" HOC to support processing of module plugins.
web/client/containers/MapViewer.jsx
Outdated
}), | ||
monitoredState: getMonitoredState(state, ConfigUtils.getConfigProp('monitorState')) | ||
}))(require('../components/plugins/PluginsContainer').default); | ||
const PluginsContainer = compose( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can remove compose now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, removed
web/client/utils/StateUtils.js
Outdated
// const fetchEpic = (storeName = PERSISTED_STORE_NAME, name = 'rootEpic') => { | ||
// return ConfigUtils.getConfigProp(storeName + '.' + name) || {}; | ||
// }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we remove this including the relative doc?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
web/client/utils/StateUtils.js
Outdated
addEpics: (key, epicsList) => { | ||
muteState[key] = new Subject(); | ||
const isolatedEpics = isolateEpics(epicsList, muteState[key].asObservable()); | ||
// wrapEpics(isolateEpics(epicsList, muteState[key].asObservable())).forEach(epic => epic$.next(epic)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this code still needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed commented line
this.setState({ initMap: () => { | ||
this.updateMap(id, contextId); | ||
this.setState({initMap: null}); | ||
}}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on the pvt discussion we should do the follow:
- revert this fix for the moment with all related code around
- plugin that has still issue because of this should be kept static for the moment
- once we have the list with all the problematic plugins we can evaluate how to proceed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rolled back, list of plugins is to be added in the comment down below in PR.
@@ -6,138 +6,143 @@ | |||
* LICENSE file in the root directory of this source tree. | |||
*/ | |||
|
|||
import {toModulePlugin} from "../utils/ModulePluginsUtils"; | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please replace require with import for static plugins
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replaced
…eing loaded whenever MapsPlugin is converted into lazy one. The problem was caused by loadMaps action being dispatched on page mount, again, while dynamically loaded epics are not registered yet. With the change, action will be dispatched by PluginsContainer, when it is mounted on the page. And this will happen after module plugins are successfully loaded." This reverts commit c50f557
… properly. MapViewerCmp was dispatching INIT_MAP action unconditionally on component mount. This was happening prior to the dynamically imported epics were registered. Therefore, some epics missed INIT_MAP action and were not running when they should. This behavior is slightly changed, MapViewerCmp will instead set a state variable holding a function that needs to run whenever plugins are mounted. State value is passed down to the withModulePlugins wrapper of PluginsContainer and function is running whenever PluginsContainer is ready to be rendered." This reverts commit 784c483
…Included common values from state into definition so usage of PluginsContainer on page components become shorter and simpler.
- Fixes for test coverage.
We will test this once merged
ok, good
I think we can keep them as appReducers, they haven't effect on app size, We will open a separate issue to solve the configuration for these plugins
We will open a separate issue to investigate properly on the css-tree import
good, waiting for this latest update for the final review, thanks |
Wonderful @allyoucanmap and @alexander-fedorenko. @alexander-fedorenko I'm looking forward to receiving the last update soon to start the testing phase in DEV with @ElenaGallo. |
- Restored augmentStore but marked it as deprecated
@tdipisa @allyoucanmap Documentation update is committed. There are two new documentation chapters. |
@ElenaGallo let's schedule a call to discuss about this and schedule the testing phase in DEV. |
@ElenaGallo after the test phase the update provided through this PR will need to be backported to 2022.02.xx to be included in the release 2022.02.00 |
Just a note about this:
Summarizing, |
(cherry picked from commit 4005b4e)
Description
This PR introduces support of module plugins.
See #8423 and https://github.com/geosolutions-it/MapStore2/wiki/%5BProposal%5D-MapStore-Modular-Plugins
for more details.
Please check if the PR fulfills these requirements
What kind of change does this PR introduce? (check one with "x", remove the others)
Issue
What is the current behavior?
#8423
What is the new behavior?
MapStore supports module plugins. Plugin implementation is loaded dynamically on demand.
Breaking change
Does this PR introduce a breaking change? (check one with "x", remove the other)
Other useful information