Explorar o código

create redicretToTrash

Shun Miyazawa %!s(int64=4) %!d(string=hai) anos
pai
achega
a41d45152f
Modificáronse 1 ficheiros con 10 adicións e 3 borrados
  1. 10 3
      packages/app/src/components/PageDeleteModal.tsx

+ 10 - 3
packages/app/src/components/PageDeleteModal.tsx

@@ -1,9 +1,9 @@
 import React, { useState, FC } from 'react';
 import React, { useState, FC } from 'react';
-import toastr from 'toastr';
 import {
 import {
   Modal, ModalHeader, ModalBody, ModalFooter,
   Modal, ModalHeader, ModalBody, ModalFooter,
 } from 'reactstrap';
 } from 'reactstrap';
 import { useTranslation } from 'react-i18next';
 import { useTranslation } from 'react-i18next';
+import nodePath from 'path';
 
 
 import { apiPost } from '~/client/util/apiv1-client';
 import { apiPost } from '~/client/util/apiv1-client';
 import { usePageDeleteModalStatus, usePageDeleteModalOpened } from '~/stores/ui';
 import { usePageDeleteModalStatus, usePageDeleteModalOpened } from '~/stores/ui';
@@ -60,6 +60,14 @@ const PageDeleteModal: FC<Props> = (props: Props) => {
     setIsDeleteCompletely(!isDeleteCompletely);
     setIsDeleteCompletely(!isDeleteCompletely);
   }
   }
 
 
+  function redicretToTrash(pagePath: string) {
+    const dirname = nodePath.dirname(pagePath as string);
+    if (dirname === '/trash') {
+      window.location.href = encodeURI(pagePath);
+    }
+    return;
+  }
+
   async function deletePage() {
   async function deletePage() {
     // toastr.warning(t('search_result.currently_not_implemented'));
     // toastr.warning(t('search_result.currently_not_implemented'));
     // Todo implement page delete function at https://redmine.weseek.co.jp/issues/82222
     // Todo implement page delete function at https://redmine.weseek.co.jp/issues/82222
@@ -79,9 +87,8 @@ const PageDeleteModal: FC<Props> = (props: Props) => {
           completely,
           completely,
         }) as IPageApiv1Result;
         }) as IPageApiv1Result;
 
 
-        const trashPagePath = result.page.path;
+        redicretToTrash(result.page.path);
 
 
-        window.location.href = encodeURI(trashPagePath);
       }
       }
       catch (err) {
       catch (err) {
         setErrs(err);
         setErrs(err);