-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[PE-97] refactor: pages actions #6234
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
d238bac
dev: support for edition specific options in pages
aaryan610 9ceb91c
refactor: page quick actions
aaryan610 bb00042
chore: add customizable page actions
aaryan610 835440f
fix: type errors
aaryan610 1314d3d
dev: hook to get page operations
aaryan610 8416b48
refactor: remove unnecessary props
aaryan610 436e4ac
chore: add permisssions to duplicate page endpoint
aaryan610 c060024
chore: memoize arranged options
aaryan610 84acc60
Merge branch 'preview' of https://github.com/makeplane/plane into dev…
aaryan610 f0a41bd
chore: use enum for page access
aaryan610 9bcbf24
chore: add type assertion
aaryan610 8806a67
fix: auth for access change and delete
aaryan610 3b6892d
fix: merge conflicts resolved from preview
aaryan610 d29ab80
fix: removing readonly editor
Palanikannan1437 383fb56
fix: merge conflicts resolved from preview
aaryan610 d52b747
chore: add sync for page access cahnge
aaryan610 2b06dfa
fix: sync state
Palanikannan1437 09f2be4
fix: indexeddb sync loader added
Palanikannan1437 7959a19
fix: remove node error fixed
Palanikannan1437 a7ddf3d
style: page title and checkbox
aaryan610 96c2f6d
chore: removing the syncing logic
Palanikannan1437 2fc1ac7
revert: is editable check removed in display message
Palanikannan1437 25abb9e
fix: editable field optional
Palanikannan1437 6189411
fix: editable removed as optional prop
Palanikannan1437 f24d8a1
fix: extra options import fix
Palanikannan1437 4dd215c
Merge branch 'dev/page-options' into fix/realtime-ref
Palanikannan1437 6fe2eef
fix: remove readonly stuff
Palanikannan1437 43db528
fix: added toggle access
Palanikannan1437 e0958b4
fix: merge conflicts resolved from preview
aaryan610 3992bd2
chore: add access change sync
aaryan610 63c59df
fix: full width toggle
aaryan610 732da3e
refactor: types and enums added
aaryan610 a5bae52
refactore: update store action
aaryan610 ba90bfc
chore: changed the duplicate viewset
NarayanBavisetti 0c963ff
fix: merge conflicts resolved from preview
NarayanBavisetti 3527e6d
fix: remove the page binary
NarayanBavisetti 190d0c6
fix: duplicate page action
aaryan610 941d4bb
fix: merge conflicts
Palanikannan1437 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,3 @@ | ||
| export * from "./editor"; | ||
| export * from "./modals"; | ||
| export * from "./extra-actions"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export * from "./move-page-modal"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| // store types | ||
| import { TPageInstance } from "@/store/pages/base-page"; | ||
|
|
||
| export type TMovePageModalProps = { | ||
| isOpen: boolean; | ||
| onClose: () => void; | ||
| page: TPageInstance; | ||
| }; | ||
|
|
||
| export const MovePageModal: React.FC<TMovePageModalProps> = () => null; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,195 @@ | ||
| "use client"; | ||
|
|
||
| import { useMemo, useState } from "react"; | ||
| import { observer } from "mobx-react"; | ||
| import { | ||
| ArchiveRestoreIcon, | ||
| Copy, | ||
| ExternalLink, | ||
| FileOutput, | ||
| Globe2, | ||
| Link, | ||
| Lock, | ||
| LockKeyhole, | ||
| LockKeyholeOpen, | ||
| Trash2, | ||
| } from "lucide-react"; | ||
| // plane editor | ||
| import { EditorRefApi } from "@plane/editor"; | ||
| // plane ui | ||
| import { ArchiveIcon, ContextMenu, CustomMenu, TContextMenuItem } from "@plane/ui"; | ||
| // components | ||
| import { DeletePageModal } from "@/components/pages"; | ||
| // constants | ||
| import { EPageAccess } from "@/constants/page"; | ||
| // helpers | ||
| import { cn } from "@/helpers/common.helper"; | ||
| // hooks | ||
| import { usePageOperations } from "@/hooks/use-page-operations"; | ||
| // plane web components | ||
| import { MovePageModal } from "@/plane-web/components/pages"; | ||
| // store types | ||
| import { TPageInstance } from "@/store/pages/base-page"; | ||
|
|
||
| export type TPageActions = | ||
| | "full-screen" | ||
| | "copy-markdown" | ||
| | "toggle-lock" | ||
| | "toggle-access" | ||
| | "open-in-new-tab" | ||
| | "copy-link" | ||
| | "make-a-copy" | ||
| | "archive-restore" | ||
| | "delete" | ||
| | "version-history" | ||
| | "export" | ||
| | "move"; | ||
|
|
||
| type Props = { | ||
| editorRef?: EditorRefApi | null; | ||
| extraOptions?: (TContextMenuItem & { key: TPageActions })[]; | ||
| optionsOrder: TPageActions[]; | ||
| page: TPageInstance; | ||
| parentRef?: React.RefObject<HTMLElement>; | ||
| }; | ||
|
|
||
| export const PageActions: React.FC<Props> = observer((props) => { | ||
| const { editorRef, extraOptions, optionsOrder, page, parentRef } = props; | ||
| // states | ||
| const [deletePageModal, setDeletePageModal] = useState(false); | ||
| const [movePageModal, setMovePageModal] = useState(false); | ||
| // page operations | ||
| const { pageOperations } = usePageOperations({ | ||
| editorRef, | ||
| page, | ||
| }); | ||
| // derived values | ||
| const { | ||
| access, | ||
| archived_at, | ||
| is_locked, | ||
| canCurrentUserArchivePage, | ||
| canCurrentUserChangeAccess, | ||
| canCurrentUserDeletePage, | ||
| canCurrentUserDuplicatePage, | ||
| canCurrentUserLockPage, | ||
| canCurrentUserMovePage, | ||
| } = page; | ||
| // menu items | ||
| const MENU_ITEMS: (TContextMenuItem & { key: TPageActions })[] = useMemo(() => { | ||
| const menuItems: (TContextMenuItem & { key: TPageActions })[] = [ | ||
| { | ||
| key: "toggle-lock", | ||
| action: pageOperations.toggleLock, | ||
| title: is_locked ? "Unlock" : "Lock", | ||
| icon: is_locked ? LockKeyholeOpen : LockKeyhole, | ||
| shouldRender: canCurrentUserLockPage, | ||
| }, | ||
| { | ||
| key: "toggle-access", | ||
| action: pageOperations.toggleAccess, | ||
| title: access === EPageAccess.PUBLIC ? "Make private" : "Make public", | ||
| icon: access === EPageAccess.PUBLIC ? Lock : Globe2, | ||
| shouldRender: canCurrentUserChangeAccess && !archived_at, | ||
| }, | ||
| { | ||
| key: "open-in-new-tab", | ||
| action: pageOperations.openInNewTab, | ||
| title: "Open in new tab", | ||
| icon: ExternalLink, | ||
| shouldRender: true, | ||
| }, | ||
| { | ||
| key: "copy-link", | ||
| action: pageOperations.copyLink, | ||
| title: "Copy link", | ||
| icon: Link, | ||
| shouldRender: true, | ||
| }, | ||
| { | ||
| key: "make-a-copy", | ||
| action: pageOperations.duplicate, | ||
| title: "Make a copy", | ||
| icon: Copy, | ||
| shouldRender: canCurrentUserDuplicatePage, | ||
| }, | ||
| { | ||
| key: "archive-restore", | ||
| action: pageOperations.toggleArchive, | ||
| title: archived_at ? "Restore" : "Archive", | ||
| icon: archived_at ? ArchiveRestoreIcon : ArchiveIcon, | ||
| shouldRender: canCurrentUserArchivePage, | ||
| }, | ||
| { | ||
| key: "delete", | ||
| action: () => setDeletePageModal(true), | ||
| title: "Delete", | ||
| icon: Trash2, | ||
| shouldRender: canCurrentUserDeletePage && !!archived_at, | ||
| }, | ||
| { | ||
| key: "move", | ||
| action: () => setMovePageModal(true), | ||
| title: "Move", | ||
| icon: FileOutput, | ||
| shouldRender: canCurrentUserMovePage, | ||
| }, | ||
| ]; | ||
| if (extraOptions) { | ||
| menuItems.push(...extraOptions); | ||
| } | ||
| return menuItems; | ||
| }, [ | ||
| access, | ||
| archived_at, | ||
| extraOptions, | ||
| is_locked, | ||
| canCurrentUserArchivePage, | ||
| canCurrentUserChangeAccess, | ||
| canCurrentUserDeletePage, | ||
| canCurrentUserDuplicatePage, | ||
| canCurrentUserLockPage, | ||
| canCurrentUserMovePage, | ||
| pageOperations, | ||
| ]); | ||
| // arrange options | ||
| const arrangedOptions = useMemo( | ||
| () => | ||
| optionsOrder | ||
| .map((key) => MENU_ITEMS.find((item) => item.key === key)) | ||
| .filter((item) => !!item) as (TContextMenuItem & { key: TPageActions })[], | ||
| [optionsOrder, MENU_ITEMS] | ||
| ); | ||
|
|
||
| return ( | ||
| <> | ||
| <MovePageModal isOpen={movePageModal} onClose={() => setMovePageModal(false)} page={page} /> | ||
| <DeletePageModal isOpen={deletePageModal} onClose={() => setDeletePageModal(false)} page={page} /> | ||
| {parentRef && <ContextMenu parentRef={parentRef} items={arrangedOptions} />} | ||
| <CustomMenu placement="bottom-end" optionsClassName="max-h-[90vh]" ellipsis closeOnSelect> | ||
| {arrangedOptions.map((item) => { | ||
| if (item.shouldRender === false) return null; | ||
| return ( | ||
| <CustomMenu.MenuItem | ||
| key={item.key} | ||
| onClick={(e) => { | ||
| e.preventDefault(); | ||
| e.stopPropagation(); | ||
| item.action?.(); | ||
| }} | ||
| className={cn("flex items-center gap-2", item.className)} | ||
| disabled={item.disabled} | ||
| > | ||
| {item.customContent ?? ( | ||
| <> | ||
| {item.icon && <item.icon className="size-3" />} | ||
| {item.title} | ||
| </> | ||
| )} | ||
| </CustomMenu.MenuItem> | ||
| ); | ||
| })} | ||
| </CustomMenu> | ||
| </> | ||
| ); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,2 @@ | ||
| export * from "./actions"; | ||
| export * from "./edit-information-popover"; | ||
| export * from "./quick-actions"; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.