From c75e11b631ea4b90f72cbe682304833c256d4adc Mon Sep 17 00:00:00 2001 From: Rick Brown Date: Thu, 5 Sep 2019 19:56:18 +0100 Subject: [PATCH] Add toast to notify when creating new file. Fixes #1140 (#1147) * Add toast to notify when creating new file * Add toast for opposite conditional #1147 * Replaced New file created with New sketch created * re #1140, change copy to 'opened new sketch' to make it clear that the new sketch isn't saved --- client/components/Nav.jsx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/client/components/Nav.jsx b/client/components/Nav.jsx index 253146b0..d78c2098 100644 --- a/client/components/Nav.jsx +++ b/client/components/Nav.jsx @@ -6,6 +6,7 @@ import { Link } from 'react-router'; import InlineSVG from 'react-inlinesvg'; import classNames from 'classnames'; import * as IDEActions from '../modules/IDE/actions/ide'; +import * as toastActions from '../modules/IDE/actions/toast'; import * as projectActions from '../modules/IDE/actions/project'; import { setAllAccessibleOutput } from '../modules/IDE/actions/preferences'; import { logoutUser } from '../modules/User/actions'; @@ -92,8 +93,12 @@ class Nav extends React.PureComponent { handleNew() { if (!this.props.unsavedChanges) { + this.props.showToast(1500); + this.props.setToastText('Opened new sketch.'); this.props.newProject(); } else if (this.props.warnIfUnsavedChanges()) { + this.props.showToast(1500); + this.props.setToastText('Opened new sketch.'); this.props.newProject(); } this.setDropdown('none'); @@ -624,6 +629,8 @@ class Nav extends React.PureComponent { Nav.propTypes = { newProject: PropTypes.func.isRequired, + showToast: PropTypes.func.isRequired, + setToastText: PropTypes.func.isRequired, saveProject: PropTypes.func.isRequired, autosaveProject: PropTypes.func.isRequired, exportProjectAsZip: PropTypes.func.isRequired, @@ -678,6 +685,7 @@ function mapStateToProps(state) { const mapDispatchToProps = { ...IDEActions, ...projectActions, + ...toastActions, logoutUser, setAllAccessibleOutput };