@@ -257,6 +257,7 @@ const DashboardEditor = ({
257257
258258 // show the card gallery if no card is being edited
259259 const [ dashboardJson , setDashboardJson ] = useState ( initialValue ) ;
260+ const [ imagesToUpload , setImagesToUpload ] = useState ( [ ] ) ;
260261 const [ selectedCardId , setSelectedCardId ] = useState ( ) ;
261262 const [ selectedBreakpointIndex , setSelectedBreakpointIndex ] = useState (
262263 breakpointSwitcher ?. initialValue
@@ -326,7 +327,18 @@ const DashboardEditor = ({
326327 cardConfig . content . src = availableImages . find (
327328 ( image ) => image . id === cardConfig . content . id
328329 ) ?. src ;
330+ } else if (
331+ cardConfig . content . imgState === 'new' &&
332+ ! imagesToUpload . some ( ( image ) => image . id === cardConfig . content . id )
333+ ) {
334+ if ( cardConfig . content . id && cardConfig . content . src ) {
335+ setImagesToUpload ( ( prevImagesToUpload ) => [
336+ ...prevImagesToUpload ,
337+ { id : cardConfig . content . id , src : cardConfig . content . src } ,
338+ ] ) ;
339+ }
329340 }
341+
330342 // TODO: this is really inefficient
331343 setDashboardJson ( ( oldJSON ) => ( {
332344 ...oldJSON ,
@@ -399,10 +411,10 @@ const DashboardEditor = ({
399411 breadcrumbs = { headerBreadcrumbs }
400412 onEditTitle = { onEditTitle }
401413 onImport = { onImport }
402- onExport = { ( ) => onExport ( dashboardJson ) }
414+ onExport = { ( ) => onExport ( dashboardJson , imagesToUpload ) }
403415 onDelete = { onDelete }
404416 onCancel = { onCancel }
405- onSubmit = { onSubmit }
417+ onSubmit = { ( params ) => onSubmit ( params , imagesToUpload ) }
406418 isSubmitDisabled = { isSubmitDisabled }
407419 isSubmitLoading = { isSubmitLoading }
408420 i18n = { mergedI18n }
0 commit comments