Support failed backup display on the frontend; use SWR for backup pages
This commit is contained in:
parent
e3178ba6f0
commit
1e735cf0e8
11 changed files with 140 additions and 150 deletions
|
@ -1,31 +0,0 @@
|
|||
import { ServerBackup } from '@/api/server/backups/getServerBackups';
|
||||
import { action, Action } from 'easy-peasy';
|
||||
|
||||
export interface ServerBackupStore {
|
||||
data: ServerBackup[];
|
||||
setBackups: Action<ServerBackupStore, ServerBackup[]>;
|
||||
appendBackup: Action<ServerBackupStore, ServerBackup>;
|
||||
removeBackup: Action<ServerBackupStore, string>;
|
||||
}
|
||||
|
||||
const backups: ServerBackupStore = {
|
||||
data: [],
|
||||
|
||||
setBackups: action((state, payload) => {
|
||||
state.data = payload;
|
||||
}),
|
||||
|
||||
appendBackup: action((state, payload) => {
|
||||
if (state.data.find(backup => backup.uuid === payload.uuid)) {
|
||||
state.data = state.data.map(backup => backup.uuid === payload.uuid ? payload : backup);
|
||||
} else {
|
||||
state.data = [ ...state.data, payload ];
|
||||
}
|
||||
}),
|
||||
|
||||
removeBackup: action((state, payload) => {
|
||||
state.data = [ ...state.data.filter(backup => backup.uuid !== payload) ];
|
||||
}),
|
||||
};
|
||||
|
||||
export default backups;
|
|
@ -4,7 +4,6 @@ import socket, { SocketStore } from './socket';
|
|||
import files, { ServerFileStore } from '@/state/server/files';
|
||||
import subusers, { ServerSubuserStore } from '@/state/server/subusers';
|
||||
import { composeWithDevTools } from 'redux-devtools-extension';
|
||||
import backups, { ServerBackupStore } from '@/state/server/backups';
|
||||
import schedules, { ServerScheduleStore } from '@/state/server/schedules';
|
||||
import databases, { ServerDatabaseStore } from '@/state/server/databases';
|
||||
|
||||
|
@ -56,7 +55,6 @@ export interface ServerStore {
|
|||
databases: ServerDatabaseStore;
|
||||
files: ServerFileStore;
|
||||
schedules: ServerScheduleStore;
|
||||
backups: ServerBackupStore;
|
||||
socket: SocketStore;
|
||||
status: ServerStatusStore;
|
||||
clearServerState: Action<ServerStore>;
|
||||
|
@ -69,7 +67,6 @@ export const ServerContext = createContextStore<ServerStore>({
|
|||
databases,
|
||||
files,
|
||||
subusers,
|
||||
backups,
|
||||
schedules,
|
||||
clearServerState: action(state => {
|
||||
state.server.data = undefined;
|
||||
|
@ -78,7 +75,6 @@ export const ServerContext = createContextStore<ServerStore>({
|
|||
state.subusers.data = [];
|
||||
state.files.directory = '/';
|
||||
state.files.selectedFiles = [];
|
||||
state.backups.data = [];
|
||||
state.schedules.data = [];
|
||||
|
||||
if (state.socket.instance) {
|
||||
|
|
Reference in a new issue