Skip to content
Snippets Groups Projects
Unverified Commit 40b505e5 authored by Shaun Ellis's avatar Shaun Ellis Committed by GitHub
Browse files

Merge pull request #2136 from ProjectMirador/2059-window-sidebar-open

When sidebar menu is toggled, info panel is displayed by default
parents 611a85b6 7f26450a
No related branches found
No related tags found
No related merge requests found
...@@ -8,7 +8,8 @@ describe('Companion Windows', () => { ...@@ -8,7 +8,8 @@ describe('Companion Windows', () => {
await expect(page).toClick('button[aria-label="Toggle window sidebar"]'); await expect(page).toClick('button[aria-label="Toggle window sidebar"]');
await page.waitFor(1000); await page.waitFor(1000);
await expect(page).toClick('button[aria-label="Open information companion window"]'); await expect(page).toMatchElement('.mirador-companion-window-left.mirador-window-sidebar-info-panel');
await expect(page).toMatchElement('button[aria-label="Open information companion window"][aria-selected="true"]');
await expect(page).not.toMatchElement('.mirador-companion-window-right.mirador-window-sidebar-info-panel'); await expect(page).not.toMatchElement('.mirador-companion-window-right.mirador-window-sidebar-info-panel');
......
...@@ -15,20 +15,24 @@ describe('window actions', () => { ...@@ -15,20 +15,24 @@ describe('window actions', () => {
id: 'helloworld', id: 'helloworld',
canvasIndex: 1, canvasIndex: 1,
collectionIndex: 0, collectionIndex: 0,
companionWindowIds: [],
manifestId: null, manifestId: null,
maximized: false, maximized: false,
rangeId: null, rangeId: null,
thumbnailNavigationPosition: 'bottom', thumbnailNavigationPosition: 'bottom',
x: 2700, x: 2700,
y: 2700, y: 2700,
sideBarPanel: 'info',
width: 400, width: 400,
height: 400, height: 400,
rotation: null, rotation: null,
view: 'single', view: 'single',
}, },
companionWindows: [{ position: 'left', content: 'info' }],
}; };
expect(actions.addWindow(options)).toEqual(expectedAction); const action = actions.addWindow(options);
expect(action).toMatchObject(expectedAction);
expect(action.window.companionWindowIds.length).toEqual(1);
expect(action.window.companionWindowIds[0]).toEqual(action.companionWindows[0].id);
}); });
}); });
......
...@@ -20,6 +20,22 @@ describe('companionWindowsReducer', () => { ...@@ -20,6 +20,22 @@ describe('companionWindowsReducer', () => {
}); });
}); });
describe('ADD_WINDOW', () => {
it('adds default companion window(s)', () => {
const action = {
type: ActionTypes.ADD_WINDOW,
companionWindows: [{ id: 'banana', position: 'left', content: 'info' }, { id: 'Banane', position: 'right', content: 'canvas_navigation' }],
};
const beforeState = {};
const expectedState = {
banana: { id: 'banana', position: 'left', content: 'info' },
Banane: { id: 'Banane', position: 'right', content: 'canvas_navigation' },
};
expect(companionWindowsReducer(beforeState, action)).toEqual(expectedState);
});
});
describe('UPDATE_COMPANION_WINDOW', () => { describe('UPDATE_COMPANION_WINDOW', () => {
it('updates an existing companion window', () => { it('updates an existing companion window', () => {
const action = { const action = {
......
...@@ -19,6 +19,7 @@ export function focusWindow(windowId) { ...@@ -19,6 +19,7 @@ export function focusWindow(windowId) {
* @memberof ActionCreators * @memberof ActionCreators
*/ */
export function addWindow(options) { export function addWindow(options) {
const cwDefault = `cw-${uuid()}`;
const defaultOptions = { const defaultOptions = {
id: `window-${uuid()}`, id: `window-${uuid()}`,
canvasIndex: 0, canvasIndex: 0,
...@@ -30,12 +31,13 @@ export function addWindow(options) { ...@@ -30,12 +31,13 @@ export function addWindow(options) {
height: 400, height: 400,
x: 2700, x: 2700,
y: 2700, y: 2700,
companionWindowIds: [], companionWindowIds: [cwDefault],
sideBarPanel: 'info',
rotation: null, rotation: null,
view: 'single', view: 'single',
maximized: false, maximized: false,
}; };
return { type: ActionTypes.ADD_WINDOW, window: { ...defaultOptions, ...options } }; return { type: ActionTypes.ADD_WINDOW, window: { ...defaultOptions, ...options }, companionWindows: [{ id: cwDefault, position: 'left', content: 'info' }] };
} }
/** /**
......
...@@ -9,6 +9,12 @@ export function companionWindowsReducer(state = {}, action) { ...@@ -9,6 +9,12 @@ export function companionWindowsReducer(state = {}, action) {
case ActionTypes.ADD_COMPANION_WINDOW: case ActionTypes.ADD_COMPANION_WINDOW:
return setIn(state, [action.id], action.payload); return setIn(state, [action.id], action.payload);
case ActionTypes.ADD_WINDOW:
return action.companionWindows.reduce((newState, cw) => {
newState[cw.id] = cw; // eslint-disable-line no-param-reassign
return newState;
}, state);
case ActionTypes.UPDATE_COMPANION_WINDOW: case ActionTypes.UPDATE_COMPANION_WINDOW:
return updateIn(state, [action.id], orig => merge(orig, action.payload)); return updateIn(state, [action.id], orig => merge(orig, action.payload));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment