Просмотр исходного кода

fix(app): show bulk-export restart modal on duplicate-job error

startBulkExport called close() unconditionally after the API call, which
set the parent modal's isOpened to false and unmounted the substance
component along with its isRestartModalOpened local state. The restart
modal was therefore never rendered when the server returned a duplicate
job error.

Move close() into the success and non-duplicate error branches, and call
close() from restartBulkExport / handleCloseRestartModal so the parent
modal still closes once the restart flow finishes or is dismissed.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
tomoyuki-t 2 дней назад
Родитель
Сommit
4382cf4f54

+ 8 - 3
apps/app/src/features/page-bulk-export/client/components/PageBulkExportSelectModal.tsx

@@ -35,16 +35,19 @@ const PageBulkExportSelectModalSubstance = (): JSX.Element => {
         setFormatMemoForRestart(format);
         await apiv3Post('/page-bulk-export', { path: currentPagePath, format });
         toastSuccess(t('page_export.bulk_export_started'));
+        close();
       } catch (e) {
         const errorCode = e?.[0].code ?? 'page_export.failed_to_export';
         if (errorCode === 'page_export.duplicate_bulk_export_job_error') {
+          // Keep the substance mounted so the restart modal can render.
+          // Closing here would unmount the substance and discard isRestartModalOpened.
           setDuplicateJobInfo(e[0].args.duplicateJob);
           setIsRestartModalOpened(true);
         } else {
           toastError(t(errorCode));
+          close();
         }
       }
-      close();
     },
     [close, currentPagePath, t],
   );
@@ -62,12 +65,14 @@ const PageBulkExportSelectModalSubstance = (): JSX.Element => {
         toastError(t('page_export.failed_to_export'));
       }
       setIsRestartModalOpened(false);
+      close();
     }
-  }, [currentPagePath, formatMemoForRestart, t]);
+  }, [close, currentPagePath, formatMemoForRestart, t]);
 
   const handleCloseRestartModal = useCallback(() => {
     setIsRestartModalOpened(false);
-  }, []);
+    close();
+  }, [close]);
 
   // Memoize format display text to prevent recalculation
   const formatDisplayText = useMemo(() => {