Kaynağa Gözat

empty trash function

yuken 4 yıl önce
ebeveyn
işleme
aca428f8a5

+ 1 - 0
packages/app/resource/locales/en_US/translation.json

@@ -444,6 +444,7 @@
   "deleted_pages": "{{path}} has been deleted",
   "deleted_pages_completely": "{{path}} has been deleted completely",
   "renamed_pages": "{{path}} has been renamed",
+  "empty_trash": "The trash has been emptied",
   "modal_empty":{
     "empty_the_trash": "Empty The Trash",
     "notice": "The pages deleted completely are unrecoverable."

+ 1 - 0
packages/app/resource/locales/ja_JP/translation.json

@@ -443,6 +443,7 @@
   "deleted_pages": "{{path}} をゴミ箱に入れました",
   "deleted_pages_completely": "{{path}} を完全に削除しました",
   "renamed_pages": "{{path}} を移動/名前変更しました",
+  "empty_trash": "ゴミ箱を空にしました",
   "modal_empty":{
     "empty_the_trash": "ゴミ箱を空にする",
     "notice": "完全削除したページは元に戻すことができません"

+ 1 - 0
packages/app/resource/locales/zh_CN/translation.json

@@ -422,6 +422,7 @@
   "deleted_pages": "将 {{path}} 放入垃圾箱",
   "deleted_pages_completely": "{{path}} 已被完全删除",
   "renamed_pages": "移动/重命名 {{path}}",
+  "empty_trash": "清空垃圾",
 	"modal_empty": {
 		"empty_the_trash": "Empty The Trash",
 		"notice": "完全删除的页面是不可恢复的。"

+ 6 - 4
packages/app/src/components/CustomNavigation/CustomNav.jsx

@@ -8,7 +8,7 @@ import {
   Nav, NavItem, NavLink,
 } from 'reactstrap';
 
-
+import { toastSuccess } from '~/client/util/apiNotification';
 import { useCurrentPagePath } from '~/stores/context';
 import { usePageDeleteModal } from '~/stores/modal';
 import { useSWRxDescendantsPageListForCurrrentPath, useSWRxPageInfoForList } from '~/stores/page';
@@ -129,9 +129,11 @@ export const CustomNavTab = (props) => {
     pageWithMetas = injectTo(dataWithMetas);
   }
 
-  const onDeletedHandler = (...args) => {
-    // process after multipe pages delete api
-  };
+  const onDeletedHandler = useCallback(() => {
+    toastSuccess(t('empty_trash'));
+
+    mutate();
+  }, [mutate, t]);
 
   const emptyTrashClickHandler = () => {
     openDeleteModal(pageWithMetas, { onDeleted: onDeletedHandler, emptyTrash: true });

+ 22 - 16
packages/app/src/components/PageDeleteModal.tsx

@@ -6,7 +6,7 @@ import {
 } from 'reactstrap';
 
 import { apiPost } from '~/client/util/apiv1-client';
-import { apiv3Post } from '~/client/util/apiv3-client';
+import { apiv3Delete, apiv3Post } from '~/client/util/apiv3-client';
 import { HasObjectId } from '~/interfaces/has-object-id';
 import {
   IDeleteSinglePageApiv1Result, IDeleteManyPageApiv3Result, IPageToDeleteWithMeta, IDataWithMeta, isIPageInfoForEntity, IPageInfoForEntity,
@@ -108,23 +108,29 @@ const PageDeleteModal: FC = () => {
      */
     if (deleteModalData.pages.length > 1) {
       try {
-        const isRecursively = isDeleteRecursively === true ? true : undefined;
-        const isCompletely = isDeleteCompletely === true ? true : undefined;
-
-        const pageIdToRevisionIdMap = {};
-        deleteModalData.pages.forEach((p) => { pageIdToRevisionIdMap[p.data._id] = p.data.revision as string });
-
-        const { data } = await apiv3Post<IDeleteManyPageApiv3Result>('/pages/delete', {
-          pageIdToRevisionIdMap,
-          isRecursively,
-          isCompletely,
-        });
-
         const onDeleted = deleteModalData.opts?.onDeleted;
-        if (onDeleted != null) {
-          onDeleted(data.paths, data.isRecursively, data.isCompletely);
-        }
 
+        if (emptyTrash) {
+          await apiv3Delete('/pages/empty-trash');
+          if (onDeleted != null) {
+            onDeleted('', null, null);
+          }
+        }
+        else {
+          const isRecursively = isDeleteRecursively === true ? true : undefined;
+          const isCompletely = isDeleteCompletely === true ? true : undefined;
+          const pageIdToRevisionIdMap = {};
+          deleteModalData.pages.forEach((p) => { pageIdToRevisionIdMap[p.data._id] = p.data.revision as string });
+          const { data } = await apiv3Post<IDeleteManyPageApiv3Result>('/pages/delete', {
+            pageIdToRevisionIdMap,
+            isRecursively,
+            isCompletely,
+          });
+          const onDeleted = deleteModalData.opts?.onDeleted;
+          if (onDeleted != null) {
+            onDeleted(data.paths, data.isRecursively, data.isCompletely);
+          }
+        }
         closeDeleteModal();
       }
       catch (err) {