19438: Finished adding fields
[arvados-workbench2.git] / src / store / file-viewers / file-viewers-actions.ts
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import { Dispatch } from 'redux';
6 import { ServiceRepository } from 'services/services';
7 import { propertiesActions } from 'store/properties/properties-actions';
8 import { FILE_VIEWERS_PROPERTY_NAME, DEFAULT_FILE_VIEWERS } from 'store/file-viewers/file-viewers-selectors';
9 import { FileViewerList } from 'models/file-viewers-config';
10
11 export const loadFileViewersConfig = async (dispatch: Dispatch, _: {}, { fileViewersConfig }: ServiceRepository) => {
12     
13     let config: FileViewerList;
14     try{
15         config = await fileViewersConfig.get();
16     } catch (e){
17         config = DEFAULT_FILE_VIEWERS;
18     }
19
20     dispatch(propertiesActions.SET_PROPERTY({
21         key: FILE_VIEWERS_PROPERTY_NAME,
22         value: config,
23     }));
24
25 };