@@ -745,24 +745,36 @@ function discoverController(
745745 }
746746
747747 function resolveIndexPatternLoading ( ) {
748- const props = $route . current . locals . ip ;
749- const loaded = props . loaded ;
750- const stateVal = props . stateVal ;
751- const stateValFound = props . stateValFound ;
748+ const {
749+ loaded : loadedIndexPattern ,
750+ stateVal,
751+ stateValFound,
752+ } = $route . current . locals . ip ;
752753
753- const own = $scope . searchSource . getOwnField ( 'index' ) ;
754+ const ownIndexPattern = $scope . searchSource . getOwnField ( 'index' ) ;
755+
756+ if ( ownIndexPattern && ! stateVal ) {
757+ return ownIndexPattern ;
758+ }
754759
755- if ( own && ! stateVal ) return own ;
756760 if ( stateVal && ! stateValFound ) {
757- const err = '"' + stateVal + '" is not a configured pattern ID. ' ;
758- if ( own ) {
759- notify . warning ( `${ err } Using the saved index pattern: "${ own . title } " (${ own . id } )` ) ;
760- return own ;
761+ const warningTitle = `"${ stateVal } " is not a configured index pattern ID` ;
762+
763+ if ( ownIndexPattern ) {
764+ toastNotifications . addWarning ( {
765+ title : warningTitle ,
766+ text : `Showing the saved index pattern: "${ ownIndexPattern . title } " (${ ownIndexPattern . id } )` ,
767+ } ) ;
768+ return ownIndexPattern ;
761769 }
762770
763- notify . warning ( `${ err } Using the default index pattern: "${ loaded . title } " (${ loaded . id } )` ) ;
771+ toastNotifications . addWarning ( {
772+ title : warningTitle ,
773+ text : `Showing the default index pattern: "${ loadedIndexPattern . title } " (${ loadedIndexPattern . id } )` ,
774+ } ) ;
764775 }
765- return loaded ;
776+
777+ return loadedIndexPattern ;
766778 }
767779
768780 init ( ) ;
0 commit comments