@@ -306,9 +306,6 @@ export type State = {
306306 // state of the index suggestions
307307 fetchingSuggestionsState : IndexSuggestionState ;
308308
309- // error specific to fetching index suggestions
310- fetchingSuggestionsError : string | null ;
311-
312309 // index suggestions in a format such as {fieldName: 1}
313310 indexSuggestions : Record < string , number > | null ;
314311
@@ -324,7 +321,6 @@ export const INITIAL_STATE: State = {
324321 options : INITIAL_OPTIONS_STATE ,
325322 currentTab : 'IndexFlow' ,
326323 fetchingSuggestionsState : 'initial' ,
327- fetchingSuggestionsError : null ,
328324 indexSuggestions : null ,
329325 sampleDocs : null ,
330326} ;
@@ -367,7 +363,7 @@ export type SuggestedIndexFetchedAction = {
367363 type : ActionTypes . SuggestedIndexesFetched ;
368364 sampleDocs : Array < Document > ;
369365 indexSuggestions : { [ key : string ] : number } | null ;
370- fetchingSuggestionsError : string | null ;
366+ error : string | null ;
371367 indexSuggestionsState : IndexSuggestionState ;
372368} ;
373369
@@ -389,7 +385,7 @@ export const fetchIndexSuggestions = ({
389385 Promise < void > ,
390386 SuggestedIndexFetchedAction | SuggestedIndexesRequestedAction
391387> => {
392- return async ( dispatch , getState , { dataService } ) => {
388+ return async ( dispatch , getState , { dataService, track } ) => {
393389 dispatch ( {
394390 type : ActionTypes . SuggestedIndexesRequested ,
395391 } ) ;
@@ -422,39 +418,28 @@ export const fetchIndexSuggestions = ({
422418 analyzedNamespace
423419 ) ;
424420 const results = await mql . suggestIndex ( [ query ] ) ;
425- const indexSuggestions = results ?. index || null ;
426-
427- // TODO in CLOUDP-311787: add info banner and update the current error banner to take in fetchingSuggestionsError as well
428- if ( ! indexSuggestions ) {
429- dispatch ( {
430- type : ActionTypes . SuggestedIndexesFetched ,
431- sampleDocs : sampleDocuments ,
432- indexSuggestions,
433- fetchingSuggestionsError :
434- 'No suggested index found. Please choose "Start with an Index" at the top to continue.' ,
435- indexSuggestionsState : 'error' ,
436- } ) ;
437- return ;
438- }
421+ const indexSuggestions = results ?. index ;
439422
440423 dispatch ( {
441424 type : ActionTypes . SuggestedIndexesFetched ,
442425 sampleDocs : sampleDocuments ,
443426 indexSuggestions,
444- fetchingSuggestionsError : null ,
427+ error : null ,
445428 indexSuggestionsState : 'success' ,
446429 } ) ;
447430 } catch ( e : unknown ) {
448431 dispatch ( {
449432 type : ActionTypes . SuggestedIndexesFetched ,
450433 sampleDocs : sampleDocuments ,
451434 indexSuggestions : null ,
452- fetchingSuggestionsError :
435+ error :
453436 e instanceof Error
454437 ? 'Error parsing query. Please follow query structure. ' + e . message
455438 : 'Error parsing query. Please follow query structure.' ,
456439 indexSuggestionsState : 'error' ,
457440 } ) ;
441+
442+ track ( 'Error parsing query' , { context : 'Create Index Modal' } ) ;
458443 }
459444 } ;
460445} ;
@@ -508,7 +493,6 @@ export const createIndexFormSubmitted = (): IndexesThunkAction<
508493 // Check for field errors.
509494 if ( isQueryFlow ) {
510495 if ( ! indexSuggestions ) {
511- // TODO in CLOUDP-311787: add info banner and update the current error banner to take in fetchingSuggestionsError as well
512496 dispatch (
513497 errorEncountered (
514498 'No suggested index found. Please choose "Start with an Index" at the top to continue.'
@@ -780,7 +764,7 @@ const reducer: Reducer<State, Action> = (state = INITIAL_STATE, action) => {
780764 return {
781765 ...state ,
782766 fetchingSuggestionsState : 'fetching' ,
783- fetchingSuggestionsError : null ,
767+ error : null ,
784768 indexSuggestions : null ,
785769 } ;
786770 }
@@ -794,7 +778,7 @@ const reducer: Reducer<State, Action> = (state = INITIAL_STATE, action) => {
794778 return {
795779 ...state ,
796780 fetchingSuggestionsState : action . indexSuggestionsState ,
797- fetchingSuggestionsError : action . fetchingSuggestionsError ,
781+ error : action . error ,
798782 indexSuggestions : action . indexSuggestions ,
799783 sampleDocs : action . sampleDocs ,
800784 } ;
0 commit comments