Skip to content

Commit d1d05e7

Browse files
feat: Add Certificates Tab to the Trust Root Page (#8)
Signed-off-by: Carlos Feria <[email protected]>
1 parent f1ad1a1 commit d1d05e7

30 files changed

+1516
-6
lines changed

client/src/app/components/StateError.tsx renamed to client/src/app/components/ErrorEmptyState.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type React from "react";
33
import { EmptyState, EmptyStateBody, EmptyStateVariant } from "@patternfly/react-core";
44
import ExclamationCircleIcon from "@patternfly/react-icons/dist/esm/icons/exclamation-circle-icon";
55

6-
export const StateError: React.FC = () => {
6+
export const ErrorEmptyState: React.FC = () => {
77
return (
88
<EmptyState
99
status="danger"
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import type { FilterValue } from "@app/hooks/TableControls/filtering/types";
2+
3+
export interface IFilterControlProps<TFilterCategoryKey extends string> {
4+
categoryKey: TFilterCategoryKey;
5+
categoryName: string;
6+
filterValue: FilterValue;
7+
setFilterValue: (newValue: FilterValue) => void;
8+
showToolbarItem?: boolean;
9+
isDisabled?: boolean;
10+
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
import React from "react";
2+
3+
import { Dropdown, DropdownItem, MenuToggle, ToolbarItem, ToolbarToggleGroup } from "@patternfly/react-core";
4+
import { FilterIcon } from "@patternfly/react-icons";
5+
6+
import type { IFilterCategory } from "@app/hooks/TableControls/filtering/types";
7+
8+
export interface IFilterToolbarProps<TItem, TFilterCategoryKey extends string> {
9+
currentFilterCategoryKey?: TFilterCategoryKey;
10+
setCurrentFilterCategoryKey: (value: TFilterCategoryKey) => void;
11+
categoryTitles: Record<TFilterCategoryKey, string>;
12+
filterCategories: IFilterCategory<TItem, TFilterCategoryKey>[];
13+
showFilterDropdown?: boolean;
14+
isDisabled?: boolean;
15+
children?: React.ReactNode;
16+
}
17+
18+
export const FilterToolbar = <TItem, TFilterCategoryKey extends string>({
19+
currentFilterCategoryKey,
20+
setCurrentFilterCategoryKey,
21+
filterCategories,
22+
categoryTitles,
23+
showFilterDropdown,
24+
isDisabled,
25+
children,
26+
}: IFilterToolbarProps<TItem, TFilterCategoryKey>) => {
27+
const [isCategoryDropdownOpen, setIsCategoryDropdownOpen] = React.useState(false);
28+
29+
const onCategorySelect = (category: IFilterCategory<TItem, TFilterCategoryKey>) => {
30+
setCurrentFilterCategoryKey(category.categoryKey);
31+
setIsCategoryDropdownOpen(false);
32+
};
33+
34+
const currentFilterCategory = filterCategories.find((category) => category.categoryKey === currentFilterCategoryKey);
35+
36+
const renderDropdownItems = () => {
37+
return filterCategories.map((category) => (
38+
<DropdownItem
39+
id={`filter-category-${category.categoryKey}`}
40+
key={category.categoryKey}
41+
onClick={() => onCategorySelect(category)}
42+
>
43+
{categoryTitles[category.categoryKey]}
44+
</DropdownItem>
45+
));
46+
};
47+
48+
return (
49+
<ToolbarToggleGroup
50+
variant="filter-group"
51+
toggleIcon={<FilterIcon />}
52+
breakpoint="2xl"
53+
gap={showFilterDropdown ? { default: "gapMd" } : undefined}
54+
>
55+
{showFilterDropdown && (
56+
<ToolbarItem>
57+
<Dropdown
58+
toggle={(toggleRef) => (
59+
<MenuToggle
60+
id="filtered-by"
61+
ref={toggleRef}
62+
onClick={() => setIsCategoryDropdownOpen(!isCategoryDropdownOpen)}
63+
isDisabled={isDisabled}
64+
>
65+
<FilterIcon /> {currentFilterCategory ? categoryTitles[currentFilterCategory.categoryKey] : null}
66+
</MenuToggle>
67+
)}
68+
isOpen={isCategoryDropdownOpen}
69+
>
70+
{renderDropdownItems()}
71+
</Dropdown>
72+
</ToolbarItem>
73+
)}
74+
{children}
75+
</ToolbarToggleGroup>
76+
);
77+
};

0 commit comments

Comments
 (0)