11import React from 'react' ;
22import { connect } from 'react-redux' ;
33import PropTypes from 'prop-types' ;
4- import { openLoadingProject , closeLoadingProject } from 'scratch-gui/src/reducers/modals' ;
4+ import {
5+ openLoadingProject ,
6+ closeLoadingProject ,
7+ openInvalidProjectModal
8+ } from 'scratch-gui/src/reducers/modals' ;
59import {
610 requestProjectUpload ,
711 setProjectId ,
@@ -10,7 +14,11 @@ import {
1014 onLoadedProject ,
1115 requestNewProject
1216} from 'scratch-gui/src/reducers/project-state' ;
13- import { setFileHandle , setUsername } from 'scratch-gui/src/reducers/tw' ;
17+ import {
18+ setFileHandle ,
19+ setUsername ,
20+ setProjectError
21+ } from 'scratch-gui/src/reducers/tw' ;
1422import { WrappedFileHandle } from './filesystem-api.js' ;
1523import { setStrings } from '../prompt/prompt.js' ;
1624
@@ -140,8 +148,8 @@ const DesktopHOC = function (WrappedComponent) {
140148 }
141149 } ) ( ) . catch ( error => {
142150 console . error ( error ) ;
143- alert ( error ) ;
144151
152+ this . props . onShowErrorModal ( error ) ;
145153 this . props . onLoadingCompleted ( ) ;
146154 this . props . onLoadedProject ( this . props . loadingState , false ) ;
147155 this . props . onHasInitialProject ( false , this . props . loadingState ) ;
@@ -193,6 +201,7 @@ const DesktopHOC = function (WrappedComponent) {
193201 onRequestNewProject,
194202 onSetFileHandle,
195203 onSetReduxUsername,
204+ onShowErrorModal,
196205 vm,
197206 ...props
198207 } = this . props ;
@@ -253,6 +262,7 @@ const DesktopHOC = function (WrappedComponent) {
253262 onRequestNewProject : PropTypes . func . isRequired ,
254263 onSetFileHandle : PropTypes . func . isRequired ,
255264 onSetReduxUsername : PropTypes . func . isRequired ,
265+ onShowErrorModal : PropTypes . func . isRequired ,
256266 vm : PropTypes . shape ( {
257267 loadProject : PropTypes . func . isRequired
258268 } ) . isRequired
@@ -283,7 +293,11 @@ const DesktopHOC = function (WrappedComponent) {
283293 } ,
284294 onRequestNewProject : ( ) => dispatch ( requestNewProject ( false ) ) ,
285295 onSetFileHandle : fileHandle => dispatch ( setFileHandle ( fileHandle ) ) ,
286- onSetReduxUsername : ( username ) => dispatch ( setUsername ( username ) )
296+ onSetReduxUsername : username => dispatch ( setUsername ( username ) ) ,
297+ onShowErrorModal : error => {
298+ dispatch ( setProjectError ( error ) ) ;
299+ dispatch ( openInvalidProjectModal ( ) ) ;
300+ }
287301 } ) ;
288302
289303 return connect (
0 commit comments