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

4944 Impossible to remove all plugins from the right list of wizard s… #4949

Merged
merged 2 commits into from
Mar 2, 2020
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
62 changes: 62 additions & 0 deletions web/client/epics/__tests__/contextcreator-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,68 @@ describe('contextcreator epics', () => {
}
}, done);
});
it('disablePluginsEpic with dependencies when value of the enabledDependentPlugins of one of the dependent children is []', (done) => {
const pluginsToDisable = ['WidgetsBuilder'];
const startActions = [disablePlugins(pluginsToDisable)];
testEpic(disablePluginsEpic, 2, startActions, actions => {
expect(actions.length).toBe(2);
expect(actions[0].type).toBe(CHANGE_PLUGINS_KEY);
expect(actions[0].ids.sort()).toEqual(['WidgetsBuilder', 'WidgetsTray']);
expect(actions[0].key).toBe('enabled');
expect(actions[0].value).toBe(false);
expect(actions[1].type).toBe(CHANGE_PLUGINS_KEY);
expect(actions[1].ids).toEqual(['WidgetsTray']);
expect(actions[1].key).toBe('forcedMandatory');
expect(actions[1].value).toBe(false);
}, {
contextcreator: {
plugins: [{
name: 'Widgets',
dependencies: [],
enabledDependentPlugins: [],
enabled: true,
isUserPlugin: false,
active: false,
children: [{
name: 'WidgetsBuilder',
dependencies: ['WidgetsTray'],
enabledDependentPlugins: [],
children: [],
parent: 'Widgets',
enabled: true,
isUserPlugin: false,
active: false
}, {
name: 'WidgetsTray',
dependencies: [],
children: [],
enabledDependentPlugins: [],
forcedMandatory: true,
parent: 'Widgets',
enabled: true,
isUserPlugin: false,
active: false
}]
}, {
name: 'ZoomIn',
dependencies: [],
enabledDependentPlugins: [],
children: [],
enabled: true,
isUserPlugin: true,
active: false
}, {
name: 'ZoomOut',
dependencies: [],
enabledDependentPlugins: [],
children: [],
enabled: false,
isUserPlugin: false,
active: false
}]
}
}, done);
});
it('disablePluginsEpic with transitive dependencies', (done) => {
const pluginsToDisable = ['Widgets'];
const startActions = [disablePlugins(pluginsToDisable)];
Expand Down
2 changes: 1 addition & 1 deletion web/client/epics/contextcreator.js
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ export const disablePluginsEpic = (action$, store) => action$
}

// if there are no more plugins that are enabled and have this plugin as a dependency, unforce it
if (enabledDependentPlugins[plugin.name].length === 0 &&
if ((!enabledDependentPlugins[plugin.name] || enabledDependentPlugins[plugin.name].length === 0) &&
pluginsToDisable.reduce((result, cur) => result && cur !== plugin.name, true)
) {
depsToUnforceMandatory.push(plugin.name);
Expand Down