refactor: page actions (#6327)

This commit is contained in:
Aaryan Khandelwal
2025-01-06 20:31:07 +05:30
committed by GitHub
parent 6321977f1f
commit d3d3bf79f9
7 changed files with 28 additions and 2 deletions

View File

@@ -2,6 +2,7 @@ export * from "./ai";
export * from "./estimates";
export * from "./gantt-chart";
export * from "./issues";
export * from "./page";
export * from "./project";
export * from "./user-permissions";
export * from "./workspace";

1
web/ce/constants/page.ts Normal file
View File

@@ -0,0 +1 @@
export const ENABLE_MOVE_PAGE = false;

View File

@@ -28,6 +28,8 @@ import { cn } from "@/helpers/common.helper";
import { usePageOperations } from "@/hooks/use-page-operations";
// plane web components
import { MovePageModal } from "@/plane-web/components/pages";
// plane web constants
import { ENABLE_MOVE_PAGE } from "@/plane-web/constants";
// store types
import { TPageInstance } from "@/store/pages/base-page";
@@ -132,7 +134,7 @@ export const PageActions: React.FC<Props> = observer((props) => {
action: () => setMovePageModal(true),
title: "Move",
icon: FileOutput,
shouldRender: canCurrentUserMovePage,
shouldRender: canCurrentUserMovePage && ENABLE_MOVE_PAGE,
},
];
if (extraOptions) {

View File

@@ -104,6 +104,7 @@ export const PageOptionsDropdown: React.FC<Props> = observer((props) => {
"full-screen",
"copy-link",
"make-a-copy",
"move",
"toggle-lock",
"toggle-access",
"archive-restore",

View File

@@ -171,4 +171,14 @@ export class ProjectPageService extends APIService {
throw error?.response?.data;
});
}
async move(workspaceSlug: string, projectId: string, pageId: string, newProjectId: string): Promise<void> {
return this.post(`/api/workspaces/${workspaceSlug}/projects/${projectId}/pages/${pageId}/move/`, {
new_project_id: newProjectId,
})
.then((response) => response?.data)
.catch((error) => {
throw error?.response?.data;
});
}
}

View File

@@ -306,5 +306,15 @@ export class ProjectPageStore implements IProjectPageStore {
* @param {string} pageId
* @param {string} newProjectId
*/
movePage = async (workspaceSlug: string, projectId: string, pageId: string, newProjectId: string) => {};
movePage = async (workspaceSlug: string, projectId: string, pageId: string, newProjectId: string) => {
try {
await this.service.move(workspaceSlug, projectId, pageId, newProjectId);
runInAction(() => {
unset(this.data, [pageId]);
});
} catch (error) {
console.error("Unable to move page", error);
throw error;
}
};
}

1
web/ee/constants/page.ts Normal file
View File

@@ -0,0 +1 @@
export * from "ce/constants/page";