Browse Source

fix(app): prompt reload after toggling page bulk export setting

Revert the dangerouslyForceHydrate approach (rejected in review for its
per-navigation re-hydration cost) and instead show a confirmation modal.
After the admin changes the "enable bulk export" flag, prompt to reload so
the page-side export menu reflects the new value. The expiration period is
read server-side, so it does not trigger the prompt.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
tomoyuki-t 20 hours ago
parent
commit
8d2a44e2fd

+ 2 - 0
apps/app/public/static/locales/en_US/admin.json

@@ -376,6 +376,8 @@
     "page_bulk_export_explanation": "Enables a feature that allows all users to export a page and all it's child pages at once from the menu. Exported data will be automatically deleted after the storage period has passed.",
     "page_bulk_export_warning": "The bulk page export feature is available to all users. In order to maintain system resources, we ask for your cooperation in using the minimum amount necessary. If you are an administrator, please inform all users of this.",
     "page_bulk_export_storage_period": "Storage period",
+    "page_bulk_export_reload_prompt": "You need to reload the page to reflect the setting change. Reload now?",
+    "reload_page": "Reload",
     "update": "Update",
     "mail_settings": "E-mail Settings",
     "mailer_is_not_set_up": "E-mail setting is not set up.",

+ 2 - 0
apps/app/public/static/locales/fr_FR/admin.json

@@ -376,6 +376,8 @@
     "page_bulk_export_explanation": "Active une fonctionnalité qui permet à tous les utilisateurs d'exporter simultanément toutes les pages sélectionnées dans le menu des pages et leurs pages subordonnées. Les données exportées seront automatiquement supprimées une fois la période de conservation écoulée.",
     "page_bulk_export_warning": "La fonctionnalité d’exportation de pages en masse est disponible pour tous les utilisateurs. Afin de maintenir les ressources du système, nous demandons votre coopération pour utiliser le montant minimum nécessaire. Si vous êtes administrateur, veuillez en informer tous les utilisateurs.",
     "page_bulk_export_storage_period": "Date limite de téléchargement",
+    "page_bulk_export_reload_prompt": "Un rechargement de la page est nécessaire pour appliquer le changement de paramètre. Recharger maintenant ?",
+    "reload_page": "Recharger",
     "update": "Sauvegarder",
     "mail_settings": "SMTP",
     "mailer_is_not_set_up": "Paramètres d'envoi de courriels non configurés.",

+ 2 - 0
apps/app/public/static/locales/ja_JP/admin.json

@@ -385,6 +385,8 @@
     "page_bulk_export_explanation": "すべてのユーザーが、ページメニューから選択したページとその配下ページをまとめてエクスポートできる機能を有効化します。エクスポートされたデータは保存期間経過後に自動的に削除されます。",
     "page_bulk_export_warning": "ページ一括エクスポート機能は全ユーザーが利用可能です。システムリソースの維持のため、必要最小限の利用にご協力をお願いいたします。管理者の方は、この旨をユーザーの皆様にご周知ください。",
     "page_bulk_export_storage_period": "保存期間",
+    "page_bulk_export_reload_prompt": "設定を反映するにはページの再読み込みが必要です。今すぐ再読み込みしますか?",
+    "reload_page": "再読み込み",
     "update": "更新",
     "mail_settings": "メールの設定",
     "mailer_is_not_set_up": "メール設定がセットアップされていません。",

+ 2 - 0
apps/app/public/static/locales/ko_KR/admin.json

@@ -376,6 +376,8 @@
     "page_bulk_export_explanation": "모든 사용자가 메뉴에서 한 번에 페이지와 모든 하위 페이지를 내보낼 수 있는 기능을 활성화합니다. 내보낸 데이터는 저장 기간이 지나면 자동으로 삭제됩니다.",
     "page_bulk_export_warning": "대량 페이지 내보내기 기능은 모든 사용자에게 제공됩니다. 시스템 리소스 유지를 위해 최소한의 사용을 부탁드립니다. 관리자라면 모든 사용자에게 이 사실을 알려주십시오.",
     "page_bulk_export_storage_period": "저장 기간",
+    "page_bulk_export_reload_prompt": "설정을 반영하려면 페이지를 다시 로드해야 합니다. 지금 다시 로드하시겠습니까?",
+    "reload_page": "다시 로드",
     "update": "업데이트",
     "mail_settings": "이메일 설정",
     "mailer_is_not_set_up": "이메일 설정이 되어 있지 않습니다.",

+ 2 - 0
apps/app/public/static/locales/zh_CN/admin.json

@@ -385,6 +385,8 @@
     "page_bulk_export_explanation": "启用一项功能,允许所有用户一次性导出从页面菜单中选择的所有页面及其下级页面。保留期限过后,导出的数据将自动删除。",
     "page_bulk_export_warning": "批量页面导出功能可供所有用户使用。为了维护系统资源,请您配合使用最低限度的资源。如果您是管理员,请将此事实告知所有用户。",
     "page_bulk_export_storage_period": "储存期限",
+    "page_bulk_export_reload_prompt": "您需要重新加载页面以反映设置更改。现在重新加载吗?",
+    "reload_page": "重新加载",
     "update": "更新",
     "mail_settings": "邮件设置",
     "mailer_is_not_set_up": "邮件设置尚未完成。",

+ 24 - 0
apps/app/src/client/components/Admin/App/PageBulkExportSettings.tsx

@@ -7,6 +7,7 @@ import { toastError, toastSuccess } from '~/client/util/toastr';
 import { useSWRxAppSettings } from '~/stores/admin/app-settings';
 
 import AdminUpdateButtonRow from '../Common/AdminUpdateButtonRow';
+import { ConfirmModal } from './ConfirmModal';
 
 const PageBulkExportSettings = (): JSX.Element => {
   const { t } = useTranslation(['admin', 'commons']);
@@ -21,6 +22,8 @@ const PageBulkExportSettings = (): JSX.Element => {
     setBulkExportDownloadExpirationSeconds,
   ] = useState(data?.bulkExportDownloadExpirationSeconds);
 
+  const [isReloadModalOpen, setReloadModalOpen] = useState(false);
+
   const changeBulkExportDownloadExpirationSeconds = (
     bulkExportDownloadExpirationDays: number,
   ) => {
@@ -30,6 +33,11 @@ const PageBulkExportSettings = (): JSX.Element => {
   };
 
   const onSubmitHandler = useCallback(async () => {
+    // Only the enable flag affects the page-side export menu visibility, which
+    // is hydrated once per page load and therefore needs a reload to reflect.
+    // The expiration period is read server-side, so a reload prompt is unneeded.
+    const isEnabledFlagChanged =
+      isBulkExportPagesEnabled !== data?.isBulkExportPagesEnabled;
     try {
       await apiv3Put('/app-settings/page-bulk-export-settings', {
         isBulkExportPagesEnabled,
@@ -40,6 +48,9 @@ const PageBulkExportSettings = (): JSX.Element => {
           target: t('app_setting.page_bulk_export_settings'),
         }),
       );
+      if (isEnabledFlagChanged) {
+        setReloadModalOpen(true);
+      }
     } catch (err) {
       toastError(err);
     }
@@ -47,6 +58,7 @@ const PageBulkExportSettings = (): JSX.Element => {
   }, [
     isBulkExportPagesEnabled,
     bulkExportDownloadExpirationSeconds,
+    data,
     mutate,
     t,
   ]);
@@ -157,6 +169,18 @@ const PageBulkExportSettings = (): JSX.Element => {
           <AdminUpdateButtonRow onClick={onSubmitHandler} />
         </>
       )}
+
+      <ConfirmModal
+        isModalOpen={isReloadModalOpen}
+        warningMessage={t('admin:app_setting.page_bulk_export_reload_prompt')}
+        supplymentaryMessage={null}
+        confirmButtonTitle={t('admin:app_setting.reload_page')}
+        onConfirm={() => {
+          window.location.reload();
+          return Promise.resolve();
+        }}
+        onCancel={() => setReloadModalOpen(false)}
+      />
     </>
   );
 };

+ 1 - 1
apps/app/src/pages/general-page/hydrate.ts

@@ -112,5 +112,5 @@ export const useHydrateGeneralPageConfigurationAtoms = (
           createAtomTuple(disableUserPagesAtom, serverConfig.disableUserPages),
         ];
 
-  useHydrateAtoms(tuples, { dangerouslyForceHydrate: true });
+  useHydrateAtoms(tuples);
 };