21128: cleanup, renamed some types Arvados-DCO-1.1-Signed-off-by: Lisa Knox <lisa...
[arvados.git] / src / store / vocabulary / vocabulary-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 { VOCABULARY_PROPERTY_NAME, DEFAULT_VOCABULARY } from './vocabulary-selectors';
9 import { isVocabulary } from 'models/vocabulary';
10
11 export const loadVocabulary = async (dispatch: Dispatch, _: {}, { vocabularyService }: ServiceRepository) => {
12     const vocabulary = await vocabularyService.getVocabulary();
13     dispatch(propertiesActions.SET_PROPERTY({
14         key: VOCABULARY_PROPERTY_NAME,
15         value: isVocabulary(vocabulary)
16             ? vocabulary
17             : DEFAULT_VOCABULARY,
18     }));
19 };