forked from pterodactyl/panel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfiles.ts
More file actions
35 lines (27 loc) · 1015 Bytes
/
files.ts
File metadata and controls
35 lines (27 loc) · 1015 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { action, Action } from 'easy-peasy';
import { cleanDirectoryPath } from '@/helpers';
export interface ServerFileStore {
directory: string;
selectedFiles: string[];
setDirectory: Action<ServerFileStore, string>;
setSelectedFiles: Action<ServerFileStore, string[]>;
appendSelectedFile: Action<ServerFileStore, string>;
removeSelectedFile: Action<ServerFileStore, string>;
}
const files: ServerFileStore = {
directory: '/',
selectedFiles: [],
setDirectory: action((state, payload) => {
state.directory = cleanDirectoryPath(payload);
}),
setSelectedFiles: action((state, payload) => {
state.selectedFiles = payload;
}),
appendSelectedFile: action((state, payload) => {
state.selectedFiles = state.selectedFiles.filter(f => f !== payload).concat(payload);
}),
removeSelectedFile: action((state, payload) => {
state.selectedFiles = state.selectedFiles.filter(f => f !== payload);
}),
};
export default files;