2016-06-22 21:58:23 +02:00
|
|
|
import * as ActionTypes from '../../../constants';
|
2016-05-11 22:13:17 +02:00
|
|
|
|
|
|
|
const initialState = {
|
2016-07-08 20:57:22 +02:00
|
|
|
isPlaying: false,
|
2017-05-31 21:23:30 +02:00
|
|
|
isAccessibleOutputPlaying: false,
|
2016-07-14 18:47:54 +02:00
|
|
|
modalIsVisible: false,
|
2016-09-04 02:47:30 +02:00
|
|
|
sidebarIsExpanded: false,
|
2017-01-09 22:31:39 +01:00
|
|
|
consoleIsExpanded: true,
|
2016-08-30 05:23:10 +02:00
|
|
|
preferencesIsVisible: false,
|
|
|
|
projectOptionsVisible: false,
|
2016-09-07 04:37:29 +02:00
|
|
|
newFolderModalVisible: false,
|
2016-09-07 22:33:01 +02:00
|
|
|
shareModalVisible: false,
|
2019-08-28 22:08:40 +02:00
|
|
|
shareModalProjectId: 'abcd',
|
|
|
|
shareModalProjectName: 'My Cute Sketch',
|
|
|
|
shareModalProjectUsername: 'p5_user',
|
2019-08-21 20:08:08 +02:00
|
|
|
sketchlistModalVisible: false,
|
2016-09-07 23:47:22 +02:00
|
|
|
editorOptionsVisible: false,
|
2016-09-21 00:27:10 +02:00
|
|
|
keyboardShortcutVisible: false,
|
2016-09-21 00:32:26 +02:00
|
|
|
unsavedChanges: false,
|
2016-09-29 00:05:14 +02:00
|
|
|
infiniteLoop: false,
|
2016-10-06 21:45:26 +02:00
|
|
|
previewIsRefreshing: false,
|
2016-10-28 01:45:09 +02:00
|
|
|
infiniteLoopMessage: '',
|
2017-01-24 19:04:51 +01:00
|
|
|
justOpenedProject: false,
|
2016-11-29 21:51:16 +01:00
|
|
|
previousPath: '/',
|
2017-07-26 20:46:59 +02:00
|
|
|
errorType: undefined,
|
|
|
|
runtimeErrorWarningVisible: true,
|
2019-10-03 21:51:34 +02:00
|
|
|
parentId: undefined
|
2016-06-24 00:29:55 +02:00
|
|
|
};
|
2016-05-11 22:13:17 +02:00
|
|
|
|
|
|
|
const ide = (state = initialState, action) => {
|
2016-06-24 00:29:55 +02:00
|
|
|
switch (action.type) {
|
|
|
|
case ActionTypes.START_SKETCH:
|
2016-07-11 21:22:29 +02:00
|
|
|
return Object.assign({}, state, { isPlaying: true });
|
2016-06-24 00:29:55 +02:00
|
|
|
case ActionTypes.STOP_SKETCH:
|
2016-07-11 21:22:29 +02:00
|
|
|
return Object.assign({}, state, { isPlaying: false });
|
2017-05-31 21:23:30 +02:00
|
|
|
case ActionTypes.START_ACCESSIBLE_OUTPUT:
|
|
|
|
return Object.assign({}, state, { isAccessibleOutputPlaying: true });
|
|
|
|
case ActionTypes.STOP_ACCESSIBLE_OUTPUT:
|
|
|
|
return Object.assign({}, state, { isAccessibleOutputPlaying: false });
|
2016-07-18 01:06:43 +02:00
|
|
|
case ActionTypes.CONSOLE_EVENT:
|
|
|
|
return Object.assign({}, state, { consoleEvent: action.event });
|
2016-07-13 22:13:28 +02:00
|
|
|
case ActionTypes.SHOW_MODAL:
|
2019-10-03 21:51:34 +02:00
|
|
|
return Object.assign({}, state, { modalIsVisible: true, parentId: action.parentId });
|
2016-07-13 22:13:28 +02:00
|
|
|
case ActionTypes.HIDE_MODAL:
|
|
|
|
return Object.assign({}, state, { modalIsVisible: false });
|
2016-07-14 18:47:54 +02:00
|
|
|
case ActionTypes.COLLAPSE_SIDEBAR:
|
|
|
|
return Object.assign({}, state, { sidebarIsExpanded: false });
|
|
|
|
case ActionTypes.EXPAND_SIDEBAR:
|
|
|
|
return Object.assign({}, state, { sidebarIsExpanded: true });
|
2016-07-21 06:33:41 +02:00
|
|
|
case ActionTypes.COLLAPSE_CONSOLE:
|
|
|
|
return Object.assign({}, state, { consoleIsExpanded: false });
|
|
|
|
case ActionTypes.EXPAND_CONSOLE:
|
|
|
|
return Object.assign({}, state, { consoleIsExpanded: true });
|
2016-08-01 19:55:49 +02:00
|
|
|
case ActionTypes.OPEN_PREFERENCES:
|
|
|
|
return Object.assign({}, state, { preferencesIsVisible: true });
|
|
|
|
case ActionTypes.CLOSE_PREFERENCES:
|
|
|
|
return Object.assign({}, state, { preferencesIsVisible: false });
|
2016-08-12 18:45:26 +02:00
|
|
|
case ActionTypes.RESET_PROJECT:
|
|
|
|
return initialState;
|
2016-08-30 05:23:10 +02:00
|
|
|
case ActionTypes.OPEN_PROJECT_OPTIONS:
|
|
|
|
return Object.assign({}, state, { projectOptionsVisible: true });
|
|
|
|
case ActionTypes.CLOSE_PROJECT_OPTIONS:
|
|
|
|
return Object.assign({}, state, { projectOptionsVisible: false });
|
|
|
|
case ActionTypes.SHOW_NEW_FOLDER_MODAL:
|
2019-10-03 21:51:34 +02:00
|
|
|
return Object.assign({}, state, { newFolderModalVisible: true, parentId: action.parentId });
|
2016-08-30 05:23:10 +02:00
|
|
|
case ActionTypes.CLOSE_NEW_FOLDER_MODAL:
|
|
|
|
return Object.assign({}, state, { newFolderModalVisible: false });
|
2016-09-07 04:37:29 +02:00
|
|
|
case ActionTypes.SHOW_SHARE_MODAL:
|
2019-06-19 22:21:25 +02:00
|
|
|
return Object.assign({}, state, {
|
|
|
|
shareModalVisible: true,
|
|
|
|
shareModalProjectId: action.payload.shareModalProjectId,
|
|
|
|
shareModalProjectName: action.payload.shareModalProjectName,
|
|
|
|
shareModalProjectUsername: action.payload.shareModalProjectUsername,
|
|
|
|
});
|
2016-09-07 04:37:29 +02:00
|
|
|
case ActionTypes.CLOSE_SHARE_MODAL:
|
|
|
|
return Object.assign({}, state, { shareModalVisible: false });
|
2016-09-07 22:33:01 +02:00
|
|
|
case ActionTypes.SHOW_EDITOR_OPTIONS:
|
|
|
|
return Object.assign({}, state, { editorOptionsVisible: true });
|
|
|
|
case ActionTypes.CLOSE_EDITOR_OPTIONS:
|
|
|
|
return Object.assign({}, state, { editorOptionsVisible: false });
|
2016-09-07 23:47:22 +02:00
|
|
|
case ActionTypes.SHOW_KEYBOARD_SHORTCUT_MODAL:
|
|
|
|
return Object.assign({}, state, { keyboardShortcutVisible: true });
|
|
|
|
case ActionTypes.CLOSE_KEYBOARD_SHORTCUT_MODAL:
|
|
|
|
return Object.assign({}, state, { keyboardShortcutVisible: false });
|
2016-09-21 00:27:10 +02:00
|
|
|
case ActionTypes.SET_UNSAVED_CHANGES:
|
|
|
|
return Object.assign({}, state, { unsavedChanges: action.value });
|
2016-09-12 07:31:30 +02:00
|
|
|
case ActionTypes.DETECT_INFINITE_LOOPS:
|
2016-10-06 21:45:26 +02:00
|
|
|
return Object.assign({}, state, { infiniteLoop: true, infiniteLoopMessage: action.message });
|
2016-09-12 07:31:30 +02:00
|
|
|
case ActionTypes.RESET_INFINITE_LOOPS:
|
2016-10-06 21:45:26 +02:00
|
|
|
return Object.assign({}, state, { infiniteLoop: false, infiniteLoopMessage: '' });
|
2016-09-29 00:05:14 +02:00
|
|
|
case ActionTypes.START_SKETCH_REFRESH:
|
|
|
|
return Object.assign({}, state, { previewIsRefreshing: true });
|
|
|
|
case ActionTypes.END_SKETCH_REFRESH:
|
|
|
|
return Object.assign({}, state, { previewIsRefreshing: false });
|
2016-10-28 01:45:09 +02:00
|
|
|
case ActionTypes.JUST_OPENED_PROJECT:
|
|
|
|
return Object.assign({}, state, { justOpenedProject: true });
|
|
|
|
case ActionTypes.RESET_JUST_OPENED_PROJECT:
|
|
|
|
return Object.assign({}, state, { justOpenedProject: false });
|
2016-11-10 22:13:00 +01:00
|
|
|
case ActionTypes.SET_PREVIOUS_PATH:
|
|
|
|
return Object.assign({}, state, { previousPath: action.path });
|
2017-01-24 21:29:25 +01:00
|
|
|
case ActionTypes.SHOW_ERROR_MODAL:
|
|
|
|
return Object.assign({}, state, { errorType: action.modalType });
|
|
|
|
case ActionTypes.HIDE_ERROR_MODAL:
|
|
|
|
return Object.assign({}, state, { errorType: undefined });
|
2017-05-03 17:46:12 +02:00
|
|
|
case ActionTypes.SHOW_HELP_MODAL:
|
|
|
|
return Object.assign({}, state, { helpType: action.helpType });
|
|
|
|
case ActionTypes.HIDE_HELP_MODAL:
|
|
|
|
return Object.assign({}, state, { helpType: undefined });
|
2017-07-26 20:46:59 +02:00
|
|
|
case ActionTypes.HIDE_RUNTIME_ERROR_WARNING:
|
|
|
|
return Object.assign({}, state, { runtimeErrorWarningVisible: false });
|
|
|
|
case ActionTypes.SHOW_RUNTIME_ERROR_WARNING:
|
|
|
|
return Object.assign({}, state, { runtimeErrorWarningVisible: true });
|
2016-06-24 00:29:55 +02:00
|
|
|
default:
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
};
|
2016-05-11 22:13:17 +02:00
|
|
|
|
2016-06-24 00:29:55 +02:00
|
|
|
export default ide;
|