Skip to content
Snippets Groups Projects
Unverified Commit 9540b316 authored by Chris Beer's avatar Chris Beer Committed by GitHub
Browse files

Merge pull request #1812 from ProjectMirador/refactor-fullscreen-action-naming

Rename things in the context of fullscreen action.
parents b7414c4b 2cecbbca
No related branches found
No related tags found
No related merge requests found
......@@ -2,15 +2,22 @@ import * as actions from '../../../src/state/actions';
import ActionTypes from '../../../src/state/actions/action-types';
describe('workspace actions', () => {
describe('fullscreenWorkspace', () => {
it('should create a new window with merged defaults', () => {
const options = true;
describe('setWorkspaceFullscreen', () => {
it('should return correct action type if set to true', () => {
const receivedAction = actions.setWorkspaceFullscreen(true);
const expectedAction = {
type: ActionTypes.SET_WORKSPACE_FULLSCREEN,
isFullscreenEnabled: true,
};
expect(receivedAction).toEqual(expectedAction);
});
it('should return correct action type if set to false', () => {
const receivedAction = actions.setWorkspaceFullscreen(false);
const expectedAction = {
type: ActionTypes.FULLSCREEN_WORKSPACE,
fullscreen: true,
type: ActionTypes.SET_WORKSPACE_FULLSCREEN,
isFullscreenEnabled: false,
};
expect(actions.fullscreenWorkspace(options)).toEqual(expectedAction);
expect(receivedAction).toEqual(expectedAction);
});
});
describe('updateWorkspaceMosaicLayout', () => {
......
......@@ -9,8 +9,8 @@ describe('App', () => {
});
describe('FullScreen', () => {
it('is enabled by the workspace.fullscreen state', () => {
const wrapper = shallow(<App manifests={[]} workspace={{ fullscreen: true }} />);
it('is enabled by the workspace.isFullscreenEnabled state', () => {
const wrapper = shallow(<App manifests={[]} workspace={{ isFullscreenEnabled: true }} />);
expect(wrapper.find('FullScreen').first().prop('enabled')).toEqual(true);
});
});
......
......@@ -4,11 +4,11 @@ import WorkspaceFullScreenButton from '../../../src/components/WorkspaceFullScre
describe('WorkspaceFullScreenButton', () => {
let wrapper;
let fullscreenWorkspace;
let setWorkspaceFullscreen;
beforeEach(() => {
fullscreenWorkspace = jest.fn();
setWorkspaceFullscreen = jest.fn();
wrapper = shallow(
<WorkspaceFullScreenButton classes={{}} fullscreenWorkspace={fullscreenWorkspace} />,
<WorkspaceFullScreenButton classes={{}} setWorkspaceFullscreen={setWorkspaceFullscreen} />,
).dive();
});
......@@ -17,6 +17,6 @@ describe('WorkspaceFullScreenButton', () => {
});
it('when clicked, sets the fullscreen state', () => {
wrapper.find('WithStyles(IconButton)').simulate('click');
expect(fullscreenWorkspace).toHaveBeenCalledWith(true);
expect(setWorkspaceFullscreen).toHaveBeenCalledWith(true);
});
});
......@@ -10,12 +10,12 @@ describe('workspace reducer', () => {
focusedWindowId: 'abc123',
});
});
it('should handle FULLSCREEN_WORKSPACE', () => {
it('should handle SET_WORKSPACE_FULLSCREEN', () => {
expect(reducer([], {
type: ActionTypes.FULLSCREEN_WORKSPACE,
fullscreen: true,
type: ActionTypes.SET_WORKSPACE_FULLSCREEN,
isFullscreenEnabled: true,
})).toEqual({
fullscreen: true,
isFullscreenEnabled: true,
});
});
it('should handle UPDATE_WORKSPACE_MOSAIC_LAYOUT', () => {
......
......@@ -16,13 +16,13 @@ class App extends Component {
* @return {String} - HTML markup for the component
*/
render() {
const { workspace, fullscreenWorkspace } = this.props;
const { workspace, setWorkspaceFullscreen } = this.props;
return (
<div className={ns('app')}>
<CssBaseline />
<Fullscreen
enabled={workspace.fullscreen}
onChange={isFullscreenEnabled => fullscreenWorkspace(isFullscreenEnabled)}
enabled={workspace.isFullscreenEnabled}
onChange={isFullscreenEnabled => setWorkspaceFullscreen(isFullscreenEnabled)}
>
<Workspace />
</Fullscreen>
......@@ -34,12 +34,12 @@ class App extends Component {
App.propTypes = {
workspace: PropTypes.object, // eslint-disable-line react/forbid-prop-types
fullscreenWorkspace: PropTypes.func,
setWorkspaceFullscreen: PropTypes.func,
};
App.defaultProps = {
workspace: {},
fullscreenWorkspace: () => {},
setWorkspaceFullscreen: () => {},
};
export default App;
......@@ -13,10 +13,10 @@ class WorkspaceFullScreenButton extends Component {
* @return
*/
render() {
const { classes, fullscreenWorkspace } = this.props;
const { classes, setWorkspaceFullscreen } = this.props;
return (
<ListItem>
<IconButton className={classes.ctrlBtn} aria-label="Full Screen" onClick={() => fullscreenWorkspace(true)}>
<IconButton className={classes.ctrlBtn} aria-label="Full Screen" onClick={() => setWorkspaceFullscreen(true)}>
<FullscreenIcon />
</IconButton>
</ListItem>
......@@ -25,7 +25,7 @@ class WorkspaceFullScreenButton extends Component {
}
WorkspaceFullScreenButton.propTypes = {
fullscreenWorkspace: PropTypes.func.isRequired,
setWorkspaceFullscreen: PropTypes.func.isRequired,
classes: PropTypes.object.isRequired, // eslint-disable-line react/forbid-prop-types
};
......
......@@ -22,7 +22,7 @@ const mapStateToProps = state => (
*/
const mapDispatchToProps = {
fetchManifest: actions.fetchManifest,
fullscreenWorkspace: actions.fullscreenWorkspace,
setWorkspaceFullscreen: actions.setWorkspaceFullscreen,
};
const enhance = compose(
......
......@@ -8,6 +8,6 @@ import WorkspaceFullScreenButton
* @memberof ManifestListItem
* @private
*/
const mapDispatchToProps = { fullscreenWorkspace: actions.fullscreenWorkspace };
const mapDispatchToProps = { setWorkspaceFullscreen: actions.setWorkspaceFullscreen };
export default connect(null, mapDispatchToProps)(WorkspaceFullScreenButton);
const ActionTypes = {
FOCUS_WINDOW: 'FOCUS_WINDOW',
FULLSCREEN_WORKSPACE: 'FULLSCREEN_WORKSPACE',
SET_WORKSPACE_FULLSCREEN: 'SET_WORKSPACE_FULLSCREEN',
ADD_MANIFEST: 'ADD_MANIFEST',
ADD_WINDOW: 'ADD_WINDOW',
NEXT_CANVAS: 'NEXT_CANVAS',
......
......@@ -2,13 +2,13 @@ import ActionTypes from './action-types';
/* eslint-disable import/prefer-default-export */
/**
* fullscreenWorkspace - action creator
* setWorkspaceFullscreen - action creator
*
* @param {String} windowId
* @param {Boolean} isFullscreenEnabled
* @memberof ActionCreators
*/
export function fullscreenWorkspace(fullscreen) {
return { type: ActionTypes.FULLSCREEN_WORKSPACE, fullscreen };
export function setWorkspaceFullscreen(isFullscreenEnabled) {
return { type: ActionTypes.SET_WORKSPACE_FULLSCREEN, isFullscreenEnabled };
}
/**
......
......@@ -7,8 +7,8 @@ const workspaceReducer = (state = {}, action) => {
switch (action.type) {
case ActionTypes.FOCUS_WINDOW:
return { ...state, focusedWindowId: action.windowId };
case ActionTypes.FULLSCREEN_WORKSPACE:
return { ...state, fullscreen: action.fullscreen };
case ActionTypes.SET_WORKSPACE_FULLSCREEN:
return { ...state, isFullscreenEnabled: action.isFullscreenEnabled };
case ActionTypes.UPDATE_WORKSPACE_MOSAIC_LAYOUT:
return { ...state, layout: action.layout };
default:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment