Skip to content
Snippets Groups Projects
Commit 10d1fffe authored by Jack Reed's avatar Jack Reed
Browse files

Enhance configuration settings so that a window can specify the sidebarPanel

parent 8218a6b0
No related branches found
No related tags found
No related merge requests found
...@@ -152,6 +152,31 @@ describe('window actions', () => { ...@@ -152,6 +152,31 @@ describe('window actions', () => {
expect(action.companionWindows[0]).toMatchObject({ content: 'thumbnailNavigation' }); expect(action.companionWindows[0]).toMatchObject({ content: 'thumbnailNavigation' });
}); });
it('enables a window to override the panel being displayed', () => {
const options = {
id: 'helloworld',
sideBarPanel: 'canvas',
};
const mockState = {
companionWindows: {},
config: {
thumbnailNavigation: {},
window: {
defaultSideBarPanel: 'info',
},
},
workspace: {},
};
const mockDispatch = jest.fn(() => ({}));
const mockGetState = jest.fn(() => mockState);
const thunk = actions.addWindow(options);
thunk(mockDispatch, mockGetState);
const action = mockDispatch.mock.calls[0][0];
expect(action.window.sideBarPanel).toEqual('canvas');
});
it('pulls a provided manifest out', () => { it('pulls a provided manifest out', () => {
const options = { const options = {
canvasIndex: 1, canvasIndex: 1,
......
...@@ -44,10 +44,12 @@ export function addWindow({ companionWindows, manifest, ...options }) { ...@@ -44,10 +44,12 @@ export function addWindow({ companionWindows, manifest, ...options }) {
), ),
]; ];
if (config.window.defaultSideBarPanel || config.window.sideBarPanel) { if (options.sideBarPanel || config.window.defaultSideBarPanel || config.window.sideBarPanel) {
defaultCompanionWindows.unshift( defaultCompanionWindows.unshift(
{ {
content: config.window.defaultSideBarPanel || config.window.sideBarPanel, content: options.sideBarPanel
|| config.window.defaultSideBarPanel
|| config.window.sideBarPanel,
default: true, default: true,
id: `cw-${uuid()}`, id: `cw-${uuid()}`,
position: 'left', position: 'left',
...@@ -72,7 +74,9 @@ export function addWindow({ companionWindows, manifest, ...options }) { ...@@ -72,7 +74,9 @@ export function addWindow({ companionWindows, manifest, ...options }) {
sideBarOpen: config.window.sideBarOpenByDefault !== undefined sideBarOpen: config.window.sideBarOpenByDefault !== undefined
? config.window.sideBarOpenByDefault ? config.window.sideBarOpenByDefault
: config.window.sideBarOpen, : config.window.sideBarOpen,
sideBarPanel: config.window.defaultSideBarPanel || config.window.sideBarPanel, sideBarPanel: options.sideBarPanel
|| config.window.defaultSideBarPanel
|| config.window.sideBarPanel,
thumbnailNavigationId: cwThumbs, thumbnailNavigationId: cwThumbs,
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment