chore: add page flag hook (#6354)
This commit is contained in:
parent
ac14d57f8b
commit
92645c1cee
5 changed files with 26 additions and 5 deletions
|
|
@ -1 +0,0 @@
|
||||||
export const ENABLE_MOVE_PAGE = false;
|
|
||||||
14
web/ce/hooks/use-page-flag.ts
Normal file
14
web/ce/hooks/use-page-flag.ts
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
export type TPageFlagHookArgs = {
|
||||||
|
workspaceSlug: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type TPageFlagHookReturnType = {
|
||||||
|
isMovePageEnabled: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const usePageFlag = (args: TPageFlagHookArgs): TPageFlagHookReturnType => {
|
||||||
|
const {} = args;
|
||||||
|
return {
|
||||||
|
isMovePageEnabled: false,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
import { useMemo, useState } from "react";
|
import { useMemo, useState } from "react";
|
||||||
import { observer } from "mobx-react";
|
import { observer } from "mobx-react";
|
||||||
|
import { useParams } from "next/navigation";
|
||||||
import {
|
import {
|
||||||
ArchiveRestoreIcon,
|
ArchiveRestoreIcon,
|
||||||
Copy,
|
Copy,
|
||||||
|
|
@ -28,8 +29,8 @@ import { cn } from "@/helpers/common.helper";
|
||||||
import { usePageOperations } from "@/hooks/use-page-operations";
|
import { usePageOperations } from "@/hooks/use-page-operations";
|
||||||
// plane web components
|
// plane web components
|
||||||
import { MovePageModal } from "@/plane-web/components/pages";
|
import { MovePageModal } from "@/plane-web/components/pages";
|
||||||
// plane web constants
|
// plane web hooks
|
||||||
import { ENABLE_MOVE_PAGE } from "@/plane-web/constants";
|
import { usePageFlag } from "@/plane-web/hooks/use-page-flag";
|
||||||
// store types
|
// store types
|
||||||
import { TPageInstance } from "@/store/pages/base-page";
|
import { TPageInstance } from "@/store/pages/base-page";
|
||||||
|
|
||||||
|
|
@ -60,6 +61,12 @@ export const PageActions: React.FC<Props> = observer((props) => {
|
||||||
// states
|
// states
|
||||||
const [deletePageModal, setDeletePageModal] = useState(false);
|
const [deletePageModal, setDeletePageModal] = useState(false);
|
||||||
const [movePageModal, setMovePageModal] = useState(false);
|
const [movePageModal, setMovePageModal] = useState(false);
|
||||||
|
// params
|
||||||
|
const { workspaceSlug } = useParams();
|
||||||
|
// page flag
|
||||||
|
const { isMovePageEnabled } = usePageFlag({
|
||||||
|
workspaceSlug: workspaceSlug?.toString() ?? "",
|
||||||
|
});
|
||||||
// page operations
|
// page operations
|
||||||
const { pageOperations } = usePageOperations({
|
const { pageOperations } = usePageOperations({
|
||||||
editorRef,
|
editorRef,
|
||||||
|
|
@ -134,7 +141,7 @@ export const PageActions: React.FC<Props> = observer((props) => {
|
||||||
action: () => setMovePageModal(true),
|
action: () => setMovePageModal(true),
|
||||||
title: "Move",
|
title: "Move",
|
||||||
icon: FileOutput,
|
icon: FileOutput,
|
||||||
shouldRender: canCurrentUserMovePage && ENABLE_MOVE_PAGE,
|
shouldRender: canCurrentUserMovePage && isMovePageEnabled,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
if (extraOptions) {
|
if (extraOptions) {
|
||||||
|
|
@ -146,6 +153,7 @@ export const PageActions: React.FC<Props> = observer((props) => {
|
||||||
archived_at,
|
archived_at,
|
||||||
extraOptions,
|
extraOptions,
|
||||||
is_locked,
|
is_locked,
|
||||||
|
isMovePageEnabled,
|
||||||
canCurrentUserArchivePage,
|
canCurrentUserArchivePage,
|
||||||
canCurrentUserChangeAccess,
|
canCurrentUserChangeAccess,
|
||||||
canCurrentUserDeletePage,
|
canCurrentUserDeletePage,
|
||||||
|
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
export * from "ce/constants/page";
|
|
||||||
1
web/ee/hooks/use-page-flag.ts
Normal file
1
web/ee/hooks/use-page-flag.ts
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
export * from "ce/hooks/use-page-flag";
|
||||||
Loading…
Add table
Add a link
Reference in a new issue