Skip to content
Snippets Groups Projects
Commit 98b0b2c6 authored by Esko Ikkala's avatar Esko Ikkala
Browse files

Show spinner when fetching results

parent a934529b
No related branches found
No related tags found
No related merge requests found
...@@ -124,7 +124,7 @@ const IntegrationAutosuggest = (props) => { ...@@ -124,7 +124,7 @@ const IntegrationAutosuggest = (props) => {
}; };
const shouldRenderSuggestions = (value) => { const shouldRenderSuggestions = (value) => {
return value.trim().length > 3; return value.trim().length > 2;
}; };
const handleOnSuggestionsClearRequested = () => { const handleOnSuggestionsClearRequested = () => {
...@@ -136,7 +136,7 @@ const IntegrationAutosuggest = (props) => { ...@@ -136,7 +136,7 @@ const IntegrationAutosuggest = (props) => {
//console.log('IntegrationAutosuggest', props.search.suggestions); //console.log('IntegrationAutosuggest', props.search.suggestions);
let adornment = null; let adornment = null;
if (props.search.fetchingSuggestions) { if (props.search.fetchingSuggestions || props.search.fetchingResults) {
adornment = <InputAdornment position="end"><CircularProgress size={20} /></InputAdornment>; adornment = <InputAdornment position="end"><CircularProgress size={20} /></InputAdornment>;
} else { } else {
adornment = <SearchIcon className={classes.icon} />; adornment = <SearchIcon className={classes.icon} />;
......
...@@ -2,6 +2,7 @@ import { ...@@ -2,6 +2,7 @@ import {
UPDATE_QUERY, UPDATE_QUERY,
UPDATE_DATASETS, UPDATE_DATASETS,
FETCH_SUGGESTIONS, FETCH_SUGGESTIONS,
FETCH_RESULTS,
UPDATE_SUGGESTIONS, UPDATE_SUGGESTIONS,
CLEAR_SUGGESTIONS, CLEAR_SUGGESTIONS,
UPDATE_RESULTS, UPDATE_RESULTS,
...@@ -18,7 +19,7 @@ export const INITIAL_STATE = { ...@@ -18,7 +19,7 @@ export const INITIAL_STATE = {
fetchingSuggestions: false, fetchingSuggestions: false,
results: [], results: [],
resultsQuery: '', resultsQuery: '',
fetchingResults: true, fetchingResults: false,
}; };
const search = (state = INITIAL_STATE, action) => { const search = (state = INITIAL_STATE, action) => {
...@@ -29,6 +30,8 @@ const search = (state = INITIAL_STATE, action) => { ...@@ -29,6 +30,8 @@ const search = (state = INITIAL_STATE, action) => {
return { ...state, datasets: action.datasets || [] }; return { ...state, datasets: action.datasets || [] };
case FETCH_SUGGESTIONS: case FETCH_SUGGESTIONS:
return { ...state, fetchingSuggestions: true }; return { ...state, fetchingSuggestions: true };
case FETCH_RESULTS:
return { ...state, fetchingResults: true };
case CLEAR_SUGGESTIONS: case CLEAR_SUGGESTIONS:
return { return {
...state, ...state,
...@@ -48,12 +51,14 @@ const search = (state = INITIAL_STATE, action) => { ...@@ -48,12 +51,14 @@ const search = (state = INITIAL_STATE, action) => {
...state, ...state,
results: [], results: [],
resultsQuery: '', resultsQuery: '',
fetchingResults: false
}; };
case UPDATE_RESULTS: case UPDATE_RESULTS:
return { return {
...state, ...state,
results: results(state.results, action), results: results(state.results, action),
resultsQuery: state.query resultsQuery: state.query,
fetchingResults: false
}; };
default: default:
return state; return state;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment