Skip to content
Snippets Groups Projects
Commit 412b8f63 authored by Chris Beer's avatar Chris Beer
Browse files

Avoid connecting plugins if they don't need it

parent e995c93c
Branches
Tags
No related merge requests found
......@@ -58,8 +58,12 @@ describe('connectPluginsToStore', () => {
const ComponentB = props => null;
const plugins = [
{ component: ComponentA, mode: 'wrap', target: 'Window' },
{ component: ComponentB, mode: 'add', target: 'TopBar' },
{
component: ComponentA, mapStateToProps: {}, mode: 'wrap', target: 'Window',
},
{
component: ComponentB, mapDispatchToProps: {}, mode: 'add', target: 'TopBar',
},
];
const result = connectPluginsToStore(plugins);
......@@ -67,6 +71,20 @@ describe('connectPluginsToStore', () => {
expect(result[0].component.displayName).toBe('Connect(ComponentA)');
expect(result[1].component.displayName).toBe('Connect(ComponentB)');
});
it('returns plugins unchanged that do not need a connection to the store', () => {
/** */
const ComponentA = props => null;
const plugins = [
{
component: ComponentA, mode: 'wrap', target: 'Window',
},
];
const result = connectPluginsToStore(plugins);
expect(result[0].component).toEqual(ComponentA);
});
});
describe('addPluginsToCompanionWindowsRegistry', () => {
......
......@@ -40,6 +40,8 @@ export function addPluginsToCompanionWindowsRegistry(plugins) {
/** Connect plugin component to state */
function connectPluginComponent(plugin) {
if (!plugin.mapStateToProps && !plugin.mapDispatchToProps) return plugin.component;
return connect(
plugin.mapStateToProps,
plugin.mapDispatchToProps,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment