-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[WEB-5573] refactor: app rail enhancements #8239
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
6 commits
Select commit
Hold shift + click to select a range
1a7e15a
chore: app rail context added
anmolsinghbhatia 8667f12
chore: dock/undock app rail implementation
anmolsinghbhatia 099668f
chore: refactor
anmolsinghbhatia 3f3243e
chore: code refactor
anmolsinghbhatia 13af6d2
chore: code refactor
anmolsinghbhatia e8ed58f
Merge branch 'preview' of github.com:makeplane/plane into refactor-ap…
anmolsinghbhatia 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 @@ | ||
| export * from "./provider"; |
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,17 @@ | ||
| "use client"; | ||
|
|
||
| import React from "react"; | ||
| import { observer } from "mobx-react"; | ||
| import { AppRailVisibilityProvider as CoreProvider } from "@/lib/app-rail"; | ||
|
|
||
| interface AppRailVisibilityProviderProps { | ||
| children: React.ReactNode; | ||
| } | ||
|
|
||
| /** | ||
| * CE AppRailVisibilityProvider | ||
| * Wraps core provider with isEnabled hardcoded to false | ||
| */ | ||
| export const AppRailVisibilityProvider = observer(({ children }: AppRailVisibilityProviderProps) => ( | ||
| <CoreProvider isEnabled={false}>{children}</CoreProvider> | ||
| )); |
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 |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| "use client"; | ||
|
|
||
| import { createContext, useContext } from "react"; | ||
| import type { IAppRailVisibilityContext } from "./types"; | ||
|
|
||
| /** | ||
| * Context for app-rail visibility control | ||
| * Provides access to app rail enabled state, collapse state, and toggle function | ||
| */ | ||
| export const AppRailVisibilityContext = createContext<IAppRailVisibilityContext | undefined>(undefined); | ||
|
|
||
| /** | ||
| * Hook to consume the AppRailVisibilityContext | ||
| * Must be used within an AppRailVisibilityProvider | ||
| * | ||
| * @returns The app rail visibility context | ||
| * @throws Error if used outside of AppRailVisibilityProvider | ||
| */ | ||
| export const useAppRailVisibility = (): IAppRailVisibilityContext => { | ||
| const context = useContext(AppRailVisibilityContext); | ||
| if (context === undefined) { | ||
| throw new Error("useAppRailVisibility must be used within AppRailVisibilityProvider"); | ||
| } | ||
| return context; | ||
| }; |
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,3 @@ | ||
| export * from "./context"; | ||
| export * from "./provider"; | ||
| export * from "./types"; |
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,46 @@ | ||
| "use client"; | ||
|
|
||
| import React, { useCallback, useMemo } from "react"; | ||
| import { observer } from "mobx-react"; | ||
| import { useParams } from "next/navigation"; | ||
| import useLocalStorage from "@/hooks/use-local-storage"; | ||
| import { AppRailVisibilityContext } from "./context"; | ||
| import type { IAppRailVisibilityContext } from "./types"; | ||
|
|
||
| interface AppRailVisibilityProviderProps { | ||
| children: React.ReactNode; | ||
| isEnabled?: boolean; // Allow override, default false | ||
| } | ||
|
|
||
| /** | ||
| * AppRailVisibilityProvider - manages app rail visibility state | ||
| * Base provider that accepts isEnabled as a prop | ||
| */ | ||
| export const AppRailVisibilityProvider = observer(({ children, isEnabled = false }: AppRailVisibilityProviderProps) => { | ||
| const { workspaceSlug } = useParams(); | ||
|
|
||
| // User preference from localStorage | ||
| const { storedValue: isCollapsed, setValue: setIsCollapsed } = useLocalStorage<boolean>( | ||
| `APP_RAIL_${workspaceSlug}`, | ||
| false // Default: not collapsed (app rail visible) | ||
| ); | ||
anmolsinghbhatia marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| const toggleAppRail = useCallback(() => { | ||
| setIsCollapsed(!isCollapsed); | ||
| }, [isCollapsed, setIsCollapsed]); | ||
anmolsinghbhatia marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| // Compute final visibility: enabled and not collapsed | ||
| const shouldRenderAppRail = isEnabled && !isCollapsed; | ||
|
|
||
| const value: IAppRailVisibilityContext = useMemo( | ||
| () => ({ | ||
| isEnabled, | ||
| isCollapsed: isCollapsed ?? false, | ||
| shouldRenderAppRail, | ||
| toggleAppRail, | ||
| }), | ||
| [isEnabled, isCollapsed, shouldRenderAppRail, toggleAppRail] | ||
| ); | ||
|
|
||
| return <AppRailVisibilityContext.Provider value={value}>{children}</AppRailVisibilityContext.Provider>; | ||
| }); | ||
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,26 @@ | ||
| /** | ||
| * Type definitions for app-rail visibility context | ||
| */ | ||
|
|
||
| export interface IAppRailVisibilityContext { | ||
| /** | ||
| * Whether the app rail is enabled | ||
| */ | ||
| isEnabled: boolean; | ||
|
|
||
| /** | ||
| * Whether the app rail is collapsed (user preference from localStorage) | ||
| */ | ||
| isCollapsed: boolean; | ||
|
|
||
| /** | ||
| * Computed property: whether the app rail should actually render | ||
| * True only if isEnabled && !isCollapsed | ||
| */ | ||
| shouldRenderAppRail: boolean; | ||
|
|
||
| /** | ||
| * Toggle the collapse state of the app rail | ||
| */ | ||
| toggleAppRail: () => void; | ||
| } |
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 "ce/hooks/app-rail"; |
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
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.