|
|
@@ -5,11 +5,13 @@ import { format } from 'date-fns';
|
|
|
import { useRouter } from 'next/router';
|
|
|
import { useTranslation } from 'react-i18next';
|
|
|
|
|
|
+import { toastError } from '~/client/util/apiNotification';
|
|
|
import { usePageDeleteModal, usePutBackPageModal } from '~/stores/modal';
|
|
|
import { useSWRxPageInfo, useSWRxCurrentPage, useIsTrashPage } from '~/stores/page';
|
|
|
import { useRedirectFrom } from '~/stores/page-redirect';
|
|
|
import { useIsAbleToShowTrashPageManagementButtons } from '~/stores/ui';
|
|
|
|
|
|
+
|
|
|
const onDeletedHandler = (pathOrPathsToDelete) => {
|
|
|
if (typeof pathOrPathsToDelete !== 'string') {
|
|
|
return;
|
|
|
@@ -45,10 +47,15 @@ export const TrashPageAlert = (): JSX.Element => {
|
|
|
return;
|
|
|
}
|
|
|
const putBackedHandler = () => {
|
|
|
- unlink();
|
|
|
- // Do not use "router.push(`/${pageId}`)" to avoid `Error: Invariant: attempted to hard navigate to the same URL`
|
|
|
- // See: https://github.com/weseek/growi/pull/7054
|
|
|
- router.reload();
|
|
|
+ try {
|
|
|
+ unlink();
|
|
|
+ // Do not use "router.push(`/${pageId}`)" to avoid `Error: Invariant: attempted to hard navigate to the same URL`
|
|
|
+ // See: https://github.com/weseek/growi/pull/7054
|
|
|
+ router.reload();
|
|
|
+ }
|
|
|
+ catch (err) {
|
|
|
+ toastError(err);
|
|
|
+ }
|
|
|
};
|
|
|
openPutBackPageModal({ pageId, path: pagePath }, { onPutBacked: putBackedHandler });
|
|
|
}, [openPutBackPageModal, pageId, pagePath, router, unlink]);
|