Skip to content

Commit

Permalink
Filter plugins direct rendering when disabled, get current state duri…
Browse files Browse the repository at this point in the history
…ng loading phase
  • Loading branch information
offtherailz committed May 15, 2017
1 parent c4112e5 commit 5b4e101
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions web/client/components/plugins/PluginsContainer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,11 @@ const PluginsContainer = React.createClass({
this.loadPlugins(this.props.pluginsState);
},
componentWillReceiveProps(newProps) {
this.loadPlugins(newProps.pluginsState);
this.loadPlugins(newProps.pluginsState, newProps);
},
getState(path) {
return get(this.props.monitoredState, path) || get(this.props.params, path) || this.context[path];
getState(path, newProps) {
let props = newProps || this.props;
return get(props.monitoredState, path) || get(this.props.params, path) || this.context[path];
},
getPluginDescriptor(plugin) {
return PluginsUtils.getPluginDescriptor(this.getState, this.props.plugins,
Expand All @@ -79,6 +80,7 @@ const PluginsContainer = React.createClass({
.filter((Plugin) => !PluginsUtils.handleExpression(this.getState, this.props.plugins && this.props.plugins.requires, Plugin.hide))
.map(this.getPluginDescriptor)
.filter((Plugin) => Plugin && !Plugin.impl.loadPlugin)
.filter(plugin => PluginsUtils.filterDisabledPlugins({plugin: plugin && plugin.impl || plugin}, this.getState))
.filter(this.filterPlugins)
.map((Plugin) => <Plugin.impl key={Plugin.id}
{...this.props.params} {...Plugin.cfg} pluginCfg={Plugin.cfg} items={Plugin.items}/>);
Expand All @@ -99,11 +101,12 @@ const PluginsContainer = React.createClass({
const container = PluginsUtils.getMorePrioritizedContainer(Plugin.impl, this.props.pluginsConfig[this.props.mode], 0);
return !container.plugin || !container.plugin.impl || container.plugin.impl.doNotHide;
},
loadPlugins(state) {
loadPlugins(state, newProps) {
const getState = (path) => this.getState(path, newProps);
(this.props.pluginsConfig && this.props.pluginsConfig[this.props.mode] || [])
.map((plugin) => PluginsUtils.getPluginDescriptor(this.getState, this.props.plugins,
.map((plugin) => PluginsUtils.getPluginDescriptor(getState, this.props.plugins,
this.props.pluginsConfig[this.props.mode], plugin, this.state.loadedPlugins))
.filter(plugin => PluginsUtils.filterDisabledPlugins({plugin: plugin && plugin.impl || plugin}, this.getState))
.filter(plugin => PluginsUtils.filterDisabledPlugins({plugin: plugin && plugin.impl || plugin}, getState))
.filter((plugin) => plugin && plugin.impl.loadPlugin).forEach((plugin) => {
if (!this.state.loadedPlugins[plugin.name]) {
if (!plugin.impl.enabler || plugin.impl.enabler(state)) {
Expand Down

0 comments on commit 5b4e101

Please sign in to comment.