Merge branch '18215-collection-update-without-manifest' into main.
[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 const fileUploaderActions = unionize({
21     CLEAR_UPLOAD: ofType(),
22     SET_UPLOAD_FILES: ofType<File[]>(),
23     UPDATE_UPLOAD_FILES: ofType<File[]>(),
24     SET_UPLOAD_PROGRESS: ofType<{ fileId: number, loaded: number, total: number, currentTime: number }>(),
25     START_UPLOAD: ofType(),
26     DELETE_UPLOAD_FILE: ofType<UploadFile>(),
27 });
28
29 export type FileUploaderAction = UnionOf<typeof fileUploaderActions>;
30
31 export const getFileUploaderState = () => (dispatch: Dispatch, getState: () => RootState) => {
32     return getState().fileUploader;
33 };