Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"use client";

import { Command } from "cmdk";
import { useParams } from "next/navigation";
// types
import { IWorkspaceSearchResults } from "@plane/types";
// helpers
Expand All @@ -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 (
<>
Expand All @@ -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"
Expand Down
9 changes: 6 additions & 3 deletions web/core/components/command-palette/helpers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
} = {
Expand Down Expand Up @@ -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: {
Expand Down