π₯π₯π₯ Open-source Jira, Linear, Monday, and ClickUp alternative. Plane is a modern project management platform to manage tasks, sprints, docs, and triage.
TypeScript boardsbug-trackerdjangodockerganttissue-trackerjirajira-alternativekanbanlinearpostgresqlproduct-managementproject-managementproject-planningpythonreactredistypesciptvitework-management
improvement: command palette search results (#6761)
Prateek Shourya1bf683e044a6
diff --git a/packages/constants/src/workspace.ts b/packages/constants/src/workspace.tsindex d1389759c3..cddc1a56ce 100644--- a/packages/constants/src/workspace.ts+++ b/packages/constants/src/workspace.ts@@ -1,4 +1,4 @@-import { TStaticViewTypes } from "@plane/types";+import { TStaticViewTypes, IWorkspaceSearchResults } from "@plane/types";import { EUserWorkspaceRoles } from "./user";export const ORGANIZATION_SIZE = [@@ -324,3 +324,15 @@ export const WORKSPACE_SIDEBAR_STATIC_NAVIGATION_ITEMS_LINKS: IWorkspaceSidebarNWORKSPACE_SIDEBAR_STATIC_NAVIGATION_ITEMS["inbox"],WORKSPACE_SIDEBAR_STATIC_NAVIGATION_ITEMS["projects"],];++export const WORKSPACE_DEFAULT_SEARCH_RESULT: IWorkspaceSearchResults = {+ results: {+ workspace: [],+ project: [],+ issue: [],+ cycle: [],+ module: [],+ issue_view: [],+ page: [],+ },+};diff --git a/web/core/components/command-palette/helpers.tsx b/web/ce/components/command-palette/helpers.tsxsimilarity index 97%rename from web/core/components/command-palette/helpers.tsxrename to web/ce/components/command-palette/helpers.tsxindex 05885ebbd1..d846ebfa06 100644--- a/web/core/components/command-palette/helpers.tsx+++ b/web/ce/components/command-palette/helpers.tsx@@ -16,14 +16,16 @@ import { generateWorkItemLink } from "@/helpers/issue.helper";// plane web componentsimport { IssueIdentifier } from "@/plane-web/components/issues";-export const commandGroups: {+export type TCommandGroups = {[key: string]: {icon: JSX.Element | null;itemName: (item: any) => React.ReactNode;path: (item: any, projectId: string | undefined) => string;title: string;};-} = {+};++export const commandGroups: TCommandGroups = {cycle: {icon: <ContrastIcon className="h-3 w-3" />,itemName: (cycle: IWorkspaceDefaultSearchResult) => (diff --git a/web/ce/components/command-palette/index.ts b/web/ce/components/command-palette/index.tsnew file mode 100644index 0000000000..62404249d7--- /dev/null+++ b/web/ce/components/command-palette/index.ts@@ -0,0 +1,3 @@+export * from "./actions";+export * from "./modals";+export * from "./helpers";diff --git a/web/core/components/command-palette/actions/search-results.tsx b/web/core/components/command-palette/actions/search-results.tsxindex 8d67635ba9..18a8a75beb 100644--- a/web/core/components/command-palette/actions/search-results.tsx+++ b/web/core/components/command-palette/actions/search-results.tsx@@ -2,12 +2,12 @@import { Command } from "cmdk";import { useParams } from "next/navigation";-// types+// plane importsimport { IWorkspaceSearchResults } from "@plane/types";-// helpers-import { commandGroups } from "@/components/command-palette";// hooksimport { useAppRouter } from "@/hooks/use-app-router";+// plane web imports+import { commandGroups } from "@/plane-web/components/command-palette";type Props = {closePalette: () => void;@@ -25,9 +25,9 @@ export const CommandPaletteSearchResults: React.FC<Props> = (props) => {return (<>{Object.keys(results.results).map((key) => {+ // TODO: add type for resultsconst section = (results.results as any)[key];const currentSection = commandGroups[key];-if (!currentSection) return null;if (section.length > 0) {return (diff --git a/web/core/components/command-palette/command-modal.tsx b/web/core/components/command-palette/command-modal.tsxindex 7fdc96f5a7..5cc0805041 100644--- a/web/core/components/command-palette/command-modal.tsx+++ b/web/core/components/command-palette/command-modal.tsx@@ -8,7 +8,7 @@ import useSWR from "swr";import { CommandIcon, FolderPlus, Search, Settings, X } from "lucide-react";import { Dialog, Transition } from "@headlessui/react";// plane imports-import { EUserPermissions, EUserPermissionsLevel } from "@plane/constants";+import { EUserPermissions, EUserPermissionsLevel, WORKSPACE_DEFAULT_SEARCH_RESULT } from "@plane/constants";import { useTranslation } from "@plane/i18n";import { IWorkspaceSearchResults } from "@plane/types";import { LayersIcon, Loader, ToggleSwitch } from "@plane/ui";@@ -58,9 +58,7 @@ export const CommandModal: React.FC = observer(() => {const [isLoading, setIsLoading] = useState(false);const [isSearching, setIsSearching] = useState(false);const [searchTerm, setSearchTerm] = useState("");- const [results, setResults] = useState<IWorkspaceSearchResults>({- results: { workspace: [], project: [], issue: [], cycle: [], module: [], issue_view: [], page: [] },- });+ const [results, setResults] = useState<IWorkspaceSearchResults>(WORKSPACE_DEFAULT_SEARCH_RESULT);const [isWorkspaceLevel, setIsWorkspaceLevel] = useState(false);const [pages, setPages] = useState<string[]>([]);const [searchInIssue, setSearchInIssue] = useState(false);@@ -151,9 +149,7 @@ export const CommandModal: React.FC = observer(() => {setIsSearching(false);});} else {- setResults({- results: { workspace: [], project: [], issue: [], cycle: [], module: [], issue_view: [], page: [] },- });+ setResults(WORKSPACE_DEFAULT_SEARCH_RESULT);setIsLoading(false);setIsSearching(false);}diff --git a/web/core/components/command-palette/index.ts b/web/core/components/command-palette/index.tsindex 0d2e042a7f..5aee700af3 100644--- a/web/core/components/command-palette/index.ts+++ b/web/core/components/command-palette/index.ts@@ -2,4 +2,3 @@ export * from "./actions";export * from "./shortcuts-modal";export * from "./command-modal";export * from "./command-palette";-export * from "./helpers";