Support pagination of server backups, closes #2787

This commit is contained in:
Dane Everitt 2020-12-06 12:01:42 -08:00
parent 8a97b73a6c
commit a8d9eccf9c
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
6 changed files with 53 additions and 22 deletions

View file

@ -3,8 +3,17 @@ import http, { getPaginationSet, PaginatedResult } from '@/api/http';
import { ServerBackup } from '@/api/server/types';
import { rawDataToServerBackup } from '@/api/transformers';
import { ServerContext } from '@/state/server';
import { createContext, useContext } from 'react';
export default (page?: number | string) => {
interface ctx {
page: number;
setPage: (value: number | ((s: number) => number)) => void;
}
export const Context = createContext<ctx>({ page: 1, setPage: () => 1 });
export default () => {
const { page } = useContext(Context);
const uuid = ServerContext.useStoreState(state => state.server.data!.uuid);
return useSWR<PaginatedResult<ServerBackup>>([ 'server:backups', uuid, page ], async () => {