Fix correct bytes not being sent, fix showing upload progress and speed
[arvados.git] / src / store / collections / creator / collection-creator-reducer.ts
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import { collectionCreateActions, CollectionCreateAction } from './collection-creator-action';
6
7 export interface CollectionCreatorState {
8     opened: boolean;
9     ownerUuid: string;
10 }
11
12 const updateCreator = (state: CollectionCreatorState, creator?: Partial<CollectionCreatorState>) => ({
13     ...state,
14     ...creator
15 });
16
17 const initialState: CollectionCreatorState = {
18     opened: false,
19     ownerUuid: ''
20 };
21
22 export const collectionCreatorReducer = (state: CollectionCreatorState = initialState, action: CollectionCreateAction) => {
23     return collectionCreateActions.match(action, {
24         OPEN_COLLECTION_CREATOR: ({ ownerUuid }) => updateCreator(state, { ownerUuid, opened: true }),
25         CLOSE_COLLECTION_CREATOR: () => updateCreator(state, { opened: false }),
26         CREATE_COLLECTION: () => updateCreator(state),
27         CREATE_COLLECTION_SUCCESS: () => updateCreator(state, { opened: false, ownerUuid: "" }),
28         default: () => state
29     });
30 };