From 4927e12e80ef2dca7c75e83abbdb2aeee6b2e9d9 Mon Sep 17 00:00:00 2001 From: Paul Kaplan Date: Wed, 13 Feb 2019 09:29:05 -0500 Subject: [PATCH] Share the replace project confirmation string between new and upload --- src/components/menu-bar/menu-bar.jsx | 11 +++-------- src/containers/sb-file-uploader.jsx | 9 +++------ src/lib/shared-messages.js | 5 +++++ 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/components/menu-bar/menu-bar.jsx b/src/components/menu-bar/menu-bar.jsx index 647a90fd0..f985881c1 100644 --- a/src/components/menu-bar/menu-bar.jsx +++ b/src/components/menu-bar/menu-bar.jsx @@ -67,13 +67,8 @@ import languageIcon from '../language-selector/language-icon.svg'; import scratchLogo from './scratch-logo.svg'; -const messages = defineMessages({ - confirmNav: { - id: 'gui.menuBar.confirmNewWithoutSaving', - defaultMessage: 'Replace contents of the current project?', - description: 'message for prompting user to confirm that they want to create new project without saving' - } -}); +import sharedMessages from '../../lib/shared-messages'; + const ariaMessages = defineMessages({ language: { id: 'gui.menuBar.LanguageSelector', @@ -173,7 +168,7 @@ class MenuBar extends React.Component { // they'll lose their work. if (this.props.projectChanged && !this.props.canCreateNew) { readyToReplaceProject = confirm( // eslint-disable-line no-alert - this.props.intl.formatMessage(messages.confirmNav) + this.props.intl.formatMessage(sharedMessages.replaceProjectWarning) ); } this.props.onRequestCloseFile(); diff --git a/src/containers/sb-file-uploader.jsx b/src/containers/sb-file-uploader.jsx index d375ccb8a..5ec6c6075 100644 --- a/src/containers/sb-file-uploader.jsx +++ b/src/containers/sb-file-uploader.jsx @@ -6,6 +6,8 @@ import {defineMessages, injectIntl, intlShape} from 'react-intl'; import analytics from '../lib/analytics'; import log from '../lib/log'; +import sharedMessages from '../lib/shared-messages'; + import { LoadingStates, getIsLoadingUpload, @@ -43,11 +45,6 @@ const messages = defineMessages({ id: 'gui.projectLoader.loadError', defaultMessage: 'The project file that was selected failed to load.', description: 'An error that displays when a local project file fails to load.' - }, - uploadWarning: { - id: 'gui.projectLoader.uploadWarning', - defaultMessage: 'Replace the contents of the current project?', - description: 'A warning before uploading a file on top of another project.' } }); @@ -109,7 +106,7 @@ class SBFileUploader extends React.Component { // has changed and is not showing with ID. If it has an ID, this operation // does not currently overwrite that project, so it is safe to do without confirmation. const uploadAllowed = (isShowingWithoutId && projectChanged) ? - confirm(intl.formatMessage(messages.uploadWarning)) : // eslint-disable-line no-alert + confirm(intl.formatMessage(sharedMessages.replaceProjectWarning)) : // eslint-disable-line no-alert true; if (uploadAllowed) this.props.requestProjectUpload(loadingState); diff --git a/src/lib/shared-messages.js b/src/lib/shared-messages.js index 0de3e342d..d3f7ad427 100644 --- a/src/lib/shared-messages.js +++ b/src/lib/shared-messages.js @@ -20,5 +20,10 @@ export default defineMessages({ defaultMessage: 'pop', description: 'Name of the pop sound, the default sound added to a sprite', id: 'gui.sharedMessages.pop' + }, + replaceProjectWarning: { + id: 'gui.sharedMessages.replaceProjectWarning', + defaultMessage: 'Replace contents of the current project?', + description: 'Confirmation that user wants to overwrite the current project contents' } });