Skip to content

Commit

Permalink
feat(search): add navlink
Browse files Browse the repository at this point in the history
  • Loading branch information
kahboom committed Nov 28, 2024
1 parent 292e874 commit 35f5dd7
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions client/src/app/pages/search/components/SearchMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export interface IEntity {
id: string;
title: string | null;
description?: string | null;
navLink: string;
type: string;
typeColor:
| "purple"
Expand Down Expand Up @@ -58,6 +59,7 @@ function useAllEntities() {
id: item.identifier,
title: item.identifier,
description: item.title,
navLink: `/advisories/${item.uuid}`,
type: "Advisory",
typeColor: "blue",
}));
Expand All @@ -66,6 +68,7 @@ function useAllEntities() {
id: item.uuid,
title: item.decomposedPurl ? item.decomposedPurl?.name : item.purl,
description: item.decomposedPurl?.namespace,
navLink: `/packages/${item.uuid}`,
type: "Package",
typeColor: "cyan",
}));
Expand All @@ -74,6 +77,7 @@ function useAllEntities() {
id: item.id,
title: item.name,
description: item.authors.join(", "),
navLink: `/sboms/${item.id}`,
type: "SBOM",
typeColor: "purple",
}));
Expand All @@ -82,8 +86,9 @@ function useAllEntities() {
(item) => ({
id: item.identifier,
title: item.identifier,
type: "CVE",
description: item.description,
navLink: `/vulnerabilities/${item.identifier}`,
type: "CVE",
typeColor: "orange",
})
);
Expand Down Expand Up @@ -112,7 +117,6 @@ export interface ISearchMenu {

export const SearchMenu: React.FC<ISearchMenu> = ({ onChangeSearch }) => {
const { list: entityList, defaultValue } = useAllEntities();
// console.table(entityList);

const [searchValue, setSearchValue] = React.useState<string | undefined>(
defaultValue
Expand Down Expand Up @@ -150,11 +154,12 @@ export const SearchMenu: React.FC<ISearchMenu> = ({ onChangeSearch }) => {
itemId={option.id}
key={option.id}
description={option.description}
to={option.navLink}
>
{option.title} <Label color={option.typeColor}>{option.type}</Label>
</MenuItem>
));
console.table(options);

if (options.length > 10) {
options = options.slice(0, 10);
} else {
Expand Down

0 comments on commit 35f5dd7

Please sign in to comment.