diff --git a/site/src/components/Filter/FilterCombobox/FilterCombobox.stories.tsx b/site/src/components/Filter/FilterCombobox/FilterCombobox.stories.tsx index 70a9217ff45..7059a57d39b 100644 --- a/site/src/components/Filter/FilterCombobox/FilterCombobox.stories.tsx +++ b/site/src/components/Filter/FilterCombobox/FilterCombobox.stories.tsx @@ -12,7 +12,7 @@ import { useState } from "react"; import { expect, userEvent, waitFor, within } from "storybook/test"; import { Avatar } from "#/components/Avatar/Avatar"; import { FilterCombobox } from "./FilterCombobox"; -import type { FilterCategory, FilterOption, SearchResult } from "./types"; +import type { FilterCategory, FilterOption } from "./types"; const meta: Meta = { title: "components/Filter/FilterCombobox", @@ -124,15 +124,9 @@ const chip = (token: string) => (_: string, element: Element | null) => const FilterComboboxHarness = ({ initialQuery = "owner:me", - getSearchResults, - onSearchResultSelect, - searchResultsLabel, categories: categoriesProp = categories, }: { initialQuery?: string; - getSearchResults?: (query: string) => Promise; - onSearchResultSelect?: (result: SearchResult) => void; - searchResultsLabel?: string; categories?: readonly FilterCategory[]; }) => { const [query, setQuery] = useState(initialQuery); @@ -144,9 +138,6 @@ const FilterComboboxHarness = ({ categories={categoriesProp} placeholder="Search and filter…" className="max-w-lg" - getSearchResults={getSearchResults} - onSearchResultSelect={onSearchResultSelect} - searchResultsLabel={searchResultsLabel} /> ); }; @@ -443,94 +434,6 @@ export const EnterCommitsHighlightedCategory: Story = { }, }; -export const LiveResourcePreviews: Story = { - render: () => ( - { - await new Promise((resolve) => { - window.setTimeout(resolve, 50); - }); - if (!query.toLowerCase().includes("dev")) { - return []; - } - return [ - { - value: "ws-1", - label: "devbox", - href: "/@alice/devbox", - }, - ]; - }} - /> - ), - play: async ({ canvasElement }) => { - const canvas = within(canvasElement); - const body = within(canvasElement.ownerDocument.body); - const input = canvas.getByRole("combobox", { - name: "Search and filter…", - }); - await userEvent.click(input); - await userEvent.type(input, "dev"); - await waitFor(() => - expect(body.getByRole("option", { name: /devbox/i })).toBeVisible(), - ); - await expect(body.getByText("Workspaces")).toBeVisible(); - }, -}; - -export const HidesStaleResourcePreviews: Story = { - render: () => ( - { - if (query === "dev") { - return [ - { - value: "ws-dev", - label: "devbox", - href: "/@alice/devbox", - }, - ]; - } - if (query === "prod") { - return [ - { - value: "ws-prod", - label: "prodbox", - href: "/@bob/prodbox", - }, - ]; - } - return []; - }} - /> - ), - play: async ({ canvasElement }) => { - const canvas = within(canvasElement); - const body = within(canvasElement.ownerDocument.body); - const input = canvas.getByRole("combobox", { - name: "Search and filter…", - }); - await userEvent.click(input); - await userEvent.type(input, "dev"); - await waitFor(() => - expect(body.getByRole("option", { name: /devbox/i })).toBeVisible(), - ); - await userEvent.clear(input); - await userEvent.type(input, "p"); - await expect( - body.queryByRole("option", { name: /devbox/i }), - ).not.toBeInTheDocument(); - await userEvent.type(input, "rod"); - await waitFor(() => - expect(body.getByRole("option", { name: /prodbox/i })).toBeVisible(), - ); - }, -}; - // Regression: chips must render in the order they were added, not in the // configured category order. Categories are status, template, owner; starting // from owner:me and adding template then status must keep the visible order @@ -622,6 +525,7 @@ export const CrossCategoryValueSuggestions: Story = { ).not.toBeInTheDocument(); await userEvent.click(body.getByRole("option", { name: /testuser01/i })); await expect(canvas.getByText(chip("owner:testuser01"))).toBeVisible(); + await expect(input).toHaveValue(""); }, }; @@ -811,44 +715,6 @@ export const TypeaheadErrorRetry: Story = { }, }; -// A failed workspace-preview lookup names the preview source, not suggestions, -// while the loaded suggestion rows stay visible. -export const PreviewErrorNamesPreview: Story = { - render: () => ( - , - getOptions: async (query) => - filterOptions([{ label: "alice", value: "alice" }], query), - }, - ]} - getSearchResults={async () => { - throw new Error("boom"); - }} - /> - ), - play: async ({ canvasElement }) => { - const canvas = within(canvasElement); - const body = within(canvasElement.ownerDocument.body); - const input = canvas.getByRole("combobox", { - name: "Search and filter…", - }); - await userEvent.click(input); - await userEvent.type(input, "alice"); - await expect( - await body.findByText(/Couldn.t load workspace previews/, { - ignore: '[role="status"], script, style', - }), - ).toBeVisible(); - await expect(body.getByRole("option", { name: /alice/i })).toBeVisible(); - }, -}; - // A category whose options resolve empty announces a category-aware empty state // rather than the browsing "No filters found." copy. export const CategoryEmptyState: Story = { diff --git a/site/src/components/Filter/FilterCombobox/FilterCombobox.tsx b/site/src/components/Filter/FilterCombobox/FilterCombobox.tsx index 5c599f9f874..7e4a393f1ea 100644 --- a/site/src/components/Filter/FilterCombobox/FilterCombobox.tsx +++ b/site/src/components/Filter/FilterCombobox/FilterCombobox.tsx @@ -1,6 +1,5 @@ import { CheckIcon, ListFilterIcon, SearchIcon } from "lucide-react"; import { useId } from "react"; -import { Avatar } from "#/components/Avatar/Avatar"; import { Badge } from "#/components/Badge/Badge"; import { Button } from "#/components/Button/Button"; import { ListFilterActiveIcon } from "#/components/Icons/ListFilterActiveIcon"; @@ -24,13 +23,16 @@ import { FilterComboboxRoot, FilterComboboxStatus, } from "./primitives"; -import type { FilterCategory, FilterOption, SearchResult } from "./types"; -import { useFilterCombobox } from "./useFilterCombobox"; +import type { FilterCategory, FilterOption } from "./types"; +import { + SUGGESTIONS_ERROR_MESSAGE, + useFilterCombobox, +} from "./useFilterCombobox"; /** * Unified workspace filter input: renders committed chips plus a cmdk-driven - * popup that browses categories, surfaces cross-category value suggestions, and - * (optionally) previews matching resources. State lives in `useFilterCombobox`. + * popup that browses categories and surfaces cross-category value suggestions. + * State lives in `useFilterCombobox`. */ type FilterComboboxProps = Readonly<{ value: string; @@ -43,10 +45,6 @@ type FilterComboboxProps = Readonly<{ * query). When set, the input is marked invalid and linked to the message. */ errorMessage?: string; - /** Debounced free-text resource previews (e.g. matching workspaces). */ - getSearchResults?: (query: string) => Promise; - onSearchResultSelect?: (result: SearchResult) => void; - searchResultsLabel?: string; }>; export function FilterCombobox({ @@ -56,9 +54,6 @@ export function FilterCombobox({ placeholder = "Search and filter…", className, errorMessage, - getSearchResults, - onSearchResultSelect, - searchResultsLabel = "Results", }: FilterComboboxProps) { const { open, @@ -73,7 +68,6 @@ export function FilterCombobox({ listedCategories, categoryPreviews, valueSuggestions, - searchResults, chipValues, typeahead, actions, @@ -81,8 +75,6 @@ export function FilterCombobox({ value, onChange, categories, - getSearchResults, - onSearchResultSelect, }); const { setInputRef } = actions; @@ -196,15 +188,10 @@ export function FilterCombobox({ listedCategories={listedCategories} categoryPreviews={categoryPreviews} valueSuggestions={valueSuggestions} - searchResults={searchResults} - searchResultsLabel={searchResultsLabel} - showSearchSection={typeahead.showSearchResults} typeaheadLoading={typeahead.loading} typeaheadError={typeahead.error} - typeaheadErrorLabel={typeahead.errorLabel} onSelectCategory={actions.selectCategory} onSelectSuggestion={actions.selectValueSuggestion} - onSelectSearchResult={actions.selectSearchResult} onRetry={actions.retryTypeahead} /> ) : ( @@ -299,20 +286,6 @@ function CategoryPreviewText({ ); } -function ResultIcon({ result }: { result: SearchResult }): React.ReactNode { - if (result.startIcon) { - return {result.startIcon}; - } - if (result.imageUrl !== undefined) { - return ( - - - - ); - } - return null; -} - type ValueSuggestion = { categoryLabel: string; token: string; @@ -323,15 +296,10 @@ type TypeaheadListProps = Readonly<{ listedCategories: readonly FilterCategory[]; categoryPreviews: ReadonlyMap; valueSuggestions: readonly ValueSuggestion[]; - searchResults: readonly SearchResult[]; - searchResultsLabel: string; - showSearchSection: boolean; typeaheadLoading: boolean; typeaheadError: boolean; - typeaheadErrorLabel: string; onSelectCategory: (categoryKey: string) => void; onSelectSuggestion: (token: string) => void; - onSelectSearchResult: (result: SearchResult) => void; onRetry: () => void; }>; @@ -339,15 +307,10 @@ function TypeaheadList({ listedCategories, categoryPreviews, valueSuggestions, - searchResults, - searchResultsLabel, - showSearchSection, typeaheadLoading, typeaheadError, - typeaheadErrorLabel, onSelectCategory, onSelectSuggestion, - onSelectSearchResult, onRetry, }: TypeaheadListProps) { const valueSuggestionsByCategory = new Map(); @@ -365,7 +328,6 @@ function TypeaheadList({ const isEmpty = listedCategories.length === 0 && valueSuggestions.length === 0 && - !showSearchSection && !typeaheadLoading && !typeaheadError; @@ -405,22 +367,6 @@ function TypeaheadList({ ), )} - {showSearchSection && ( - - {searchResultsLabel} - {searchResults.map((result) => ( - onSelectSearchResult(result)} - > - - {result.label} - - ))} - - )} {typeaheadLoading && (
@@ -428,7 +374,7 @@ function TypeaheadList({ )} {typeaheadError && !typeaheadLoading && (
- {typeaheadErrorLabel} + {SUGGESTIONS_ERROR_MESSAGE} diff --git a/site/src/components/Filter/FilterCombobox/primitives.tsx b/site/src/components/Filter/FilterCombobox/primitives.tsx index f5d8a1a0de5..71dcac5be0c 100644 --- a/site/src/components/Filter/FilterCombobox/primitives.tsx +++ b/site/src/components/Filter/FilterCombobox/primitives.tsx @@ -187,9 +187,8 @@ type FilterComboboxItemProps = React.ComponentProps< >; /** - * A dropdown row. Rows are actions, not toggles: pass `onSelect` to run the - * row's behavior (open a category, add a chip, navigate to a result). cmdk - * calls `onSelect` on click and on Enter for the highlighted row. + * A dropdown row. Rows are actions, not toggles: cmdk calls `onSelect` on + * click and on Enter for the highlighted row. */ export const FilterComboboxItem: React.FC = ({ className, diff --git a/site/src/components/Filter/FilterCombobox/queries.ts b/site/src/components/Filter/FilterCombobox/queries.ts index db16cb9ac7a..9dff8a91a1e 100644 --- a/site/src/components/Filter/FilterCombobox/queries.ts +++ b/site/src/components/Filter/FilterCombobox/queries.ts @@ -1,12 +1,9 @@ import type { UseQueryOptions } from "react-query"; -import type { FilterOption, SearchResult } from "./types"; +import type { FilterOption } from "./types"; const filterComboboxOptionsKey = (categoryKey: string, query: string) => ["filterCombobox", "options", categoryKey, query] as const; -const filterComboboxSearchResultsKey = (query: string) => - ["filterCombobox", "searchResults", query] as const; - /** * react-query options for one category's options at `query`. `getOptions` is * optional so an active-category key that no longer resolves to a category @@ -25,17 +22,3 @@ export const filterComboboxOptions = ( enabled, } satisfies UseQueryOptions; }; - -/** react-query options for the free-text resource preview at `query`. */ -export const filterComboboxSearchResults = ( - getSearchResults: ((query: string) => Promise) | undefined, - query: string, - enabled: boolean, -) => { - return { - queryKey: filterComboboxSearchResultsKey(query), - queryFn: async (): Promise => - getSearchResults ? getSearchResults(query) : [], - enabled, - } satisfies UseQueryOptions; -}; diff --git a/site/src/components/Filter/FilterCombobox/types.ts b/site/src/components/Filter/FilterCombobox/types.ts index fd182fd8c10..a8e1634a1f5 100644 --- a/site/src/components/Filter/FilterCombobox/types.ts +++ b/site/src/components/Filter/FilterCombobox/types.ts @@ -31,14 +31,3 @@ export type FilterCategory = { */ chipKeys?: readonly string[]; }; - -/** Live resource preview row shown while typing free-text search. */ -export type SearchResult = { - label: string; - value: string; - startIcon?: React.ReactNode; - /** Renders an avatar when `startIcon` is not provided. */ - imageUrl?: string; - /** Opaque payload for `onSearchResultSelect`, e.g. a workspace URL path. */ - href?: string; -}; diff --git a/site/src/components/Filter/FilterCombobox/useFilterCombobox.ts b/site/src/components/Filter/FilterCombobox/useFilterCombobox.ts index 15d522df2e1..acf4bc68a12 100644 --- a/site/src/components/Filter/FilterCombobox/useFilterCombobox.ts +++ b/site/src/components/Filter/FilterCombobox/useFilterCombobox.ts @@ -14,8 +14,8 @@ import { parseTypedCategoryPrefix, queryToChips, } from "./filterQuery"; -import { filterComboboxOptions, filterComboboxSearchResults } from "./queries"; -import type { FilterCategory, FilterOption, SearchResult } from "./types"; +import { filterComboboxOptions } from "./queries"; +import type { FilterCategory, FilterOption } from "./types"; const SEARCH_DEBOUNCE_MS = 300; @@ -45,22 +45,14 @@ type Action = | { type: "typeFreeText"; value: string } | { type: "setCommittedFreeText"; value: string } | { type: "leaveCategory" } - | { type: "close"; input: "restore" | "clear" | "keep" } + | { type: "close" } | { type: "reconcile"; freeText: string }; -const closeState = ( - state: State, - input: "restore" | "clear" | "keep", -): State => ({ +const closeState = (state: State): State => ({ mode: "closed", activeCategoryKey: null, committedFreeText: state.committedFreeText, - inputValue: - input === "restore" - ? state.committedFreeText - : input === "clear" - ? "" - : state.inputValue, + inputValue: state.committedFreeText, }); const reducer = (state: State, action: Action): State => { @@ -93,7 +85,7 @@ const reducer = (state: State, action: Action): State => { inputValue: state.committedFreeText, }; case "close": - return closeState(state, action.input); + return closeState(state); case "reconcile": return { ...state, @@ -112,10 +104,12 @@ type StatusMessageInput = { activeOptionsError: boolean; activeOptionsEmpty: boolean; typeaheadError: boolean; - typeaheadErrorLabel: string; typeaheadEmpty: boolean; }; +/** Shown and announced when the typeahead suggestion queries fail. */ +export const SUGGESTIONS_ERROR_MESSAGE = "Couldn't load suggestions."; + // Live-region text for each terminal state so screen readers hear loading, // failures, and empty results rather than silence. Typeahead loading is voiced // by the standalone instead, to avoid a duplicate announcement. @@ -125,7 +119,6 @@ const deriveStatusMessage = ({ activeOptionsError, activeOptionsEmpty, typeaheadError, - typeaheadErrorLabel, typeaheadEmpty, }: StatusMessageInput): string => { if (activeCategoryLabel !== undefined) { @@ -141,7 +134,7 @@ const deriveStatusMessage = ({ return `Filtering by ${activeCategoryLabel}`; } if (typeaheadError) { - return typeaheadErrorLabel; + return SUGGESTIONS_ERROR_MESSAGE; } if (typeaheadEmpty) { return "No filters found"; @@ -153,14 +146,12 @@ type UseFilterComboboxOptions = { value: string; onChange: (query: string) => void; categories: readonly FilterCategory[]; - getSearchResults?: (query: string) => Promise; - onSearchResultSelect?: (result: SearchResult) => void; }; /** * Drives the unified workspace filter combobox: a `mode` state machine for the * popup, debounced query emission back to the caller, and the react-query - * lookups for category options, cross-category suggestions, and search results. + * lookups for category options and cross-category suggestions. * Local state is reconciled against the caller-owned `value` so an external * update wins over any in-flight local edit. */ @@ -168,8 +159,6 @@ export const useFilterCombobox = ({ value, onChange, categories, - getSearchResults, - onSearchResultSelect, }: UseFilterComboboxOptions) => { const chipKeys = useMemo( () => categories.flatMap((category) => category.chipKeys ?? [category.key]), @@ -193,7 +182,6 @@ export const useFilterCombobox = ({ const prevChipKeysRef = useRef(chipKeys); const highlightedItemRef = useRef(null); const inputRef = useRef(null); - const hasSearchResultsLoader = Boolean(getSearchResults); const { debounced: debouncedOnChange, cancelDebounce } = useDebouncedFunction( (query: string) => { @@ -375,72 +363,26 @@ export const useFilterCombobox = ({ chipValues, ); - // A rejected suggestion query must not leave the popup spinning forever; - // treat an error as "done loading" and surface it instead. - const suggestionsError = + const typeaheadError = activeCategoryKey === null && isBrowsing && suggestionOptions.isError; - const valueSuggestionsLoading = - activeCategoryKey === null && - isBrowsing && - inputValue.trim().length > 0 && - !suggestionsError && - (typeaheadQueryPending || suggestionOptions.isFetching); - - const searchResultsQuery = useQuery( - filterComboboxSearchResults( - getSearchResults, - debouncedTypeaheadQuery, - hasSearchResultsLoader && - debouncedTypeaheadQuery.length > 0 && - activeCategoryKey === null && - isBrowsing, - ), - ); - - const searchResults = typeaheadQueryPending - ? [] - : (searchResultsQuery.data ?? []); - const searchResultsLoading = - (hasSearchResultsLoader && typeaheadQueryPending) || - (searchResultsQuery.isFetching && !searchResultsQuery.isError); - const previewError = - activeCategoryKey === null && - isBrowsing && - hasSearchResultsLoader && - searchResultsQuery.isError; - const typeaheadError = suggestionsError || previewError; const typeaheadActive = activeCategoryKey === null && isBrowsing; const hasTypeaheadQuery = typeaheadActive && inputValue.trim().length > 0; - const showSearchResults = hasTypeaheadQuery && searchResults.length > 0; - // Spin while either source is still fetching without rows for its own - // section, so an in-flight query never leaves an empty gap. The other - // section's rows keep rendering above the spinner. + // Spin while suggestions are still fetching without rows, so an in-flight + // query never leaves an empty gap. A failed category query shows the error + // and Retry even while other category queries are still fetching. const typeaheadLoading = hasTypeaheadQuery && - ((valueSuggestionsLoading && valueSuggestions.length === 0) || - (hasSearchResultsLoader && - searchResultsLoading && - searchResults.length === 0)); + !typeaheadError && + (typeaheadQueryPending || suggestionOptions.isFetching) && + valueSuggestions.length === 0; const typeaheadEmpty = hasTypeaheadQuery && !typeaheadLoading && !typeaheadError && listedCategories.length === 0 && - valueSuggestions.length === 0 && - searchResults.length === 0; - - // Name the failing source so the copy points at the right endpoint instead - // of blaming suggestions for a preview outage. - const typeaheadErrorLabel = - suggestionsError && previewError - ? "Couldn't load results." - : previewError - ? "Couldn't load workspace previews." - : suggestionsError - ? "Couldn't load suggestions." - : ""; + valueSuggestions.length === 0; const activeOptionsEmpty = activeCategoryKey !== null && @@ -457,15 +399,11 @@ export const useFilterCombobox = ({ activeOptionsError, activeOptionsEmpty, typeaheadError, - typeaheadErrorLabel, typeaheadEmpty, }); - // Refetch both typeahead sources so one retry covers a failed suggestion - // lookup and a failed workspace preview. const retryTypeahead = () => { suggestionOptions.refetch(); - void searchResultsQuery.refetch(); }; const updateFromChips = (tokens: string[], freeText?: string) => { @@ -488,19 +426,14 @@ export const useFilterCombobox = ({ const selectValueSuggestion = (token: string) => { updateFromChips([...chipValues, token], ""); - dispatch({ type: "close", input: "clear" }); + dispatch({ type: "close" }); }; // In category mode, choosing an option commits its chip while preserving the // free-text name search that preceded the category prefix. const selectCategoryOption = (token: string) => { updateFromChips([...chipValues, token]); - dispatch({ type: "close", input: "restore" }); - }; - - const selectSearchResult = (result: SearchResult) => { - onSearchResultSelect?.(result); - dispatch({ type: "close", input: "keep" }); + dispatch({ type: "close" }); }; // From inside a category the toggle steps back to the category list rather @@ -511,7 +444,7 @@ export const useFilterCombobox = ({ return; } if (open) { - dispatch({ type: "close", input: "restore" }); + dispatch({ type: "close" }); return; } dispatch({ type: "openBrowsing" }); @@ -590,7 +523,7 @@ export const useFilterCombobox = ({ // Radix only originates close requests (escape / outside press); opens flow // from the caller, so a dismissal simply restores the free-text input. const handleDismiss = () => { - dispatch({ type: "close", input: "restore" }); + dispatch({ type: "close" }); }; // Chip removal mirrors Backspace: drop the token and keep the current popup @@ -647,9 +580,8 @@ export const useFilterCombobox = ({ } } - // Tab completes the highlighted filter only. A highlighted resource - // preview has no chip token, so Tab falls through to the default focus - // move rather than navigating. + // Tab completes the highlighted category or value suggestion and + // otherwise moves focus. const isTabComplete = event.key === "Tab" && !event.shiftKey; if (!isTabComplete || mode !== "browsing") { return; @@ -688,7 +620,6 @@ export const useFilterCombobox = ({ listedCategories, categoryPreviews, valueSuggestions, - searchResults, chipValues, // Derived typeahead view-model, so the view renders flags instead of // recomputing loading/visibility from raw query state. @@ -696,8 +627,6 @@ export const useFilterCombobox = ({ active: typeaheadActive, loading: typeaheadLoading, error: typeaheadError, - errorLabel: typeaheadErrorLabel, - showSearchResults, }, actions: { setInputRef: (node: HTMLInputElement | null) => { @@ -711,7 +640,6 @@ export const useFilterCombobox = ({ selectCategory, selectCategoryOption, selectValueSuggestion, - selectSearchResult, onInputFocus: handleInputFocus, onInputKeyDown: handleInputKeyDown, onInputValueChange: handleInputValueChange, diff --git a/site/src/pages/WorkspacesPage/filter/WorkspacesFilter.tsx b/site/src/pages/WorkspacesPage/filter/WorkspacesFilter.tsx index 94ba89617b7..44915345700 100644 --- a/site/src/pages/WorkspacesPage/filter/WorkspacesFilter.tsx +++ b/site/src/pages/WorkspacesPage/filter/WorkspacesFilter.tsx @@ -6,21 +6,16 @@ import { UserIcon, UserKeyIcon, } from "lucide-react"; -import { useCallback, useMemo } from "react"; +import { useMemo } from "react"; import { useQueryClient } from "react-query"; -import { useNavigate } from "react-router"; import { getValidationErrorMessage, hasError, isApiValidationError, } from "#/api/errors"; -import { workspaces } from "#/api/queries/workspaces"; import type { UseFilterResult } from "#/components/Filter/Filter"; import { FilterCombobox } from "#/components/Filter/FilterCombobox/FilterCombobox"; -import type { - FilterCategory, - SearchResult, -} from "#/components/Filter/FilterCombobox/types"; +import type { FilterCategory } from "#/components/Filter/FilterCombobox/types"; import { useAuthenticated } from "#/hooks/useAuthenticated"; import { useDashboard } from "#/modules/dashboard/useDashboard"; import { @@ -33,8 +28,6 @@ import { getUserFilterOptions, } from "./categoryOptions"; -const WORKSPACE_PREVIEW_LIMIT = 5; - type WorkspaceFilterProps = Readonly<{ filter: UseFilterResult; error: unknown; @@ -54,7 +47,6 @@ export const WorkspacesFilter: React.FC = ({ const canFilterDormant = entitlements.features.advanced_template_scheduling.enabled; const queryClient = useQueryClient(); - const navigate = useNavigate(); const categories = useMemo(() => { // Always expose User and Owner so both stay recognized chip keys and the @@ -116,35 +108,6 @@ export const WorkspacesFilter: React.FC = ({ return next; }, [canListUsers, canFilterDormant, me, showOrganizations, queryClient]); - const getSearchResults = useCallback( - async (query: string): Promise => { - const response = await queryClient.fetchQuery( - workspaces({ - q: query, - limit: WORKSPACE_PREVIEW_LIMIT, - offset: 0, - }), - ); - - return response.workspaces.map((workspace) => ({ - value: workspace.id, - label: workspace.name, - imageUrl: workspace.owner_avatar_url, - href: `/@${workspace.owner_name}/${workspace.name}`, - })); - }, - [queryClient], - ); - - const onSearchResultSelect = useCallback( - (result: SearchResult) => { - if (result.href) { - navigate(result.href); - } - }, - [navigate], - ); - // The page hides its ErrorAlert for API validation errors, so the filter // owns surfacing the actionable "invalid query" message. const showValidationError = hasError(error) && isApiValidationError(error); @@ -161,9 +124,6 @@ export const WorkspacesFilter: React.FC = ({ errorMessage={ showValidationError ? getValidationErrorMessage(error) : undefined } - getSearchResults={getSearchResults} - onSearchResultSelect={onSearchResultSelect} - searchResultsLabel="Jump to workspace" />
);