-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[WIKI-320] refactor: page header actions #6946
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
4 commits
Select commit
Hold shift + click to select a range
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| "use client"; | ||
|
|
||
| // store | ||
| import { TPageInstance } from "@/store/pages/base-page"; | ||
|
|
||
| export type TPageCollaboratorsListProps = { | ||
| page: TPageInstance; | ||
| }; | ||
|
|
||
| export const PageCollaboratorsList = ({}: TPageCollaboratorsListProps) => 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,116 @@ | ||
| "use client"; | ||
|
|
||
| import { useState, useEffect, useRef } from "react"; | ||
| import { observer } from "mobx-react"; | ||
| import { LockKeyhole, LockKeyholeOpen } from "lucide-react"; | ||
| // plane imports | ||
| import { Tooltip } from "@plane/ui"; | ||
| // hooks | ||
| import { usePageOperations } from "@/hooks/use-page-operations"; | ||
| // store | ||
| import { TPageInstance } from "@/store/pages/base-page"; | ||
|
|
||
| // Define our lock display states, renaming "icon-only" to "neutral" | ||
| type LockDisplayState = "neutral" | "locked" | "unlocked"; | ||
|
|
||
| type Props = { | ||
| page: TPageInstance; | ||
| }; | ||
|
|
||
| export const PageLockControl = observer(({ page }: Props) => { | ||
| // Initial state: if locked, then "locked", otherwise default to "neutral" | ||
| const [displayState, setDisplayState] = useState<LockDisplayState>(page.is_locked ? "locked" : "neutral"); | ||
| // derived values | ||
| const { canCurrentUserLockPage, is_locked } = page; | ||
| // Ref for the transition timer | ||
| const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null); | ||
| // Ref to store the previous value of isLocked for detecting transitions | ||
| const prevLockedRef = useRef(is_locked); | ||
| // page operations | ||
| const { | ||
| pageOperations: { toggleLock }, | ||
| } = usePageOperations({ | ||
| page, | ||
| }); | ||
|
|
||
| // Cleanup any running timer on unmount | ||
| useEffect( | ||
| () => () => { | ||
| if (timerRef.current) clearTimeout(timerRef.current); | ||
| }, | ||
| [] | ||
| ); | ||
|
|
||
| // Update display state when isLocked changes | ||
| useEffect(() => { | ||
| // Clear any previous timer to avoid overlapping transitions | ||
| if (timerRef.current) { | ||
| clearTimeout(timerRef.current); | ||
| timerRef.current = null; | ||
| } | ||
|
|
||
| // Transition logic: | ||
| // If locked, ensure the display state is "locked" | ||
| // If unlocked after being locked, show "unlocked" briefly then revert to "neutral" | ||
| if (is_locked) { | ||
| setDisplayState("locked"); | ||
| } else if (prevLockedRef.current === true) { | ||
| setDisplayState("unlocked"); | ||
| timerRef.current = setTimeout(() => { | ||
| setDisplayState("neutral"); | ||
| timerRef.current = null; | ||
| }, 600); | ||
| } else { | ||
| setDisplayState("neutral"); | ||
| } | ||
|
|
||
| // Update the previous locked state | ||
| prevLockedRef.current = is_locked; | ||
| }, [is_locked]); | ||
|
|
||
| if (!canCurrentUserLockPage) return null; | ||
|
|
||
| // Render different UI based on the current display state | ||
| return ( | ||
| <> | ||
| {displayState === "neutral" && ( | ||
| <Tooltip tooltipContent="Lock" position="bottom"> | ||
| <button | ||
| type="button" | ||
| onClick={toggleLock} | ||
| className="flex-shrink-0 size-6 grid place-items-center rounded text-custom-text-200 hover:text-custom-text-100 hover:bg-custom-background-80 transition-colors" | ||
| aria-label="Lock" | ||
| > | ||
| <LockKeyhole className="size-3.5" /> | ||
| </button> | ||
| </Tooltip> | ||
| )} | ||
|
|
||
| {displayState === "locked" && ( | ||
| <button | ||
| type="button" | ||
| onClick={toggleLock} | ||
| className="h-6 flex items-center gap-1 px-2 rounded text-custom-primary-100 bg-custom-primary-100/20 hover:bg-custom-primary-100/30 transition-colors" | ||
| aria-label="Locked" | ||
| > | ||
| <LockKeyhole className="flex-shrink-0 size-3.5 animate-lock-icon" /> | ||
| <span className="text-xs font-medium whitespace-nowrap overflow-hidden transition-all duration-500 ease-out animate-text-slide-in"> | ||
| Locked | ||
| </span> | ||
| </button> | ||
| )} | ||
|
|
||
| {displayState === "unlocked" && ( | ||
| <div | ||
| className="h-6 flex items-center gap-1 px-2 rounded text-custom-text-200 animate-fade-out" | ||
| aria-label="Unlocked" | ||
| > | ||
| <LockKeyholeOpen className="flex-shrink-0 size-3.5 animate-unlock-icon" /> | ||
| <span className="text-xs font-medium whitespace-nowrap overflow-hidden transition-all duration-500 ease-out animate-text-slide-in animate-text-fade-out"> | ||
| Unlocked | ||
| </span> | ||
| </div> | ||
| )} | ||
| </> | ||
| ); | ||
| }); |
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 @@ | ||
| "use client"; | ||
|
|
||
| // store | ||
| import { TPageInstance } from "@/store/pages/base-page"; | ||
|
|
||
| export type TPageMoveControlProps = { | ||
| page: TPageInstance; | ||
| }; | ||
|
|
||
| export const PageMoveControl = ({}: TPageMoveControlProps) => null; |
19 changes: 0 additions & 19 deletions
19
web/core/components/pages/dropdowns/edit-information-popover.tsx
This file was deleted.
Oops, something went wrong.
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 @@ | ||
| export * from "./actions"; | ||
| export * from "./edit-information-popover"; |
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
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.