Added removing files during upload feature
[arvados-workbench2.git] / src / store / file-uploader / file-uploader-actions.ts
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import { unionize, ofType, UnionOf } from "~/common/unionize";
6 import { Dispatch } from "redux";
7 import { RootState } from '~/store/store';
8
9 export interface UploadFile {
10     id: number;
11     file: File;
12     prevLoaded: number;
13     loaded: number;
14     total: number;
15     startTime: number;
16     prevTime: number;
17     currentTime: number;
18 }
19
20 export interface FileWithId extends File {
21     id: number;
22 }
23
24 export const fileUploaderActions = unionize({
25     CLEAR_UPLOAD: ofType(),
26     SET_UPLOAD_FILES: ofType<File[]>(),
27     UPDATE_UPLOAD_FILES: ofType<File[]>(),
28     SET_UPLOAD_PROGRESS: ofType<{ fileId: number, loaded: number, total: number, currentTime: number }>(),
29     START_UPLOAD: ofType(),
30     DELETE_UPLOAD_FILE: ofType<FileWithId[]>(),
31 });
32
33 export type FileUploaderAction = UnionOf<typeof fileUploaderActions>;
34
35 export const getFileUploaderState = () => (dispatch: Dispatch, getState: () => RootState) => {
36     return getState().fileUploader;
37 };