Explorar o código

Merge remote-tracking branch 'origin/master' into imprv/page-delete-modal-fetching-pageinfo

Yuki Takei %!s(int64=4) %!d(string=hai) anos
pai
achega
7b836f75cd

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

@@ -459,7 +459,7 @@
       "recursive": "Duplicate children of under this path recursively"
     }
   },
-  "duplicated_pages": "{{path}} has been duplicated",
+  "duplicated_pages": "{{fromPath}} has been duplicated",
   "modal_putback": {
     "label": {
       "Put Back Page": "Put back page",

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

@@ -458,7 +458,7 @@
       "recursive": "配下のページも複製します"
     }
   },
-  "duplicated_pages": "{{path}} を複製しました",
+  "duplicated_pages": "{{fromPath}} を複製しました",
   "modal_putback": {
     "label": {
       "Put Back Page": "ページを元に戻す",

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

@@ -437,7 +437,7 @@
       "recursive": "Duplicate children of under this path recursively"
     }
   },
-  "duplicated_pages": "{{path}} 已重复",
+  "duplicated_pages": "{{fromPath}} 已重复",
 	"modal_putback": {
 		"label": {
 			"Put Back Page": "Put back page",

+ 5 - 2
packages/app/src/components/Navbar/GrowiContextualSubNavigation.tsx

@@ -5,7 +5,7 @@ import PropTypes from 'prop-types';
 
 import { DropdownItem } from 'reactstrap';
 
-import { OnRenamedFunction, OnDeletedFunction } from '~/interfaces/ui';
+import { OnDuplicatedFunction, OnRenamedFunction, OnDeletedFunction } from '~/interfaces/ui';
 import { IPageHasId, IPageWithMeta } from '~/interfaces/page';
 
 import { withUnstatedContainers } from '../UnstatedUtils';
@@ -184,7 +184,10 @@ const GrowiContextualSubNavigation = (props) => {
   }, [pageId]);
 
   const duplicateItemClickedHandler = useCallback(async(page: IPageForPageDuplicateModal) => {
-    openDuplicateModal(page);
+    const duplicatedHandler: OnDuplicatedFunction = (fromPath, toPath) => {
+      window.location.href = toPath;
+    };
+    openDuplicateModal(page, { onDuplicated: duplicatedHandler });
   }, [openDuplicateModal]);
 
   const renameItemClickedHandler = useCallback(async(page: IPageForPageRenameModal) => {

+ 5 - 2
packages/app/src/components/PageDuplicateModal.jsx

@@ -112,10 +112,13 @@ const PageDuplicateModal = (props) => {
     setErrs(null);
 
     try {
-      await appContainer.apiv3Post('/pages/duplicate', { pageId, pageNameInput, isRecursively: isDuplicateRecursively });
+      const { data } = await appContainer.apiv3Post('/pages/duplicate', { pageId, pageNameInput, isRecursively: isDuplicateRecursively });
       const onDuplicated = duplicateModalData.opts?.onDuplicated;
+      const fromPath = path;
+      const toPath = data.page.path;
+
       if (onDuplicated != null) {
-        onDuplicated(path);
+        onDuplicated(fromPath, toPath);
       }
       closeDuplicateModal();
     }

+ 3 - 2
packages/app/src/components/SearchPage/SearchResultContent.tsx

@@ -120,8 +120,9 @@ export const SearchResultContent: FC<Props> = (props: Props) => {
 
 
   const duplicateItemClickedHandler = useCallback(async(pageToDuplicate) => {
-    const duplicatedHandler: OnDuplicatedFunction = (path) => {
-      toastSuccess(t('duplicated_pages', { path }));
+    // eslint-disable-next-line @typescript-eslint/no-unused-vars
+    const duplicatedHandler: OnDuplicatedFunction = (fromPath, toPath) => {
+      toastSuccess(t('duplicated_pages', { fromPath }));
 
       advancePt();
       advanceFts();

+ 3 - 2
packages/app/src/components/Sidebar/PageTree/ItemsTree.tsx

@@ -145,8 +145,9 @@ const ItemsTree: FC<ItemsTreeProps> = (props: ItemsTreeProps) => {
   }, []);
 
   const onClickDuplicateMenuItem = (pageToDuplicate: IPageForPageDuplicateModal) => {
-    const duplicatedHandler: OnDuplicatedFunction = (path) => {
-      toastSuccess(t('duplicated_pages', { path }));
+    // eslint-disable-next-line @typescript-eslint/no-unused-vars
+    const duplicatedHandler: OnDuplicatedFunction = (fromPath, toPath) => {
+      toastSuccess(t('duplicated_pages', { fromPath }));
 
       advancePt();
       advanceFts();

+ 1 - 1
packages/app/src/interfaces/ui.ts

@@ -23,4 +23,4 @@ export type ICustomNavTabMappings = { [key: string]: ICustomTabContent };
 
 export type OnDeletedFunction = (idOrPaths: string | string[], isRecursively: Nullable<true>, isCompletely: Nullable<true>) => void;
 export type OnRenamedFunction = (path: string) => void;
-export type OnDuplicatedFunction = (path: string) => void;
+export type OnDuplicatedFunction = (fromPath: string, toPath: string) => void;