1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-08-05 13:55:21 +02:00

fix(templates): separate template views filters [EE-6397] (#10711)

This commit is contained in:
Chaim Lev-Ari 2024-01-02 13:25:26 +07:00 committed by GitHub
parent 82951093b5
commit 4c226d7a17
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 28 additions and 16 deletions

View file

@ -34,6 +34,7 @@ export function AppTemplatesView() {
onSelect={(template) => setSelectedTemplateId(template.Id)}
disabledTypes={[TemplateType.Container]}
fixedCategories={['edge']}
storageKey="edge-app-templates"
/>
</>
);

View file

@ -26,6 +26,7 @@ export function ListView() {
to: 'edge.stacks.new',
params: { templateId: template.Id },
})}
storageKey="edge-custom-templates"
/>
</>
);

View file

@ -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) {

View file

@ -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) =>