-
Notifications
You must be signed in to change notification settings - Fork 3.4k
[PE-97] chore: add page flag hook for authorization #6354
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
Conversation
WalkthroughThis pull request introduces changes to page-related functionality across multiple files. The primary modifications include removing the Changes
Sequence DiagramsequenceDiagram
participant PageActions as PageActions Component
participant usePageFlag as usePageFlag Hook
participant Params as useParams Hook
Params->>PageActions: Provide workspaceSlug
PageActions->>usePageFlag: Call with workspaceSlug
usePageFlag-->>PageActions: Return isMovePageEnabled
alt isMovePageEnabled is true
PageActions->>PageActions: Render Move Page Option
else
PageActions->>PageActions: Hide Move Page Option
end
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
web/core/components/pages/dropdowns/actions.tsx (1)
64-69: Improve type safety for workspaceSlug.The current implementation has a potential type safety issue with
workspaceSlug. Consider handling the undefined case more explicitly.Apply this diff to improve type safety:
// params const { workspaceSlug } = useParams(); // page flag const { isMovePageEnabled } = usePageFlag({ - workspaceSlug: workspaceSlug?.toString() ?? "", + workspaceSlug: workspaceSlug ? workspaceSlug.toString() : "", });
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
web/ce/constants/page.ts(0 hunks)web/ce/hooks/use-page-flag.ts(1 hunks)web/core/components/pages/dropdowns/actions.tsx(5 hunks)web/ee/constants/page.ts(0 hunks)web/ee/hooks/use-page-flag.ts(1 hunks)
💤 Files with no reviewable changes (2)
- web/ce/constants/page.ts
- web/ee/constants/page.ts
✅ Files skipped from review due to trivial changes (1)
- web/ee/hooks/use-page-flag.ts
🧰 Additional context used
🪛 Biome (1.9.4)
web/ce/hooks/use-page-flag.ts
[error] 10-10: Unexpected empty object pattern.
(lint/correctness/noEmptyPattern)
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: lint-web
- GitHub Check: Analyze (javascript)
- GitHub Check: Analyze (python)
🔇 Additional comments (3)
web/ce/hooks/use-page-flag.ts (2)
1-7: LGTM! Well-defined types.The type definitions are clear and purposeful:
TPageFlagHookArgs: Defines required workspace contextTPageFlagHookReturnType: Clearly specifies the feature flag structure
9-14:⚠️ Potential issueHook implementation needs completion.
The current implementation appears to be a placeholder:
- The
workspaceSlugparameter is not utilized- The hook returns a static
falsevalue- There's an unnecessary empty object destructuring
Apply this diff to fix the immediate issues:
export const usePageFlag = (args: TPageFlagHookArgs): TPageFlagHookReturnType => { - const {} = args; + const { workspaceSlug } = args; return { isMovePageEnabled: false, }; };Additionally, please implement the actual authorization logic using the
workspaceSlug. Consider:
- Fetching workspace settings/permissions
- Checking user roles/permissions
- Implementing proper feature flag checks
Would you like me to help implement the authorization logic?
🧰 Tools
🪛 Biome (1.9.4)
[error] 10-10: Unexpected empty object pattern.
(lint/correctness/noEmptyPattern)
web/core/components/pages/dropdowns/actions.tsx (1)
144-144: LGTM! Proper integration of the feature flag.The move page menu item correctly combines both permission check (
canCurrentUserMovePage) and feature flag (isMovePageEnabled). The dependencies array is also properly updated.Also applies to: 156-156
Description
This PR adds a new
usePageFlaghook for handling page actions' authorization in a better way.Type of Change
Summary by CodeRabbit
Release Notes
Refactor
ENABLE_MOVE_PAGEconstantNew Features
usePageFlaghook to dynamically manage page-related feature flags