diff --git a/client/constants.js b/client/constants.js index 50ca8f8e..d99a9784 100644 --- a/client/constants.js +++ b/client/constants.js @@ -42,5 +42,7 @@ export const CONSOLE_EVENT = 'CONSOLE_EVENT'; export const EXPAND_CONSOLE = 'EXPAND_CONSOLE'; export const COLLAPSE_CONSOLE = 'COLLAPSE_CONSOLE'; +export const TOGGLE_BEEP = 'TOGGLE_BEEP'; + // eventually, handle errors more specifically and better export const ERROR = 'ERROR'; diff --git a/client/modules/IDE/actions/editorHidden.js b/client/modules/IDE/actions/editorHidden.js new file mode 100644 index 00000000..d5cc4a92 --- /dev/null +++ b/client/modules/IDE/actions/editorHidden.js @@ -0,0 +1,7 @@ +import * as ActionTypes from '../../../constants'; + +export function toggleBeep() { + return { + type: ActionTypes.TOGGLE_BEEP + }; +} diff --git a/client/modules/IDE/actions/ide.js b/client/modules/IDE/actions/ide.js index 7628ff3f..1b8b18d8 100644 --- a/client/modules/IDE/actions/ide.js +++ b/client/modules/IDE/actions/ide.js @@ -79,4 +79,3 @@ export function closePreferences() { type: ActionTypes.CLOSE_PREFERENCES }; } - diff --git a/client/modules/IDE/components/Editor.js b/client/modules/IDE/components/Editor.js index 4469af07..2a7bbc28 100644 --- a/client/modules/IDE/components/Editor.js +++ b/client/modules/IDE/components/Editor.js @@ -44,7 +44,7 @@ class Editor extends React.Component { isVisible = true; } }); - if (isVisible) { + if (isVisible && this.props.enableBeep) { this.beep.play(); } }) @@ -109,6 +109,7 @@ class Editor extends React.Component { } Editor.propTypes = { + enableBeep: PropTypes.bool.isRequired, indentationAmount: PropTypes.number.isRequired, isTabIndent: PropTypes.bool.isRequired, updateFileContent: PropTypes.func.isRequired, diff --git a/client/modules/IDE/components/EditorHidden.js b/client/modules/IDE/components/EditorHidden.js new file mode 100644 index 00000000..e69de29b diff --git a/client/modules/IDE/pages/IDEView.js b/client/modules/IDE/pages/IDEView.js index fe9eadbc..6edb48d6 100644 --- a/client/modules/IDE/pages/IDEView.js +++ b/client/modules/IDE/pages/IDEView.js @@ -12,6 +12,7 @@ import { connect } from 'react-redux'; import * as FileActions from '../actions/files'; import * as IDEActions from '../actions/ide'; import * as ProjectActions from '../actions/project'; +import * as EditorHiddenActions from '../actions/editorHidden'; import { getFile, getHTMLFile, getJSFiles, getCSSFiles } from '../reducers/files'; class IDEView extends React.Component { @@ -60,7 +61,9 @@ class IDEView extends React.Component {
+ { + switch (action.type) { + case ActionTypes.TOGGLE_BEEP: + return Object.assign({}, state, { enableBeep: !state.enableBeep }); + default: + return state; + } +}; + +export default editorHidden; diff --git a/client/reducers.js b/client/reducers.js index 1dfafa9e..f689c860 100644 --- a/client/reducers.js +++ b/client/reducers.js @@ -3,6 +3,7 @@ import files from './modules/IDE/reducers/files'; import ide from './modules/IDE/reducers/ide'; import preferences from './modules/IDE/reducers/preferences'; import project from './modules/IDE/reducers/project'; +import editorHidden from './modules/IDE/reducers/editorHidden'; import user from './modules/User/reducers'; import sketches from './modules/Sketch/reducers'; import { reducer as form } from 'redux-form'; @@ -14,7 +15,8 @@ const rootReducer = combineReducers({ preferences, user, project, - sketches + sketches, + editorHidden }); export default rootReducer;