From fdd79297de2d58c0e25588beb9ddf4feda908afa Mon Sep 17 00:00:00 2001 From: Michal Klobukowski Date: Tue, 27 Nov 2018 10:59:15 +0100 Subject: [PATCH] Create loadVocabulary action Feature #14393 Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski --- src/store/vocabulary/vocabulary-actions.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/store/vocabulary/vocabulary-actions.ts diff --git a/src/store/vocabulary/vocabulary-actions.ts b/src/store/vocabulary/vocabulary-actions.ts new file mode 100644 index 00000000..799cffa0 --- /dev/null +++ b/src/store/vocabulary/vocabulary-actions.ts @@ -0,0 +1,20 @@ +// Copyright (C) The Arvados Authors. All rights reserved. +// +// SPDX-License-Identifier: AGPL-3.0 + +import { Dispatch } from 'redux'; +import { ServiceRepository } from '~/services/services'; +import { propertiesActions } from '~/store/properties/properties-actions'; +import { VOCABULARY_PROPERTY_NAME, DEFAULT_VOCABULARY } from './vocabulary-selctors'; +import { isVocabulary } from '~/models/vocabulary'; + +export const loadVocabulary = async (dispatch: Dispatch, _: {}, { vocabularyService }: ServiceRepository) => { + const vocabulary = await vocabularyService.getVocabulary(); + + dispatch(propertiesActions.SET_PROPERTY({ + key: VOCABULARY_PROPERTY_NAME, + value: isVocabulary(vocabulary) + ? vocabulary + : DEFAULT_VOCABULARY, + })); +}; -- 2.30.2