diff --git a/src/containers/gui.jsx b/src/containers/gui.jsx index 2d74e21c2428bed32fd42da05ae2a6a4450207bb..2076286e3b315cdd36197b8d79343aa1ea5b40bc 100644 --- a/src/containers/gui.jsx +++ b/src/containers/gui.jsx @@ -66,12 +66,12 @@ class GUI extends React.Component { render () { if (this.props.isError) { throw new Error( - `Failed to load project from server [id=${window.location.hash}]: ${this.props.errStr}`); + `Failed to load project from server [id=${window.location.hash}]: ${this.props.errorMessage}`); } const { /* eslint-disable no-unused-vars */ assetHost, - errStr, + errorMessage, hideIntro, isError, isShowingProject, @@ -101,12 +101,12 @@ class GUI extends React.Component { GUI.propTypes = { assetHost: PropTypes.string, children: PropTypes.node, - errStr: PropTypes.string, + errorMessage: PropTypes.string, fetchingProject: PropTypes.bool, hideIntro: PropTypes.bool, importInfoVisible: PropTypes.bool, - isError: PropTypes.bool, intl: intlShape, + isError: PropTypes.bool, isLoading: PropTypes.bool, isShowingProject: PropTypes.bool, loadingStateVisible: PropTypes.bool, @@ -136,7 +136,7 @@ const mapStateToProps = (state, ownProps) => { cardsVisible: state.scratchGui.cards.visible, costumeLibraryVisible: state.scratchGui.modals.costumeLibrary, costumesTabVisible: state.scratchGui.editorTab.activeTabIndex === COSTUMES_TAB_INDEX, - errStr: state.scratchGui.projectState.errStr, + errorMessage: state.scratchGui.projectState.errorMessage, importInfoVisible: state.scratchGui.modals.importInfo, isError: getIsError(loadingState), isPlayerOnly: state.scratchGui.mode.isPlayerOnly, diff --git a/src/lib/project-fetcher-hoc.jsx b/src/lib/project-fetcher-hoc.jsx index 20fb80602e771d7223aa533079b955d25661b3ea..1a8322a071c214088249e5cad4b4137c5f3bcc94 100644 --- a/src/lib/project-fetcher-hoc.jsx +++ b/src/lib/project-fetcher-hoc.jsx @@ -126,7 +126,7 @@ const ProjectFetcherHOC = function (WrappedComponent) { reduxProjectId: state.scratchGui.projectState.projectId }); const mapDispatchToProps = dispatch => ({ - onError: errStr => dispatch(onError(errStr)), + onError: errorMessage => dispatch(onError(errorMessage)), onFetchedProjectData: (projectData, loadingState) => dispatch(onFetchedProjectData(projectData, loadingState)), setProjectId: projectId => dispatch(setProjectId(projectId)) diff --git a/src/lib/project-saver-hoc.jsx b/src/lib/project-saver-hoc.jsx index 5bc15f1d5b6fe2b40afc9fe45e909d1471d15cd2..6d85eca4c005603c3848045d79419b6a8fa3ea35 100644 --- a/src/lib/project-saver-hoc.jsx +++ b/src/lib/project-saver-hoc.jsx @@ -141,7 +141,7 @@ const ProjectSaverHOC = function (WrappedComponent) { createProject: () => dispatch(createProject()), onCreated: projectId => dispatch(onCreated(projectId)), onUpdated: (projectId, loadingState) => dispatch(onUpdated(projectId, loadingState)), - onError: errStr => dispatch(onError(errStr)), + onError: errorMessage => dispatch(onError(errorMessage)), saveProject: () => dispatch(saveProject()) }); // Allow incoming props to override redux-provided props. Used to mock in tests. diff --git a/src/lib/vm-manager-hoc.jsx b/src/lib/vm-manager-hoc.jsx index 20271706d4a584b5a34f598dd267726bab3e410c..6e1d0125cf04f10e35484aebebfebf4f569c2e2a 100644 --- a/src/lib/vm-manager-hoc.jsx +++ b/src/lib/vm-manager-hoc.jsx @@ -97,7 +97,7 @@ const vmManagerHOC = function (WrappedComponent) { }; const mapDispatchToProps = dispatch => ({ - onError: errStr => dispatch(onError(errStr)), + onError: errorMessage => dispatch(onError(errorMessage)), onLoadedProject: (loadingState, canSave) => dispatch(onLoadedProject(loadingState, canSave)) }); diff --git a/src/reducers/project-state.js b/src/reducers/project-state.js index 1b80fd3e481ce92c6b55124273489dc92f7df41d..9ade631624b676b90721edc15ef0403e4f3e0e57 100644 --- a/src/reducers/project-state.js +++ b/src/reducers/project-state.js @@ -70,7 +70,7 @@ const getIsError = loadingState => ( ); const initialState = { - errStr: null, + errorMessage: null, projectData: null, projectId: null, loadingState: LoadingState.NOT_LOADED @@ -224,7 +224,7 @@ const reducer = function (state, action) { ].includes(state.loadingState)) { return Object.assign({}, state, { loadingState: LoadingState.ERROR, - errStr: action.errStr + errorMessage: action.errorMessage }); } return state; @@ -298,9 +298,9 @@ const onUpdated = loadingState => { } }; -const onError = errStr => ({ +const onError = errorMessage => ({ type: GO_TO_ERROR_STATE, - errStr: errStr + errorMessage: errorMessage }); const setProjectId = id => ({ diff --git a/test/unit/reducers/project-state-reducer.test.js b/test/unit/reducers/project-state-reducer.test.js index c91d1909cca70344c3e5ae6d4db3680cd8fefdcc..81f2d2c0c96611c2b0c54a49a6ebf7e627f06eb1 100644 --- a/test/unit/reducers/project-state-reducer.test.js +++ b/test/unit/reducers/project-state-reducer.test.js @@ -17,7 +17,7 @@ test('initialState', () => { let defaultState; /* projectStateReducer(state, action) */ expect(projectStateReducer(defaultState, {type: 'anything'})).toBeDefined(); - expect(projectStateReducer(defaultState, {type: 'anything'}).errStr).toBe(null); + expect(projectStateReducer(defaultState, {type: 'anything'}).errorMessage).toBe(null); expect(projectStateReducer(defaultState, {type: 'anything'}).projectData).toBe(null); expect(projectStateReducer(defaultState, {type: 'anything'}).projectId).toBe(null); expect(projectStateReducer(defaultState, {type: 'anything'}).loadingState).toBe(LoadingState.NOT_LOADED); @@ -229,23 +229,23 @@ test('onError from various states should show error', () => { ]; for (const startState of startStates) { const initialState = { - errStr: null, + errorMessage: null, loadingState: startState }; const action = onError('Error string'); const resultState = projectStateReducer(initialState, action); expect(resultState.loadingState).toBe(LoadingState.ERROR); - expect(resultState.errStr).toBe('Error string'); + expect(resultState.errorMessage).toBe('Error string'); } }); test('onError from showing project should show error', () => { const initialState = { - errStr: null, + errorMessage: null, loadingState: LoadingState.FETCHING_WITH_ID }; const action = onError('Error string'); const resultState = projectStateReducer(initialState, action); expect(resultState.loadingState).toBe(LoadingState.ERROR); - expect(resultState.errStr).toBe('Error string'); + expect(resultState.errorMessage).toBe('Error string'); });