1
1
import classNames from 'classnames' ;
2
2
import { connect } from 'react-redux' ;
3
+ import { compose } from 'redux' ;
3
4
import { defineMessages , FormattedMessage , injectIntl , intlShape } from 'react-intl' ;
4
5
import PropTypes from 'prop-types' ;
5
6
import bindAll from 'lodash.bindall' ;
@@ -27,6 +28,7 @@ import LoginDropdown from './login-dropdown.jsx';
27
28
import SB3Downloader from '../../containers/sb3-downloader.jsx' ;
28
29
import DeletionRestorer from '../../containers/deletion-restorer.jsx' ;
29
30
import TurboMode from '../../containers/turbo-mode.jsx' ;
31
+ import ConfirmReplaceHOC from './confirm-replace-hoc.jsx' ;
30
32
31
33
import { openTipsLibrary } from '../../reducers/modals' ;
32
34
import { setPlayer } from '../../reducers/mode' ;
@@ -63,7 +65,6 @@ import styles from './menu-bar.css';
63
65
64
66
import helpIcon from '../../lib/assets/icon--tutorials.svg' ;
65
67
import mystuffIcon from './icon--mystuff.png' ;
66
- import feedbackIcon from './icon--feedback.svg' ;
67
68
import profileIcon from './icon--profile.png' ;
68
69
import remixIcon from './icon--remix.svg' ;
69
70
import dropdownCaret from './dropdown-caret.svg' ;
@@ -164,17 +165,14 @@ class MenuBar extends React.Component {
164
165
document . removeEventListener ( 'keydown' , this . handleKeyPress ) ;
165
166
}
166
167
handleClickNew ( ) {
167
- let readyToReplaceProject = true ;
168
168
// if the project is dirty, and user owns the project, we will autosave.
169
169
// but if they are not logged in and can't save, user should consider
170
170
// downloading or logging in first.
171
171
// Note that if user is logged in and editing someone else's project,
172
172
// they'll lose their work.
173
- if ( this . props . projectChanged && ! this . props . canCreateNew ) {
174
- readyToReplaceProject = confirm ( // eslint-disable-line no-alert
175
- this . props . intl . formatMessage ( sharedMessages . replaceProjectWarning )
176
- ) ;
177
- }
173
+ const readyToReplaceProject = this . props . confirmReadyToReplaceProject (
174
+ this . props . intl . formatMessage ( sharedMessages . replaceProjectWarning )
175
+ ) ;
178
176
this . props . onRequestCloseFile ( ) ;
179
177
if ( readyToReplaceProject ) {
180
178
this . props . onClickNew ( this . props . canSave && this . props . canCreateNew ) ;
@@ -644,25 +642,6 @@ class MenuBar extends React.Component {
644
642
) : (
645
643
// ******** no login session is available, so don't show login stuff
646
644
< React . Fragment >
647
- < div className = { classNames ( styles . menuBarItem , styles . feedbackButtonWrapper ) } >
648
- < a
649
- className = { styles . feedbackLink }
650
- href = "https://scratch.mit.edu/discuss/topic/312261/"
651
- rel = "noopener noreferrer"
652
- target = "_blank"
653
- >
654
- < Button
655
- className = { styles . feedbackButton }
656
- iconSrc = { feedbackIcon }
657
- >
658
- < FormattedMessage
659
- defaultMessage = "Give Feedback"
660
- description = "Label for feedback form modal button"
661
- id = "gui.menuBar.giveFeedback"
662
- />
663
- </ Button >
664
- </ a >
665
- </ div >
666
645
{ this . props . showComingSoon ? (
667
646
< React . Fragment >
668
647
< MenuBarItemTooltip id = "mystuff" >
@@ -759,7 +738,6 @@ MenuBar.propTypes = {
759
738
onShare : PropTypes . func ,
760
739
onToggleLoginOpen : PropTypes . func ,
761
740
onUpdateProjectTitle : PropTypes . func ,
762
- projectChanged : PropTypes . bool ,
763
741
projectTitle : PropTypes . string ,
764
742
renderLogin : PropTypes . func ,
765
743
sessionExists : PropTypes . bool ,
@@ -785,7 +763,6 @@ const mapStateToProps = (state, ownProps) => {
785
763
languageMenuOpen : languageMenuOpen ( state ) ,
786
764
locale : state . locales . locale ,
787
765
loginMenuOpen : loginMenuOpen ( state ) ,
788
- projectChanged : state . scratchGui . projectChanged ,
789
766
projectTitle : state . scratchGui . projectTitle ,
790
767
sessionExists : state . session && typeof state . session . session !== 'undefined' ,
791
768
username : user ? user . username : null ,
@@ -815,7 +792,11 @@ const mapDispatchToProps = dispatch => ({
815
792
onSeeCommunity : ( ) => dispatch ( setPlayer ( true ) )
816
793
} ) ;
817
794
818
- export default injectIntl ( connect (
819
- mapStateToProps ,
820
- mapDispatchToProps
821
- ) ( MenuBar ) ) ;
795
+ export default compose (
796
+ injectIntl ,
797
+ ConfirmReplaceHOC ,
798
+ connect (
799
+ mapStateToProps ,
800
+ mapDispatchToProps
801
+ )
802
+ ) ( MenuBar ) ;
0 commit comments