p5.js-web-editor/client/modules/IDE/reducers/ide.js

117 lines
5.2 KiB
JavaScript
Raw Normal View History

2016-06-22 19:58:23 +00:00
import * as ActionTypes from '../../../constants';
2016-05-11 20:13:17 +00:00
const initialState = {
2016-07-08 18:57:22 +00:00
isPlaying: false,
isAccessibleOutputPlaying: false,
2016-07-14 16:47:54 +00:00
modalIsVisible: false,
2016-09-04 00:47:30 +00:00
sidebarIsExpanded: false,
consoleIsExpanded: true,
2016-08-30 03:23:10 +00:00
preferencesIsVisible: false,
projectOptionsVisible: false,
2016-09-07 02:37:29 +00:00
newFolderModalVisible: false,
2016-09-07 20:33:01 +00:00
shareModalVisible: false,
shareModalProjectId: 'abcd',
shareModalProjectName: 'My Cute Sketch',
shareModalProjectUsername: 'p5_user',
2016-09-07 21:47:22 +00:00
editorOptionsVisible: false,
keyboardShortcutVisible: false,
2016-09-20 22:32:26 +00:00
unsavedChanges: false,
2016-09-28 22:05:14 +00:00
infiniteLoop: false,
previewIsRefreshing: false,
infiniteLoopMessage: '',
justOpenedProject: false,
previousPath: '/',
errorType: undefined,
runtimeErrorWarningVisible: true,
2016-06-23 22:29:55 +00:00
};
2016-05-11 20:13:17 +00:00
const ide = (state = initialState, action) => {
2016-06-23 22:29:55 +00:00
switch (action.type) {
case ActionTypes.START_SKETCH:
2016-07-11 19:22:29 +00:00
return Object.assign({}, state, { isPlaying: true });
2016-06-23 22:29:55 +00:00
case ActionTypes.STOP_SKETCH:
2016-07-11 19:22:29 +00:00
return Object.assign({}, state, { isPlaying: false });
case ActionTypes.START_ACCESSIBLE_OUTPUT:
return Object.assign({}, state, { isAccessibleOutputPlaying: true });
case ActionTypes.STOP_ACCESSIBLE_OUTPUT:
return Object.assign({}, state, { isAccessibleOutputPlaying: false });
case ActionTypes.CONSOLE_EVENT:
return Object.assign({}, state, { consoleEvent: action.event });
case ActionTypes.SHOW_MODAL:
return Object.assign({}, state, { modalIsVisible: true });
case ActionTypes.HIDE_MODAL:
return Object.assign({}, state, { modalIsVisible: false });
2016-07-14 16:47:54 +00:00
case ActionTypes.COLLAPSE_SIDEBAR:
return Object.assign({}, state, { sidebarIsExpanded: false });
case ActionTypes.EXPAND_SIDEBAR:
return Object.assign({}, state, { sidebarIsExpanded: true });
case ActionTypes.COLLAPSE_CONSOLE:
return Object.assign({}, state, { consoleIsExpanded: false });
case ActionTypes.EXPAND_CONSOLE:
return Object.assign({}, state, { consoleIsExpanded: true });
case ActionTypes.OPEN_PREFERENCES:
return Object.assign({}, state, { preferencesIsVisible: true });
case ActionTypes.CLOSE_PREFERENCES:
return Object.assign({}, state, { preferencesIsVisible: false });
case ActionTypes.RESET_PROJECT:
return initialState;
2016-08-30 03:23:10 +00: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:
return Object.assign({}, state, { newFolderModalVisible: true });
case ActionTypes.CLOSE_NEW_FOLDER_MODAL:
return Object.assign({}, state, { newFolderModalVisible: false });
2016-09-07 02:37:29 +00:00
case ActionTypes.SHOW_SHARE_MODAL:
Update sketch list styling (#819) * parent b3c3efcec96b5e5bb4e00be742e8f17a025db409 author Laksh Singla <lakshsingla@gmail.com> 1549106083 +0530 committer Cassie Tarakajian <ctarakajian@gmail.com> 1560540243 -0400 parent b3c3efcec96b5e5bb4e00be742e8f17a025db409 author Laksh Singla <lakshsingla@gmail.com> 1549106083 +0530 committer Cassie Tarakajian <ctarakajian@gmail.com> 1560540198 -0400 parent b3c3efcec96b5e5bb4e00be742e8f17a025db409 author Laksh Singla <lakshsingla@gmail.com> 1549106083 +0530 committer Cassie Tarakajian <ctarakajian@gmail.com> 1560539667 -0400 Created initial html structure and styling for new SketchList design Final styling of ActionDialogueBox commplete Dropdown menu disappearing while clicking anywhere on the table Fixed linting issues and renamed variables Minor tweaks in the SketchList dropdown dialogue UI Themifyed the dropdown Made changes in the dropdown: Arrow positioned slightly updwards, Removed blank space and added box-shadow in dropdown, themifyed dropdowns dashed border color Added Delete and Share functionality to Dialog box Added Duplicate functionality to Dialog box Added download functionality to Dialog box SketchList does not open a sketch if dialogue box is opened SketchList Rename initial UI completed Enter key handled for rename project option [WIP] Updating rename functionality Download option now working for all the sketches Duplicate functionality extended for non opened sketches too Modified overlay behaviour to close only the last overlay Share modal can now display different projects Dropdown closes when Share and Delete are closing for a more natural UX fix broken files from rebasing Created initial html structure and styling for new SketchList design Final styling of ActionDialogueBox commplete Added Delete and Share functionality to Dialog box Added Duplicate functionality to Dialog box [WIP] Updating rename functionality Duplicate functionality extended for non opened sketches too Modified overlay behaviour to close only the last overlay Share modal can now display different projects Final styling of ActionDialogueBox commplete Fixed linting issues and renamed variables Minor tweaks in the SketchList dropdown dialogue UI Themifyed the dropdown Added Delete and Share functionality to Dialog box [WIP] Updating rename functionality Modified overlay behaviour to close only the last overlay Share modal can now display different projects Dropdown closes when Share and Delete are closing for a more natural UX fix broken files from rebasing Final styling of ActionDialogueBox commplete Minor tweaks in the SketchList dropdown dialogue UI Themifyed the dropdown [WIP] Updating rename functionality Duplicate functionality extended for non opened sketches too Modified overlay behaviour to close only the last overlay Share modal can now display different projects Dropdown closes when Share and Delete are closing for a more natural UX * fix bugs in merge commit * move sketch list dialogue to ul/li * update sketch option dropdown to use dropdown placeholder, remove unused css * major refactor of sketchlist component, fix showShareModal action, minor updates ot icon sizing * fix broken links on asset list * remove unused image, fix options for different users in sketch list
2019-06-19 20:21:25 +00:00
return Object.assign({}, state, {
shareModalVisible: true,
shareModalProjectId: action.payload.shareModalProjectId,
shareModalProjectName: action.payload.shareModalProjectName,
shareModalProjectUsername: action.payload.shareModalProjectUsername,
});
2016-09-07 02:37:29 +00:00
case ActionTypes.CLOSE_SHARE_MODAL:
return Object.assign({}, state, { shareModalVisible: false });
2016-09-07 20:33:01 +00: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 21:47:22 +00: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 });
case ActionTypes.SET_UNSAVED_CHANGES:
return Object.assign({}, state, { unsavedChanges: action.value });
case ActionTypes.DETECT_INFINITE_LOOPS:
return Object.assign({}, state, { infiniteLoop: true, infiniteLoopMessage: action.message });
case ActionTypes.RESET_INFINITE_LOOPS:
return Object.assign({}, state, { infiniteLoop: false, infiniteLoopMessage: '' });
2016-09-28 22:05:14 +00:00
case ActionTypes.START_SKETCH_REFRESH:
return Object.assign({}, state, { previewIsRefreshing: true });
case ActionTypes.END_SKETCH_REFRESH:
return Object.assign({}, state, { previewIsRefreshing: false });
case ActionTypes.JUST_OPENED_PROJECT:
return Object.assign({}, state, { justOpenedProject: true });
case ActionTypes.RESET_JUST_OPENED_PROJECT:
return Object.assign({}, state, { justOpenedProject: false });
case ActionTypes.SET_PREVIOUS_PATH:
return Object.assign({}, state, { previousPath: action.path });
case ActionTypes.SHOW_ERROR_MODAL:
return Object.assign({}, state, { errorType: action.modalType });
case ActionTypes.HIDE_ERROR_MODAL:
return Object.assign({}, state, { errorType: undefined });
case ActionTypes.SHOW_HELP_MODAL:
return Object.assign({}, state, { helpType: action.helpType });
case ActionTypes.HIDE_HELP_MODAL:
return Object.assign({}, state, { helpType: undefined });
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-23 22:29:55 +00:00
default:
return state;
}
};
2016-05-11 20:13:17 +00:00
2016-06-23 22:29:55 +00:00
export default ide;