1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import { searchBarActions, SearchBarActions } from '~/store/search-bar/search-bar-actions';
6 import { GroupContentsResource } from '~/services/groups-service/groups-service';
11 searchResults: GroupContentsResource[];
13 savedQueries: string[];
16 export enum SearchView {
18 ADVANCED = 'advanced',
19 AUTOCOMPLETE = 'autocomplete'
22 const initialState: SearchBar = {
23 currentView: SearchView.BASIC,
30 export const searchBarReducer = (state = initialState, action: SearchBarActions): SearchBar =>
31 searchBarActions.match(action, {
32 SET_CURRENT_VIEW: currentView => ({ ...state, currentView }),
33 OPEN_SEARCH_VIEW: () => ({ ...state, open: true }),
34 CLOSE_SEARCH_VIEW: () => ({ ...state, open: false }),
35 SET_SEARCH_RESULTS: (searchResults) => ({ ...state, searchResults }),
36 SET_SEARCH_VALUE: (searchValue) => ({ ...state, searchValue }),
37 SET_SAVED_QUERIES: savedQueries => ({ ...state, savedQueries }),