2020 */
2121import * as Antd from 'antd' ;
2222import * as React from 'react' ;
23- import { RcFile , UploadRequestOption } from 'rc-upload/lib/interface' ;
2423import * as commonStorage from '../storage/common_storage' ;
2524import * as storageNames from '../storage/names' ;
2625import * as storageProject from '../storage/project' ;
@@ -391,7 +390,7 @@ export function Component(props: MenuProps): React.JSX.Element {
391390 } ,
392391 onChange : ( _info ) => {
393392 } ,
394- customRequest : ( options : UploadRequestOption ) => {
393+ customRequest : ( options ) => {
395394 const reader = new FileReader ( ) ;
396395 reader . onload = ( event ) => {
397396 if ( ! event . target ) {
@@ -402,16 +401,20 @@ export function Component(props: MenuProps): React.JSX.Element {
402401 projectNames . forEach ( projectName => {
403402 existingProjectNames . push ( projectName ) ;
404403 } ) ;
405- const file = options . file as RcFile ;
404+ const file = options . file as File ;
406405 const uploadProjectName = storageProject . makeUploadProjectName ( file . name , existingProjectNames ) ;
407406 if ( props . storage ) {
408407 storageProject . uploadProject ( props . storage , uploadProjectName , dataUrl ) ;
409408 }
409+ if ( options . onSuccess ) {
410+ options . onSuccess ( dataUrl ) ;
411+ }
410412 } ;
411413 reader . onerror = ( _error ) => {
412414 console . log ( 'Error reading file: ' + reader . error ) ;
413- // TODO: i18n
414- props . setAlertErrorMessage ( t ( 'UPLOAD_FAILED' ) || 'Failed to upload project' ) ;
415+ if ( options . onError ) {
416+ options . onError ( new Error ( t ( 'UPLOAD_FAILED' ) ) ) ;
417+ }
415418 } ;
416419 reader . readAsDataURL ( options . file as Blob ) ;
417420 } ,
0 commit comments