Skip to content

[WEB-3759] chore: header revamp for cycles, modules, pages and views#6875

Merged
sriramveeraghanta merged 4 commits intopreviewfrom
chore-header-revamp
Apr 9, 2025
Merged

[WEB-3759] chore: header revamp for cycles, modules, pages and views#6875
sriramveeraghanta merged 4 commits intopreviewfrom
chore-header-revamp

Conversation

@vamsikrishnamathala
Copy link
Member

@vamsikrishnamathala vamsikrishnamathala commented Apr 7, 2025

Description

Added switcher for detail pages and quick actions menu to the header.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • Feature (non-breaking change which adds functionality)
  • Improvement (change that would cause existing functionality to not work as expected)
  • Code refactoring
  • Performance improvements
  • Documentation update

Screenshots and Media (if applicable)

Test Scenarios

References

WEB-3759

Summary by CodeRabbit

  • New Features

    • Introduced a unified search select interface across cycles, modules, pages, and views for streamlined navigation.
    • Added a customizable label component for enhanced dropdown displays.
    • Enhanced project page details layout with dynamic data fetching capabilities.
  • Refactor

    • Replaced legacy menu components with interactive, simplified search selects.
    • Removed outdated restore and copy actions, offering a cleaner, more focused interface.
    • Updated page filtering to support improved tab-based navigation.
  • Style

    • Applied minor UI tweaks and added custom styling options to quick action buttons.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Apr 7, 2025

Walkthrough

This pull request introduces a range of updates across components and stores. A new type definition, ICustomSearchSelectOption, has been added to standardize dropdown selections. Several header components in cycles, modules, pages, and views now use a simplified selection mechanism with CustomSearchSelect and corresponding switcherOptions, replacing the previous CustomMenu implementations. The updates also include the addition of the SwitcherLabel component, customization props for quick actions, refactoring of page store methods for tab-based filtering, and removal of deprecated functions in analytics sidebars.

Changes

Files Summary
packages/types/src/common.d.ts Added new type ICustomSearchSelectOption with properties: value, query, content, disabled?, and tooltip?.
packages/ui/src/dropdowns/helper.tsx
web/app/[...]/cycles/(detail)/header.tsx
web/app/[...]/modules/(detail)/header.tsx
web/app/[...]/pages/(detail)/header.tsx
web/app/[...]/views/(detail)/header.tsx
Updated header components by importing ICustomSearchSelectOption and replacing legacy CustomMenu with CustomSearchSelect. Introduced switcherOptions for streamlined option handling and adjusted UI elements accordingly.
web/core/components/common/index.ts
web/core/components/common/switcher-label.tsx
Added new SwitcherLabel component and exported it via the common index for enhanced label rendering.
web/core/components/cycles/quick-actions.tsx
web/core/components/modules/quick-actions.tsx
web/core/components/views/quick-actions.tsx
Introduced the new optional property customClassName in QuickActions components to support custom styling for the CustomMenu button.
web/core/store/pages/project-page.store.ts
web/core/components/pages/list/root.tsx
web/core/components/pages/pages-list-main-content.tsx
Renamed and updated methods for retrieving page IDs (switching to tab-based variants) and modified the fetchPagesList signature for optional parameters.
web/core/components/cycles/analytics-sidebar/sidebar-header.tsx
web/core/components/modules/analytics-sidebar/root.tsx
Removed legacy functions (handleRestoreCycle, handleCopyText, handleRestoreModule) and the associated UI elements for cycle and module restoration and link copying.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant CSS as CustomSearchSelect
    participant HC as Header Component
    participant L as Link Component
    
    U->>CSS: Clicks to open options
    CSS->>HC: Requests switcherOptions
    HC-->>CSS: Provides options (value, query, content)
    U->>CSS: Selects an option
    CSS->>L: Renders link with selected option
    L-->>U: Navigates to target page
Loading

Possibly related PRs

  • [WEB-3748, 3749] feat: work item description version history #6863: The changes in the main PR, which involve adding a new type definition ICustomSearchSelectOption, are related to the retrieved PR as both involve modifications to the handling of options for components, specifically through the use of the ICustomSearchSelectOption type in the UI components.

Suggested labels

✨feature

Suggested reviewers

  • prateekshourya29
  • sriramveeraghanta

Poem

I'm a little rabbit, hopping with delight,
New types and components make coding so bright.
Menus turned to search selects with a clever twist,
Quick actions and clean code, nothing's missed.
Hop along the code path, where ideas take flight!
🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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 (4)
packages/types/src/common.d.ts (1)

30-36: Consider using generics for type safety in the new ICustomSearchSelectOption type.

The introduction of ICustomSearchSelectOption is a good approach to standardize dropdown selections across components. However, using any for the value property reduces type safety.

Consider making the type more type-safe by using a generic parameter:

-export type ICustomSearchSelectOption = {
+export type ICustomSearchSelectOption<T = any> = {
-  value: any;
+  value: T;
   query: string;
   content: React.ReactNode;
   disabled?: boolean;
   tooltip?: string | React.ReactNode;
};

This would allow components to specify the exact type for their values while maintaining backward compatibility with existing code.

web/app/[workspaceSlug]/(projects)/projects/(detail)/[projectId]/modules/(detail)/header.tsx (1)

221-243: Replaced Custom Menu with SearchSelect for improved module selection.

Upgraded the module selection UI from a basic menu to a more interactive search select component, allowing users to more easily find and switch between modules. This implements the "switcher for detail pages" objective mentioned in the PR.

One minor issue: The onChange handler is currently a no-op function () => {}. Consider implementing proper navigation logic here instead of relying solely on the Link component within each option.

-  onChange={() => {}}
+  onChange={(value) => {
+    if (value && value !== moduleId) {
+      router.push(`/${workspaceSlug}/projects/${projectId}/modules/${value}`);
+    }
+  }}
web/app/[workspaceSlug]/(projects)/projects/(detail)/[projectId]/views/(detail)/[viewId]/header.tsx (1)

272-280: ViewQuickActions integration needs accessibility consideration.

While the ViewQuickActions component has been properly integrated with custom styling, consider adding an aria-label to improve accessibility for the quick actions button.

<ViewQuickActions
  parentRef={parentRef}
  customClassName="flex-shrink-0 flex items-center justify-center size-6 bg-custom-background-80/70 rounded"
+ aria-label="View quick actions"
  projectId={projectId.toString()}
  view={viewDetails}
  workspaceSlug={workspaceSlug.toString()}
/>
web/app/[workspaceSlug]/(projects)/projects/(detail)/[projectId]/cycles/(detail)/header.tsx (1)

333-339: Added CycleQuickActions with consistent styling.

The CycleQuickActions component is properly integrated with custom styling that matches the design pattern used in other headers. Consider adding an aria-label for better accessibility.

<CycleQuickActions
  parentRef={parentRef}
  cycleId={cycleId}
  projectId={projectId}
  workspaceSlug={workspaceSlug}
  customClassName="flex-shrink-0 flex items-center justify-center size-6 bg-custom-background-80/70 rounded"
+ aria-label="Cycle quick actions"
/>
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 34337f9 and ad8d367.

📒 Files selected for processing (16)
  • packages/types/src/common.d.ts (1 hunks)
  • packages/ui/src/dropdowns/helper.tsx (2 hunks)
  • web/app/[workspaceSlug]/(projects)/projects/(detail)/[projectId]/cycles/(detail)/header.tsx (6 hunks)
  • web/app/[workspaceSlug]/(projects)/projects/(detail)/[projectId]/modules/(detail)/header.tsx (3 hunks)
  • web/app/[workspaceSlug]/(projects)/projects/(detail)/[projectId]/pages/(detail)/header.tsx (2 hunks)
  • web/app/[workspaceSlug]/(projects)/projects/(detail)/[projectId]/views/(detail)/[viewId]/header.tsx (5 hunks)
  • web/core/components/common/index.ts (1 hunks)
  • web/core/components/common/switcher-label.tsx (1 hunks)
  • web/core/components/cycles/analytics-sidebar/sidebar-header.tsx (0 hunks)
  • web/core/components/cycles/quick-actions.tsx (2 hunks)
  • web/core/components/modules/analytics-sidebar/root.tsx (3 hunks)
  • web/core/components/modules/quick-actions.tsx (2 hunks)
  • web/core/components/pages/list/root.tsx (1 hunks)
  • web/core/components/pages/pages-list-main-content.tsx (1 hunks)
  • web/core/components/views/quick-actions.tsx (2 hunks)
  • web/core/store/pages/project-page.store.ts (4 hunks)
💤 Files with no reviewable changes (1)
  • web/core/components/cycles/analytics-sidebar/sidebar-header.tsx
🧰 Additional context used
🧬 Code Definitions (6)
web/core/components/pages/list/root.tsx (1)
web/ce/hooks/store/use-page-store.ts (1)
  • usePageStore (15-24)
web/core/components/cycles/quick-actions.tsx (1)
packages/ui/src/dropdowns/custom-menu.tsx (1)
  • CustomMenu (232-232)
web/app/[workspaceSlug]/(projects)/projects/(detail)/[projectId]/pages/(detail)/header.tsx (6)
web/ce/hooks/store/use-page.ts (1)
  • usePage (12-23)
web/ce/hooks/store/use-page-store.ts (1)
  • usePageStore (15-24)
web/core/store/router.store.ts (2)
  • projectId (85-87)
  • workspaceSlug (69-71)
web/core/components/common/switcher-label.tsx (1)
  • SwitcherLabel (13-27)
packages/types/src/common.d.ts (1)
  • ICustomSearchSelectOption (30-36)
packages/ui/src/dropdowns/custom-search-select.tsx (1)
  • CustomSearchSelect (14-218)
packages/ui/src/dropdowns/helper.tsx (1)
packages/types/src/common.d.ts (1)
  • ICustomSearchSelectOption (30-36)
web/app/[workspaceSlug]/(projects)/projects/(detail)/[projectId]/views/(detail)/[viewId]/header.tsx (3)
web/core/components/common/switcher-label.tsx (1)
  • SwitcherLabel (13-27)
packages/types/src/common.d.ts (1)
  • ICustomSearchSelectOption (30-36)
packages/ui/src/dropdowns/custom-search-select.tsx (1)
  • CustomSearchSelect (14-218)
web/core/store/pages/project-page.store.ts (3)
packages/types/src/pages.d.ts (2)
  • TPageNavigationTabs (27-27)
  • TPageFilters (40-45)
web/core/store/router.store.ts (2)
  • projectId (85-87)
  • workspaceSlug (69-71)
web/core/store/pages/project-page.ts (1)
  • TProjectPage (14-14)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Analyze (javascript)
  • GitHub Check: Analyze (python)
🔇 Additional comments (53)
web/core/components/pages/list/root.tsx (1)

20-22: Method name updated to reflect tab-based filtering.

The method name change from getCurrentProjectFilteredPageIds to getCurrentProjectFilteredPageIdsByTab accurately reflects that the filtering is based on tabs, making the code more descriptive.

web/core/components/modules/quick-actions.tsx (3)

27-27: Good addition of customization option.

Adding the customClassName property enhances the component's flexibility by allowing custom styling.


31-31: Property correctly destructured from props.

The customClassName property is properly destructured from the props.


171-171: Properly implemented custom styling for dropdown.

The customClassName is correctly passed to the CustomMenu component as buttonClassName, allowing for customized appearance of the menu button.

web/core/components/pages/pages-list-main-content.tsx (2)

29-30: Updated method names for tab-based filtering.

The destructuring now uses the updated method names getCurrentProjectFilteredPageIdsByTab and getCurrentProjectPageIdsByTab, which better describe their functionality.


34-35: Consistently using the updated method names.

Both pageIds and filteredPageIds now use the new method names, maintaining consistency with the store refactoring.

web/core/components/modules/analytics-sidebar/root.tsx (3)

7-7: Cleaned up imports by removing unused icons.

The import list has been simplified by removing unnecessary icons like ArchiveRestoreIcon, LinkIcon, Trash2, and ArchiveIcon that were likely used in now-removed functionality.


22-22: Streamlined UI imports, removing unused components.

The imports from @plane/ui have been updated to remove unused components that were related to functionality that has been removed.


69-70: Simplified hook usage by removing unused methods.

The destructuring of methods from useModule and useEventTracker has been updated to include only the methods that are actually used in the component, removing references to methods associated with the removed functionality.

web/core/store/pages/project-page.store.ts (7)

40-42: Renamed and added methods for better API clarity.

The interface has been improved by:

  1. Renaming getCurrentProjectPageIds to getCurrentProjectPageIdsByTab to clearly indicate it filters by tab type
  2. Adding a new getCurrentProjectPageIds method that takes a projectId parameter to get all pages for a project
  3. Renaming getCurrentProjectFilteredPageIds to getCurrentProjectFilteredPageIdsByTab for consistency

These changes make the API more intuitive and consistent.


50-50: Made pageType parameter optional for more flexibility.

Making the pageType parameter optional in fetchPagesList allows for more flexible usage of the method, particularly when fetching all pages without filtering by type.


129-139: Renamed method with clear "ByTab" indicator.

The implementation of the renamed getCurrentProjectPageIdsByTab method maintains the same functionality but with a clearer name that indicates it filters pages based on the tab type.


141-149: Added new method to get all pages for a project.

This new implementation of getCurrentProjectPageIds fetches all pages associated with a project ID without filtering by tab type, providing a useful utility for components that need all pages.


155-172: Renamed filtered method for consistency.

The implementation of getCurrentProjectFilteredPageIdsByTab maintains the same functionality but with a renamed method that matches the pattern of other methods and clearly indicates filtering by tab.


197-197: Updated method signature with optional parameter.

The signature of fetchPagesList has been updated to make the pageType parameter optional, allowing for more flexible method calls.


201-201: Updated method call to use renamed method.

The implementation now correctly uses the renamed getCurrentProjectPageIdsByTab method, maintaining consistency with the interface changes.

web/core/components/common/index.ts (1)

9-9: Added export for new SwitcherLabel component.

Added a new export for the SwitcherLabel component, which is likely part of the header revamp mentioned in the PR objectives for cycles, modules, pages, and views.

web/core/components/cycles/quick-actions.tsx (3)

27-27: Added customClassName property for enhanced flexibility.

Added a new optional customClassName property to the Props interface, which allows parent components to customize the appearance of the quick actions menu button.


31-31: Updated destructuring to include new customClassName property.

The component now properly extracts the customClassName from props, making it available for use.


192-192: Applied customClassName to CustomMenu component.

The customClassName is now passed to the CustomMenu component as buttonClassName, allowing for custom styling of the menu button from parent components.

web/core/components/views/quick-actions.tsx (3)

25-25: Added new customClassName property for enhanced styling control.

The addition of this optional string property allows customization of the menu button styles, aligning with the PR's objective of header revamp.


29-29: Properly destructured the new customClassName prop.

The destructuring has been updated to include the new customClassName parameter, ensuring it's available for use within the component.


99-99: Successfully implemented custom styling for the menu button.

The customClassName prop is now properly passed to the CustomMenu component through buttonClassName, enabling flexible styling of the button element.

packages/ui/src/dropdowns/helper.tsx (2)

3-3: Imported standardized option type for dropdown components.

The import of ICustomSearchSelectOption from @plane/types aligns with the effort to standardize dropdown selection mechanisms across the application.


48-48: Simplified type definition using centralized type.

Replacing the inline type definition with the imported ICustomSearchSelectOption type improves code maintainability and ensures consistency across the application. This change is part of the broader standardization of selection components.

web/core/components/common/switcher-label.tsx (2)

1-11: Well-structured prop type definition for the new SwitcherLabel component.

The TSwitcherLabelProps type properly defines the component's interface with optional logo properties and a required icon component, providing flexibility for different use cases.


13-27: Created reusable label component for switcher implementations.

The SwitcherLabel component intelligently handles different logo scenarios and provides text truncation, which is essential for consistent header presentation across cycles, modules, pages, and views as mentioned in the PR objectives.

The component follows a clear hierarchy for rendering:

  1. Logo component (if logo_props.in_use is true)
  2. Image (if logo_url is provided)
  3. Default icon (always as fallback)
web/app/[workspaceSlug]/(projects)/projects/(detail)/[projectId]/modules/(detail)/header.tsx (5)

19-24: Updated imports to include necessary type for switcher options.

Added ICustomSearchSelectOption to the imports, enabling proper typing for the new dropdown selection mechanism.


26-26: Added CustomSearchSelect component import.

Imported CustomSearchSelect from "@plane/ui" to replace the previous menu implementation, enhancing the header with the new switcher functionality.


29-29: Added SwitcherLabel component to imports.

Imported the newly created SwitcherLabel component to provide consistent label presentation in the module switcher.


163-164: Renamed variable to reflect updated terminology.

Changed issuesCount to workItemsCount, reflecting the application's shift in terminology from "issues" to "work items".


165-180: Created structured options for the module switcher.

Well-implemented array of options for the module selector dropdown, with each option containing:

  • value: module ID
  • query: module name for searchability
  • content: React component with properly styled label

This implementation provides a consistent user experience for module selection.

web/app/[workspaceSlug]/(projects)/projects/(detail)/[projectId]/pages/(detail)/header.tsx (6)

3-10: The import modifications align with new header functionality.

The changes correctly add the necessary imports for the new header switcher functionality, including Link from next/link and the ICustomSearchSelectOption type.


21-21: Updated store imports support the new page switching mechanism.

The updated import correctly brings in the necessary hooks and types from the store.


29-29: Added projectId parameter extraction.

Good addition of projectId to the useParams hook to support the new project-specific page filtering functionality.


36-45: Enhanced store usage with SWR for efficient data fetching.

The implementation correctly uses SWR to fetch the pages list for the current project and keeps it updated. This is a good pattern for data fetching that ensures the component has the latest data.


47-62: Well-structured switcher options implementation.

The switcherOptions mapping creates a clean data structure for the dropdown selection, properly filtering out undefined options and casting to the correct type. This follows the ICustomSearchSelectOption type definition correctly.


98-107: Improved page selection with CustomSearchSelect.

The implementation replaces the previous menu component with CustomSearchSelect, providing a more consistent and user-friendly way to switch between pages. The component is properly configured with the necessary props.

web/app/[workspaceSlug]/(projects)/projects/(detail)/[projectId]/views/(detail)/[viewId]/header.tsx (5)

19-24: Type imports correctly support the new selection mechanism.

The ICustomSearchSelectOption type import supports the new dropdown selection functionality, consistent with the pattern used in other header components.


26-26: UI component imports updated for new header features.

The CustomSearchSelect component is now properly imported from @plane/ui for use in the view header.


150-165: Well-implemented view switcher options.

The switcherOptions implementation follows the same pattern as in the pages header, creating a consistent user experience across different sections of the application. The mapping logic is clean and correctly handles null/undefined cases.


185-190: Consistent switcher implementation in breadcrumb.

The CustomSearchSelect component is correctly implemented in the breadcrumb, using the same pattern as other headers for consistency across the application.


205-205: Header right item alignment improvement.

Added "items-center" class to ensure proper vertical alignment of the right header elements.

web/app/[workspaceSlug]/(projects)/projects/(detail)/[projectId]/cycles/(detail)/header.tsx (10)

3-3: Added useRef for parent reference.

The addition of useRef is appropriate for creating a DOM reference that can be passed to the CycleQuickActions component.


21-26: Proper type imports for the header modifications.

The ICustomSearchSelectOption import supports the new selection functionality, maintaining consistency with other header components.


28-28: Updated UI component imports.

The CustomSearchSelect component is correctly imported alongside other necessary UI components.


31-32: Added imports for common components.

The BreadcrumbLink and SwitcherLabel components are properly imported to support the new header functionality.


79-80: Added parentRef for CycleQuickActions.

The parentRef is correctly implemented using useRef, providing a reference to the DOM element for the CycleQuickActions component.


170-186: Well-structured cycle switcher options.

The switcherOptions implementation follows the same pattern as in other headers, providing a consistent user experience across different sections of the application.


187-188: Updated terminology from 'issues' to 'work items'.

Good change to use workItemsCount instead of issuesCount for better clarity and consistency with the application's terminology.


231-253: Improved cycle selection with CustomSearchSelect.

The implementation correctly uses CustomSearchSelect with proper configuration, including a count badge with tooltip for work items. The component follows the same pattern used in other headers.


328-329: Enhanced button styling for sidebar toggle.

The updated styling for the sidebar toggle button improves visual consistency with other header elements.


331-331: Improved icon styling using conditional classes.

Good use of the cn utility to conditionally apply styling to the PanelRight icon based on the sidebar state.

@henit-chobisa henit-chobisa changed the title [WEB-3759]chore: header revamp for cycles, modules, pages and views [WEB-3759] chore: header revamp for cycles, modules, pages and views Apr 7, 2025
@henit-chobisa henit-chobisa changed the title [WEB-3759] chore: header revamp for cycles, modules, pages and views [WEB-3759] chore: header revamp for cycles, modules, pages and views Apr 7, 2025
@henit-chobisa henit-chobisa changed the title [WEB-3759] chore: header revamp for cycles, modules, pages and views [WEB-3759] chore: header revamp for cycles, modules, pages and views Apr 7, 2025
@makeplane
Copy link

makeplane bot commented Apr 7, 2025

Pull Request Linked with Plane Work Items

Comment Automatically Generated by Plane

@vamsikrishnamathala vamsikrishnamathala marked this pull request as draft April 8, 2025 07:08
@pushya22 pushya22 marked this pull request as ready for review April 9, 2025 03:58
Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

♻️ Duplicate comments (1)
web/app/[workspaceSlug]/(projects)/projects/(detail)/[projectId]/pages/(detail)/header.tsx (1)

1-111: Consider moving the header component to layout level.

A previous review comment suggested "Move it to layout level." This might improve code organization and reusability across the application.

I notice there's a past review comment about moving this component to the layout level. Consider whether this refactoring should be part of the current PR or a separate task.

🧹 Nitpick comments (4)
web/app/[workspaceSlug]/(projects)/projects/(detail)/[projectId]/pages/(detail)/layout.tsx (1)

15-19: Consider adding error handling and loading states to SWR implementation.

The SWR implementation is good for fetching page data conditionally based on URL parameters. However, it could be improved by handling error states and loading indicators.

- useSWR(
-   workspaceSlug && projectId ? `PROJECT_PAGES_${projectId}` : null,
-   workspaceSlug && projectId ? () => fetchPagesList(workspaceSlug.toString(), projectId.toString()) : null
- );
+ const { error, isLoading } = useSWR(
+   workspaceSlug && projectId ? `PROJECT_PAGES_${projectId}` : null,
+   workspaceSlug && projectId ? () => fetchPagesList(workspaceSlug.toString(), projectId.toString()) : null
+ );
+ 
+ // Optional: Handle error state
+ React.useEffect(() => {
+   if (error) console.error("Failed to fetch pages:", error);
+ }, [error]);
web/app/[workspaceSlug]/(projects)/projects/(detail)/[projectId]/pages/(detail)/header.tsx (3)

39-39: Remove redundant null check.

There are two identical null checks for the page variable (lines 39 and 57). The second check is redundant since the function would already have returned if page is null at line 39.

-  if (!page) return null;
   const switcherOptions = projectPageIds
     .map((id) => {
       const _page = id === pageId ? page : getPageById(id);
       if (!_page) return;
       const pageLink = `/${workspaceSlug}/projects/${projectId}/pages/${_page.id}`;
       return {
         value: _page.id,
         query: _page.name,
         content: (
           <Link href={pageLink} className="flex gap-2 items-center justify-between">
             <SwitcherLabel logo_props={_page.logo_props} name={_page.name} LabelIcon={Layers} />
           </Link>
         ),
       };
     })
     .filter((option) => option !== undefined) as ICustomSearchSelectOption[];

-  if (!page) return null;

Also applies to: 57-57


92-100: Empty onChange handler in CustomSearchSelect may cause confusion.

The onChange handler for the CustomSearchSelect component is empty (() => {}). While navigation is handled through the Link components within each option's content, having an empty handler might be confusing for other developers. Consider adding a comment explaining why it's empty or implementing proper onChange behavior if necessary.

<CustomSearchSelect
  value={pageId}
  options={switcherOptions}
  label={<SwitcherLabel logo_props={page.logo_props} name={page.name} LabelIcon={Layers} />}
- onChange={() => {}}
+ onChange={() => {
+   // Navigation is handled by Link components within each option
+ }}
/>

37-37: Validate projectId before using it as a parameter.

The code directly uses projectId?.toString() without validating if it's undefined. While the optional chaining provides some safety, consider adding a more explicit check or fallback value to avoid potential issues.

- const projectPageIds = getCurrentProjectPageIds(projectId?.toString());
+ const projectPageIds = getCurrentProjectPageIds(projectId?.toString() || "");
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ad8d367 and 953c849.

📒 Files selected for processing (7)
  • web/app/[workspaceSlug]/(projects)/projects/(detail)/[projectId]/pages/(detail)/header.tsx (2 hunks)
  • web/app/[workspaceSlug]/(projects)/projects/(detail)/[projectId]/pages/(detail)/layout.tsx (1 hunks)
  • web/core/components/cycles/analytics-sidebar/sidebar-header.tsx (0 hunks)
  • web/core/components/cycles/quick-actions.tsx (2 hunks)
  • web/core/components/modules/analytics-sidebar/root.tsx (3 hunks)
  • web/core/components/modules/quick-actions.tsx (2 hunks)
  • web/core/components/views/quick-actions.tsx (2 hunks)
💤 Files with no reviewable changes (1)
  • web/core/components/cycles/analytics-sidebar/sidebar-header.tsx
🚧 Files skipped from review as they are similar to previous changes (4)
  • web/core/components/modules/quick-actions.tsx
  • web/core/components/cycles/quick-actions.tsx
  • web/core/components/views/quick-actions.tsx
  • web/core/components/modules/analytics-sidebar/root.tsx
🧰 Additional context used
🧬 Code Graph Analysis (2)
web/app/[workspaceSlug]/(projects)/projects/(detail)/[projectId]/pages/(detail)/layout.tsx (2)
web/ce/hooks/store/use-page-store.ts (1)
  • usePageStore (15-24)
web/core/store/router.store.ts (2)
  • workspaceSlug (69-71)
  • projectId (85-87)
web/app/[workspaceSlug]/(projects)/projects/(detail)/[projectId]/pages/(detail)/header.tsx (6)
web/ce/hooks/store/use-page.ts (1)
  • usePage (12-23)
web/ce/hooks/store/use-page-store.ts (1)
  • usePageStore (15-24)
web/core/store/router.store.ts (2)
  • projectId (85-87)
  • workspaceSlug (69-71)
web/core/components/common/switcher-label.tsx (1)
  • SwitcherLabel (13-27)
packages/types/src/common.d.ts (1)
  • ICustomSearchSelectOption (30-36)
packages/ui/src/dropdowns/custom-search-select.tsx (1)
  • CustomSearchSelect (14-218)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (5)
web/app/[workspaceSlug]/(projects)/projects/(detail)/[projectId]/pages/(detail)/layout.tsx (3)

4-5: Good addition of navigation and data fetching imports.

The imports of useParams and useSWR are appropriate for implementing the dynamic data fetching required in this component.


8-8: Good refactoring of import structure.

The import from @/plane-web/hooks/store now correctly includes the necessary EPageStoreType enum alongside the usePageStore hook.


13-14: Good implementation of parameter extraction and store access.

The component now correctly extracts the route parameters using useParams() and accesses the page store functionality through the usePageStore hook.

web/app/[workspaceSlug]/(projects)/projects/(detail)/[projectId]/pages/(detail)/header.tsx (2)

3-20: The imports have been updated to support the new page switcher functionality.

The changes in imports support the new page switcher functionality, adding necessary components like Link, CustomSearchSelect, and SwitcherLabel, as well as the required type ICustomSearchSelectOption.


40-55: Good implementation of the page switcher options.

The implementation effectively maps page IDs to selectable options with proper link navigation. The filtering of undefined values and type casting ensures type safety. This aligns well with the PR objective of adding a switcher for detail pages.

@sriramveeraghanta sriramveeraghanta merged commit 993c789 into preview Apr 9, 2025
4 of 5 checks passed
@sriramveeraghanta sriramveeraghanta deleted the chore-header-revamp branch April 9, 2025 09:27
lifeiscontent pushed a commit that referenced this pull request Aug 18, 2025
…6875)

* chore: header revamp for cycles, modules, pages and views

* chore: moved list fetch to layout level
@coderabbitai coderabbitai bot mentioned this pull request Sep 11, 2025
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants