diff options
Diffstat (limited to 'app/assets/javascripts/frequent_items/store/actions.js')
-rw-r--r-- | app/assets/javascripts/frequent_items/store/actions.js | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/app/assets/javascripts/frequent_items/store/actions.js b/app/assets/javascripts/frequent_items/store/actions.js index d4756e2ea6a..f4156487625 100644 --- a/app/assets/javascripts/frequent_items/store/actions.js +++ b/app/assets/javascripts/frequent_items/store/actions.js @@ -1,7 +1,7 @@ -import Api from '~/api'; import AccessorUtilities from '~/lib/utils/accessor'; import * as types from './mutation_types'; import { getTopFrequentItems } from '../utils'; +import { getGroups, getProjects } from '~/rest_api'; export const setNamespace = ({ commit }, namespace) => { commit(types.SET_NAMESPACE, namespace); @@ -54,12 +54,16 @@ export const fetchSearchedItems = ({ state, dispatch }, searchQuery) => { membership: Boolean(gon.current_user_id), }; + let searchFunction; if (state.namespace === 'projects') { + searchFunction = getProjects; params.order_by = 'last_activity_at'; + } else { + searchFunction = getGroups; } - return Api[state.namespace](searchQuery, params) - .then(results => { + return searchFunction(searchQuery, params) + .then((results) => { dispatch('receiveSearchedItemsSuccess', results); }) .catch(() => { |