Skip to content

armgit / plane

Public Imported from GitHub
0

πŸ”₯πŸ”₯πŸ”₯ Open-source Jira, Linear, Monday, and ClickUp alternative. Plane is a modern project management platform to manage tasks, sprints, docs, and triage.

[WEB-1995] fix: searched page redirection from command palette. (#5170)

Prateek Shourya44a0ff5c672f
diff --git a/web/core/components/command-palette/actions/search-results.tsx b/web/core/components/command-palette/actions/search-results.tsx
index c0916f281d..dba61ecc36 100644
--- a/web/core/components/command-palette/actions/search-results.tsx
+++ b/web/core/components/command-palette/actions/search-results.tsx
@@ -1,6 +1,7 @@
"use client";
import { Command } from "cmdk";
+import { useParams } from "next/navigation";
// types
import { IWorkspaceSearchResults } from "@plane/types";
// helpers
@@ -15,8 +16,11 @@ type Props = {
export const CommandPaletteSearchResults: React.FC<Props> = (props) => {
const { closePalette, results } = props;
-
+ // router
const router = useAppRouter();
+ const { projectId: routerProjectId } = useParams();
+ // derived values
+ const projectId = routerProjectId?.toString();
return (
<>
@@ -32,7 +36,7 @@ export const CommandPaletteSearchResults: React.FC<Props> = (props) => {
key={item.id}
onSelect={() => {
closePalette();
- router.push(currentSection.path(item));
+ router.push(currentSection.path(item, projectId));
}}
value={`${key}-${item?.id}-${item.name}-${item.project__identifier ?? ""}-${item.sequence_id ?? ""}`}
className="focus:outline-none"
diff --git a/web/core/components/command-palette/helpers.tsx b/web/core/components/command-palette/helpers.tsx
index 2f41aa46d0..cc3e80bb7c 100644
--- a/web/core/components/command-palette/helpers.tsx
+++ b/web/core/components/command-palette/helpers.tsx
@@ -15,7 +15,7 @@ export const commandGroups: {
[key: string]: {
icon: JSX.Element;
itemName: (item: any) => React.ReactNode;
- path: (item: any) => string;
+ path: (item: any, projectId: string | undefined) => string;
title: string;
};
} = {
@@ -73,8 +73,11 @@ export const commandGroups: {
<span className="text-xs text-custom-text-300">{page.project__identifiers?.[0]}</span> {page.name}
</h6>
),
- path: (page: IWorkspaceDefaultSearchResult) =>
- `/${page?.workspace__slug}/projects/${page?.project_id}/pages/${page?.id}`,
+ path: (page: IWorkspacePageSearchResult, projectId: string | undefined) => {
+ let redirectProjectId = page?.project_ids?.[0];
+ if (!!projectId && page?.project_ids?.includes(projectId)) redirectProjectId = projectId;
+ return `/${page?.workspace__slug}/projects/${redirectProjectId}/pages/${page?.id}`;
+ },
title: "Pages",
},
project: {