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
This commit is contained in:
Rick Brown 2019-09-05 19:56:18 +01:00 committed by Cassie Tarakajian
parent 5695830361
commit c75e11b631
1 changed files with 8 additions and 0 deletions

View File

@ -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
};