mirror of
https://github.com/portainer/portainer.git
synced 2025-08-09 07:45:22 +02:00
fix(templates): separate template views filters [EE-6397] (#10711)
This commit is contained in:
parent
82951093b5
commit
4c226d7a17
8 changed files with 28 additions and 16 deletions
|
@ -14,21 +14,15 @@ import { ListState, TemplateType } from './types';
|
|||
import { useSortAndFilterTemplates } from './useSortAndFilter';
|
||||
import { Filters } from './Filters';
|
||||
|
||||
const tableKey = 'app-templates-list';
|
||||
const store = createPersistedStore<ListState>(tableKey, undefined, (set) => ({
|
||||
category: null,
|
||||
setCategory: (category: ListState['category']) => set({ category }),
|
||||
types: [],
|
||||
setTypes: (types: ListState['types']) => set({ types }),
|
||||
}));
|
||||
|
||||
export function AppTemplatesList({
|
||||
templates: initialTemplates,
|
||||
onSelect,
|
||||
selectedId,
|
||||
disabledTypes,
|
||||
fixedCategories,
|
||||
storageKey,
|
||||
}: {
|
||||
storageKey: string;
|
||||
templates?: TemplateViewModel[];
|
||||
onSelect: (template: TemplateViewModel) => void;
|
||||
selectedId?: TemplateViewModel['Id'];
|
||||
|
@ -36,8 +30,15 @@ export function AppTemplatesList({
|
|||
fixedCategories?: Array<string>;
|
||||
}) {
|
||||
const [page, setPage] = useState(0);
|
||||
|
||||
const listState = useTableState(store, tableKey);
|
||||
const [store] = useState(() =>
|
||||
createPersistedStore<ListState>(storageKey, undefined, (set) => ({
|
||||
category: null,
|
||||
setCategory: (category: ListState['category']) => set({ category }),
|
||||
types: [],
|
||||
setTypes: (types: ListState['types']) => set({ types }),
|
||||
}))
|
||||
);
|
||||
const listState = useTableState(store, storageKey);
|
||||
|
||||
const templates = useMemo(() => {
|
||||
if (!initialTemplates) {
|
||||
|
|
|
@ -14,15 +14,13 @@ import { Link } from '@@/Link';
|
|||
|
||||
import { CustomTemplatesListItem } from './CustomTemplatesListItem';
|
||||
|
||||
const tableKey = 'custom-templates-list';
|
||||
const store = createPersistedStore(tableKey);
|
||||
|
||||
export function CustomTemplatesList({
|
||||
templates,
|
||||
onSelect,
|
||||
onDelete,
|
||||
selectedId,
|
||||
templateLinkParams,
|
||||
storageKey,
|
||||
}: {
|
||||
templates?: CustomTemplate[];
|
||||
onSelect?: (template: CustomTemplate['Id']) => void;
|
||||
|
@ -32,10 +30,11 @@ export function CustomTemplatesList({
|
|||
to: string;
|
||||
params: object;
|
||||
};
|
||||
storageKey: string;
|
||||
}) {
|
||||
const [page, setPage] = useState(0);
|
||||
|
||||
const listState = useTableState(store, tableKey);
|
||||
const [store] = useState(() => createPersistedStore(storageKey));
|
||||
const listState = useTableState(store, storageKey);
|
||||
|
||||
const filterBySearch = useCallback(
|
||||
(item: CustomTemplate) =>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue