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

Display toaster when Page is published

Shun Miyazawa 2 лет назад
Родитель
Сommit
9306ece224

+ 3 - 1
apps/app/public/static/locales/en_US/translation.json

@@ -831,6 +831,8 @@
     "success_save_as_wip": "Successfully saved as a WIP page",
     "fail_save_as_wip": "Failed to save as a WIP page",
     "alert": "This page is a work in progress",
-    "publish_page": "Publish page"
+    "publish_page": "Publish page",
+    "success_publish_page": "Page has been published",
+    "fail_publish_page": "Failed to publish the Page"
   }
 }

+ 3 - 1
apps/app/public/static/locales/ja_JP/translation.json

@@ -864,6 +864,8 @@
     "success_save_as_wip": "WIP ページとして保存しました",
     "fail_save_as_wip": "WIP ページとして保存できませんでした",
     "alert": "このページは作業途中です",
-    "publish_page": "WIP を解除"
+    "publish_page": "WIP を解除",
+    "success_publish_page": "WIP を解除しました",
+    "fail_publish_page": "WIP を解除できませんでした"
   }
 }

+ 3 - 1
apps/app/public/static/locales/zh_CN/translation.json

@@ -834,6 +834,8 @@
     "success_save_as_wip": "成功保存为 WIP 页面",
     "fail_save_as_wip": "保存为 WIP 页失败",
     "alert": "本页面正在制作中",
-    "publish_page": "发布 WIP"
+    "publish_page": "发布 WIP",
+    "success_publish_page": "WIP 已停用",
+    "fail_publish_page": "无法停用 WIP"
   }
 }

+ 10 - 3
apps/app/src/components/PageAlert/WipPageAlert.tsx

@@ -2,6 +2,7 @@ import React, { useCallback } from 'react';
 
 import { useTranslation } from 'react-i18next';
 
+import { toastSuccess, toastError } from '~/client/util/toastr';
 import { useSWRMUTxCurrentPage, useSWRxCurrentPage } from '~/stores/page';
 
 import { publish } from '../../client/services/page-operation';
@@ -17,9 +18,15 @@ export const WipPageAlert = (): JSX.Element => {
       return;
     }
 
-    await publish(currentPage._id);
-    await mutateCurrentPage();
-  }, [currentPage._id, mutateCurrentPage]);
+    try {
+      await publish(currentPage._id);
+      await mutateCurrentPage();
+      toastSuccess(t('wip_page.success_publish_page'));
+    }
+    catch {
+      toastError(t('wip_page.fail_publish_page'));
+    }
+  }, [currentPage._id, mutateCurrentPage, t]);
 
 
   if (!currentPage?.wip) {