+export const searchSingleCluster = (session: Session, searchValue: string) =>
+ (dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
+ const state = getState();
+ const dataExplorer = getDataExplorer(state.dataExplorer, SEARCH_RESULTS_PANEL_ID);
+
+ if (searchValue.trim() === '') {
+ return;
+ }
+
+ const params = getParams(dataExplorer, searchValue, session.apiRevision);
+
+ // If the clusterId & search offset has already been fetched, we don't need to fetch the results again
+ if(state.searchBar.searchOffsets[session.clusterId] === params.offset) {
+ return;
+ }
+
+ dispatch(progressIndicatorActions.START_WORKING(SEARCH_RESULTS_PANEL_ID))
+
+ services.groupsService.contents('', params, session)
+ .then((response) => {
+ dispatch<any>(setSearchOffsets(session.clusterId, params.offset ));
+ dispatch(updateResources(response.items));
+ dispatch(appendItems(response));
+ // Request all containers for process status to be available
+ const containerRequests = response.items.filter((item) => item.kind === ResourceKind.CONTAINER_REQUEST) as ContainerRequestResource[];
+ const containerUuids = containerRequests.map(container => container.containerUuid).filter(uuid => uuid !== null) as string[];
+ containerUuids.length && services.containerService
+ .list({
+ filters: new FilterBuilder()
+ .addIn('uuid', containerUuids)
+ .getFilters()
+ }, false)
+ .then((containers) => {
+ dispatch(updateResources(containers.items));
+ });
+ }).catch(() => {
+ dispatch(couldNotFetchSearchResults(session.clusterId));
+ dispatch(progressIndicatorActions.STOP_WORKING(SEARCH_RESULTS_PANEL_ID))
+ });
+ dispatch(progressIndicatorActions.STOP_WORKING(SEARCH_RESULTS_PANEL_ID))
+}
+