Merge branch '19319-container-price' into main. Closes #19319
[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     CANCEL_FILES_UPLOAD: ofType(),
28 });
29
30 export type FileUploaderAction = UnionOf<typeof fileUploaderActions>;
31
32 export const getFileUploaderState = () => (dispatch: Dispatch, getState: () => RootState) => {
33     return getState().fileUploader;
34 };