@@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
33import React from 'react' ;
44import { withTranslation } from 'react-i18next' ;
55import { connect } from 'react-redux' ;
6- import { Link , withRouter } from 'react-router' ;
6+ import { Link } from 'react-router-dom ' ;
77import { availableLanguages , languageKeyToLabel } from '../i18n' ;
88import * as IDEActions from '../modules/IDE/actions/ide' ;
99import * as toastActions from '../modules/IDE/actions/toast' ;
@@ -37,12 +37,12 @@ class Nav extends React.PureComponent {
3737 }
3838
3939 handleNew ( ) {
40- const { unsavedChanges, warnIfUnsavedChanges } = this . props ;
40+ const { unsavedChanges } = this . props ;
4141 if ( ! unsavedChanges ) {
4242 this . props . showToast ( 1500 ) ;
4343 this . props . setToastText ( 'Toast.OpenedNewSketch' ) ;
4444 this . props . newProject ( ) ;
45- } else if ( warnIfUnsavedChanges && warnIfUnsavedChanges ( ) ) {
45+ } else if ( window . confirm ( this . props . t ( 'Nav.WarningUnsavedChanges' ) ) ) {
4646 this . props . showToast ( 1500 ) ;
4747 this . props . setToastText ( 'Toast.OpenedNewSketch' ) ;
4848 this . props . newProject ( ) ;
@@ -73,11 +73,10 @@ class Nav extends React.PureComponent {
7373 }
7474
7575 handleShare ( ) {
76- const { username } = this . props . params ;
7776 this . props . showShareModal (
7877 this . props . project . id ,
7978 this . props . project . name ,
80- username
79+ this . props . project . owner . username
8180 ) ;
8281 }
8382
@@ -351,14 +350,14 @@ Nav.propTypes = {
351350 id : PropTypes . string ,
352351 name : PropTypes . string ,
353352 owner : PropTypes . shape ( {
354- id : PropTypes . string
353+ id : PropTypes . string ,
354+ username : PropTypes . string
355355 } )
356356 } ) ,
357357 logoutUser : PropTypes . func . isRequired ,
358358 showShareModal : PropTypes . func . isRequired ,
359359 showErrorModal : PropTypes . func . isRequired ,
360360 unsavedChanges : PropTypes . bool . isRequired ,
361- warnIfUnsavedChanges : PropTypes . func ,
362361 showKeyboardShortcutModal : PropTypes . func . isRequired ,
363362 cmController : PropTypes . shape ( {
364363 tidyCode : PropTypes . func ,
@@ -374,9 +373,6 @@ Nav.propTypes = {
374373 rootFile : PropTypes . shape ( {
375374 id : PropTypes . string . isRequired
376375 } ) . isRequired ,
377- params : PropTypes . shape ( {
378- username : PropTypes . string
379- } ) ,
380376 t : PropTypes . func . isRequired ,
381377 setLanguage : PropTypes . func . isRequired ,
382378 language : PropTypes . string . isRequired ,
@@ -391,10 +387,6 @@ Nav.defaultProps = {
391387 } ,
392388 cmController : { } ,
393389 layout : 'project' ,
394- warnIfUnsavedChanges : undefined ,
395- params : {
396- username : undefined
397- } ,
398390 editorLink : '/'
399391} ;
400392
@@ -420,6 +412,6 @@ const mapDispatchToProps = {
420412} ;
421413
422414export default withTranslation ( ) (
423- withRouter ( connect ( mapStateToProps , mapDispatchToProps ) ( Nav ) )
415+ connect ( mapStateToProps , mapDispatchToProps ) ( Nav )
424416) ;
425417export { Nav as NavComponent } ;
0 commit comments