1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import { Dispatch } from 'redux';
6 import { RootState } from '~/store/store';
7 import { ServiceRepository } from '~/services/services';
8 import { bindDataExplorerActions } from '~/store/data-explorer/data-explorer-action';
9 import { setBreadcrumbs } from '~/store/breadcrumbs/breadcrumbs-actions';
10 import { searchBarActions } from '~/store/search-bar/search-bar-actions';
12 export const SEARCH_RESULTS_PANEL_ID = "searchResultsPanel";
13 export const searchResultsPanelActions = bindDataExplorerActions(SEARCH_RESULTS_PANEL_ID);
15 export const loadSearchResultsPanel = () =>
16 (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
17 dispatch(setBreadcrumbs([{ label: 'Search results' }]));
18 const loc = getState().router.location;
20 const search = new URLSearchParams(loc.search);
21 const q = search.get('q');
23 dispatch(searchBarActions.SET_SEARCH_VALUE(q));
26 dispatch(searchBarActions.SET_SEARCH_RESULTS([]));
27 dispatch(searchResultsPanelActions.CLEAR());
28 dispatch(searchResultsPanelActions.REQUEST_ITEMS(true));