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

Simplify the update action passed to the companion window

parent 15e89ba4
No related branches found
No related tags found
No related merge requests found
......@@ -43,7 +43,7 @@ describe('CompanionWindow', () => {
const button = companionWindow.find(MiradorMenuButton);
button.props().onClick(); // Trigger the onClick prop
expect(updateCompanionWindow).toHaveBeenCalledTimes(1);
expect(updateCompanionWindow).toHaveBeenCalledWith('x', 'abc123', { position: 'right' });
expect(updateCompanionWindow).toHaveBeenCalledWith({ position: 'right' });
});
});
......@@ -94,7 +94,7 @@ describe('CompanionWindow', () => {
const button = companionWindow.find(MiradorMenuButton).first();
button.props().onClick(); // Trigger the onClick prop
expect(updateCompanionWindow).toHaveBeenCalledTimes(1);
expect(updateCompanionWindow).toHaveBeenCalledWith('x', 'abc123', { position: 'bottom' });
expect(updateCompanionWindow).toHaveBeenCalledWith({ position: 'bottom' });
});
describe('when the companion window is on the bottom', () => {
......@@ -109,7 +109,7 @@ describe('CompanionWindow', () => {
const button = companionWindow.find(MiradorMenuButton).first();
button.props().onClick(); // Trigger the onClick prop
expect(updateCompanionWindow).toHaveBeenCalledTimes(1);
expect(updateCompanionWindow).toHaveBeenCalledWith('x', 'abc123', { position: 'right' });
expect(updateCompanionWindow).toHaveBeenCalledWith({ position: 'right' });
});
it('renders title controls when available', () => {
......
......@@ -67,8 +67,8 @@ export class CompanionWindow extends Component {
*/
render() {
const {
ariaLabel, classes, paperClassName, id, onCloseClick, updateCompanionWindow, isDisplayed,
position, t, windowId, title, children, titleControls, size,
ariaLabel, classes, paperClassName, onCloseClick, updateCompanionWindow, isDisplayed,
position, t, title, children, titleControls, size,
defaultSidebarPanelWidth, defaultSidebarPanelHeight,
} = this.props;
......@@ -128,7 +128,7 @@ export class CompanionWindow extends Component {
&& (
<MiradorMenuButton
aria-label={t('openInCompanionWindow')}
onClick={() => { updateCompanionWindow(windowId, id, { position: 'right' }); }}
onClick={() => { updateCompanionWindow({ position: 'right' }); }}
>
<OpenInNewIcon style={this.openInNewStyle()} />
</MiradorMenuButton>
......@@ -140,7 +140,7 @@ export class CompanionWindow extends Component {
<MiradorMenuButton
aria-label={position === 'bottom' ? t('moveCompanionWindowToRight') : t('moveCompanionWindowToBottom')}
className={classes.positionButton}
onClick={() => { updateCompanionWindow(windowId, id, { position: position === 'bottom' ? 'right' : 'bottom' }); }}
onClick={() => { updateCompanionWindow({ position: position === 'bottom' ? 'right' : 'bottom' }); }}
>
<MoveIcon />
</MiradorMenuButton>
......@@ -188,7 +188,6 @@ CompanionWindow.propTypes = {
defaultSidebarPanelHeight: PropTypes.number,
defaultSidebarPanelWidth: PropTypes.number,
direction: PropTypes.string.isRequired,
id: PropTypes.string.isRequired,
isDisplayed: PropTypes.bool,
onCloseClick: PropTypes.func,
paperClassName: PropTypes.string,
......@@ -201,7 +200,6 @@ CompanionWindow.propTypes = {
]),
titleControls: PropTypes.node,
updateCompanionWindow: PropTypes.func,
windowId: PropTypes.string.isRequired,
};
CompanionWindow.defaultProps = {
......
......@@ -39,7 +39,9 @@ const mapDispatchToProps = (dispatch, { windowId, id }) => ({
onCloseClick: () => dispatch(
actions.removeCompanionWindow(windowId, id),
),
updateCompanionWindow: (...args) => dispatch(actions.updateCompanionWindow(...args)),
updateCompanionWindow: (...args) => dispatch(
actions.updateCompanionWindow(windowId, id, ...args),
),
});
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment