diff options
Diffstat (limited to 'app/assets/javascripts/header_search/store/actions.js')
-rw-r--r-- | app/assets/javascripts/header_search/store/actions.js | 45 |
1 files changed, 0 insertions, 45 deletions
diff --git a/app/assets/javascripts/header_search/store/actions.js b/app/assets/javascripts/header_search/store/actions.js deleted file mode 100644 index a0f9e594506..00000000000 --- a/app/assets/javascripts/header_search/store/actions.js +++ /dev/null @@ -1,45 +0,0 @@ -import { omitBy, isNil } from 'lodash'; -import { objectToQuery } from '~/lib/utils/url_utility'; -import axios from '~/lib/utils/axios_utils'; -import { FETCH_TYPES } from '../constants'; -import * as types from './mutation_types'; - -export const autocompleteQuery = ({ state, fetchType }) => { - const query = omitBy( - { - term: state.search, - project_id: state.searchContext?.project?.id, - project_ref: state.searchContext?.ref, - filter: fetchType, - }, - isNil, - ); - - return `${state.autocompletePath}?${objectToQuery(query)}`; -}; - -const doFetch = ({ commit, state, fetchType }) => { - return axios - .get(autocompleteQuery({ state, fetchType })) - .then(({ data }) => { - commit(types.RECEIVE_AUTOCOMPLETE_SUCCESS, data); - }) - .catch(() => { - commit(types.RECEIVE_AUTOCOMPLETE_ERROR); - }); -}; - -export const fetchAutocompleteOptions = ({ commit, state }) => { - commit(types.REQUEST_AUTOCOMPLETE); - const promises = FETCH_TYPES.map((fetchType) => doFetch({ commit, state, fetchType })); - - return Promise.all(promises); -}; - -export const clearAutocomplete = ({ commit }) => { - commit(types.CLEAR_AUTOCOMPLETE); -}; - -export const setSearch = ({ commit }, value) => { - commit(types.SET_SEARCH, value); -}; |