From 9fdb8b7419d7d293481a54d731742958bd802c76 Mon Sep 17 00:00:00 2001 From: Carlos Feria Date: Thu, 2 Jul 2026 19:47:26 +0200 Subject: [PATCH] fix: sbom Search by name instead of full search (#1134) Signed-off-by: Carlos Feria <2582866+carlosthe19916@users.noreply.github.com> (cherry picked from commit 2e45be37c561d10f0506935e82f48654f8fff974) --- client/src/app/pages/sbom-list/sbom-context.ts | 2 +- client/src/app/pages/sbom-list/sbom-provider.tsx | 2 +- client/src/app/pages/search/components/SearchMenu.tsx | 10 +++++++--- client/src/app/pages/search/components/SearchTabs.tsx | 4 ++-- client/src/app/pages/search/search.tsx | 2 +- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/client/src/app/pages/sbom-list/sbom-context.ts b/client/src/app/pages/sbom-list/sbom-context.ts index 030101eb4..0cdd078e3 100644 --- a/client/src/app/pages/sbom-list/sbom-context.ts +++ b/client/src/app/pages/sbom-list/sbom-context.ts @@ -25,7 +25,7 @@ interface ISbomSearchContext { | "labels" | "vulnerabilities", "name" | "published", - "" | "published" | "labels" | "license", + "name" | "published" | "labels" | "license", string >; diff --git a/client/src/app/pages/sbom-list/sbom-provider.tsx b/client/src/app/pages/sbom-list/sbom-provider.tsx index c98d0d8fc..14fbb1f0c 100644 --- a/client/src/app/pages/sbom-list/sbom-provider.tsx +++ b/client/src/app/pages/sbom-list/sbom-provider.tsx @@ -72,7 +72,7 @@ export const SbomSearchProvider: React.FunctionComponent = ({ isFilterEnabled: true, filterCategories: [ { - categoryKey: FILTER_TEXT_CATEGORY_KEY, + categoryKey: "name", title: "Filter text", placeholderText: "Search", type: FilterType.search, diff --git a/client/src/app/pages/search/components/SearchMenu.tsx b/client/src/app/pages/search/components/SearchMenu.tsx index 16ed06516..aeec3a140 100644 --- a/client/src/app/pages/search/components/SearchMenu.tsx +++ b/client/src/app/pages/search/components/SearchMenu.tsx @@ -63,6 +63,11 @@ function useAllEntities(filterText: string, disableSearch: boolean) { page: { pageNumber: 1, itemsPerPage: 5 }, }; + const sbomParams: HubRequestParams = { + filters: [{ field: "name", operator: "~", value: filterText }], + page: { pageNumber: 1, itemsPerPage: 5 }, + }; + const { isFetching: isFetchingAdvisories, result: { data: advisories }, @@ -76,7 +81,7 @@ function useAllEntities(filterText: string, disableSearch: boolean) { const { isFetching: isFetchingSBOMs, result: { data: sboms }, - } = useFetchSBOMs(null, { ...params }, [], disableSearch); + } = useFetchSBOMs(null, { ...sbomParams }, [], disableSearch); const { isFetching: isFetchingVulnerabilities, @@ -170,8 +175,7 @@ export const SearchMenu: React.FC = ({ onChangeSearch }) => { // (no useMemo in the useUrlParams → useFilterState → context chain), but the // extracted string only changes when the URL filter param actually changes. const appliedSearchValue = - sbomTableControls.filterState.filterValues[FILTER_TEXT_CATEGORY_KEY]?.[0] ?? - ""; + sbomTableControls.filterState.filterValues["name"]?.[0] ?? ""; const [searchValue, setSearchValue] = React.useState(""); const [isSearchValueDirty, setIsSearchValueDirty] = React.useState(false); diff --git a/client/src/app/pages/search/components/SearchTabs.tsx b/client/src/app/pages/search/components/SearchTabs.tsx index da767a08e..a45f34830 100644 --- a/client/src/app/pages/search/components/SearchTabs.tsx +++ b/client/src/app/pages/search/components/SearchTabs.tsx @@ -48,7 +48,7 @@ export interface SearchTabsProps { >; sbomFilterPanelProps: IFilterPanelProps< SbomSummary, - "" | "published" | "labels" | "license" + "name" | "published" | "labels" | "license" >; vulnerabilityFilterPanelProps: IFilterPanelProps< VulnerabilitySummary, @@ -117,7 +117,7 @@ export const SearchTabs: React.FC = ({ {isTabActive("sboms") ? ( ) : isTabActive("packages") ? ( diff --git a/client/src/app/pages/search/search.tsx b/client/src/app/pages/search/search.tsx index 8597d60e8..79f617e86 100644 --- a/client/src/app/pages/search/search.tsx +++ b/client/src/app/pages/search/search.tsx @@ -92,7 +92,7 @@ export const Search: React.FC = ({ searchBodyOverride }) => { if (searchValue === undefined) return; sbomTableControls.filterState.setFilterValues({ ...sbomTableControls.filterState.filterValues, - [FILTER_TEXT_CATEGORY_KEY]: [searchValue], + ["name"]: [searchValue], }); packageTableControls.filterState.setFilterValues({ ...packageTableControls.filterState.filterValues,