mirror of
https://github.com/portainer/portainer.git
synced 2025-07-24 15:59:41 +02:00
refactor(k8s): namespace core logic (#12142)
Co-authored-by: testA113 <aliharriss1995@gmail.com> Co-authored-by: Anthony Lapenna <anthony.lapenna@portainer.io> Co-authored-by: James Carppe <85850129+jamescarppe@users.noreply.github.com> Co-authored-by: Ali <83188384+testA113@users.noreply.github.com>
This commit is contained in:
parent
da010f3d08
commit
ea228c3d6d
276 changed files with 9241 additions and 3361 deletions
|
@ -1,7 +1,7 @@
|
|||
import clsx from 'clsx';
|
||||
import { useMemo } from 'react';
|
||||
import { Menu, MenuButton, MenuPopover } from '@reach/menu-button';
|
||||
import { Column } from '@tanstack/react-table';
|
||||
import { Column, Row } from '@tanstack/react-table';
|
||||
import { Check, Filter } from 'lucide-react';
|
||||
|
||||
import { getValueAsArrayOfStrings } from '@/portainer/helpers/array';
|
||||
|
@ -73,7 +73,15 @@ export function MultipleSelectionFilter({
|
|||
}
|
||||
}
|
||||
|
||||
export function filterHOC<TData extends DefaultType>(menuTitle: string) {
|
||||
export type FilterOptionsTransformer<TData extends DefaultType> = (
|
||||
rows: Row<TData>[],
|
||||
id: string
|
||||
) => string[];
|
||||
|
||||
export function filterHOC<TData extends DefaultType>(
|
||||
menuTitle: string,
|
||||
filterOptionsTransformer: FilterOptionsTransformer<TData> = defaultFilterOptionsTransformer
|
||||
) {
|
||||
return function Filter({
|
||||
column: { getFilterValue, setFilterValue, getFacetedRowModel, id },
|
||||
}: {
|
||||
|
@ -81,15 +89,10 @@ export function filterHOC<TData extends DefaultType>(menuTitle: string) {
|
|||
}) {
|
||||
const { flatRows } = getFacetedRowModel();
|
||||
|
||||
const options = useMemo(() => {
|
||||
const options = new Set<string>();
|
||||
flatRows.forEach(({ getValue }) => {
|
||||
const value = getValue<string>(id);
|
||||
|
||||
options.add(value);
|
||||
});
|
||||
return Array.from(options);
|
||||
}, [flatRows, id]);
|
||||
const options = useMemo(
|
||||
() => filterOptionsTransformer(flatRows, id),
|
||||
[flatRows, id]
|
||||
);
|
||||
|
||||
const value = getFilterValue();
|
||||
|
||||
|
@ -106,3 +109,15 @@ export function filterHOC<TData extends DefaultType>(menuTitle: string) {
|
|||
);
|
||||
};
|
||||
}
|
||||
|
||||
function defaultFilterOptionsTransformer<TData extends DefaultType>(
|
||||
rows: Row<TData>[],
|
||||
id: string
|
||||
) {
|
||||
const options = new Set<string>();
|
||||
rows.forEach(({ getValue }) => {
|
||||
const value = getValue<string>(id);
|
||||
options.add(value);
|
||||
});
|
||||
return Array.from(options);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue