[WEB-1995] fix: searched page redirection from command palette.#5170
[WEB-1995] fix: searched page redirection from command palette.#5170SatishGandham merged 2 commits intopreviewfrom
Conversation
WalkthroughThe recent updates enhance the Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant CommandPalette
participant PageHandler
User->>CommandPalette: Invoke command with page data
CommandPalette->>PageHandler: Call path(page: IWorkspacePageSearchResult, projectId)
PageHandler->>PageHandler: Retrieve project_ids
PageHandler->>CommandPalette: Return updated path
CommandPalette->>User: Display updated command results
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 as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- web/core/components/command-palette/helpers.tsx (1 hunks)
Additional comments not posted (1)
web/core/components/command-palette/helpers.tsx (1)
76-77: Ensureproject_idsarray is populated.The change to handle an array of project IDs is correct. However, it is important to ensure that the
project_idsarray is always populated to avoid potential errors.Consider adding a check to handle cases where the
project_idsarray might be empty or undefined.- `/${page?.workspace__slug}/projects/${page?.project_ids?.[0]}/pages/${page?.id}` + `/${page?.workspace__slug}/projects/${page?.project_ids?.length ? page.project_ids[0] : 'default_project_id'}/pages/${page?.id}`
| path: (page: IWorkspaceDefaultSearchResult) => | ||
| `/${page?.workspace__slug}/projects/${page?.project_id}/pages/${page?.id}`, | ||
| path: (page: IWorkspacePageSearchResult) => | ||
| `/${page?.workspace__slug}/projects/${page?.project_ids?.[0]}/pages/${page?.id}`, |
There was a problem hiding this comment.
If the use is already in a project, lets open that project level link.
There was a problem hiding this comment.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- web/core/components/command-palette/actions/search-results.tsx (3 hunks)
- web/core/components/command-palette/helpers.tsx (2 hunks)
Files skipped from review as they are similar to previous changes (1)
- web/core/components/command-palette/helpers.tsx
Additional comments not posted (4)
web/core/components/command-palette/actions/search-results.tsx (4)
4-4: LGTM! ImportinguseParamsis appropriate.The addition of
useParamsfromnext/navigationis necessary for accessing URL parameters.
19-21: LGTM! UsinguseAppRouteranduseParamsis appropriate.These hooks are necessary for obtaining the router instance and URL parameters, respectively.
23-23: LGTM! ConvertingrouterProjectIdto a string is appropriate.This ensures that
projectIdis in the correct format for use in the redirection logic.
39-39: LGTM! Updatingrouter.pushto includeprojectIdis appropriate.This change ensures that the redirection logic correctly handles multiple project IDs.
Problem
When attempting to visit a page from the command palette search results, an error displays: "Project doesn't exist."
Solution
This issue arose because the API response for page search results recently changed to return an array of project IDs instead of a single ID. However, the redirection logic has not been updated to handle this new format.
Media
Before
Screen.Recording.2024-07-19.at.12.16.56.PM.mov
After
Screen.Recording.2024-07-19.at.12.16.11.PM.mov
Issue link: WEB-1995
Summary by CodeRabbit
New Features
Bug Fixes