@@ -32,7 +32,7 @@ import { RouteComponentProps, useLocation } from 'react-router-dom';
32
32
import { AppState } from '../../../redux/reducers' ;
33
33
import { getMappings } from '../../../redux/reducers/opensearch' ;
34
34
import { useFetchDetectorInfo } from '../../CreateDetectorSteps/hooks/useFetchDetectorInfo' ;
35
- import { BREADCRUMBS , BASE_DOCS_LINK } from '../../../utils/constants' ;
35
+ import { BREADCRUMBS , BASE_DOCS_LINK , MDS_BREADCRUMBS } from '../../../utils/constants' ;
36
36
import { useHideSideNavBar } from '../../main/hooks/useHideSideNavBar' ;
37
37
import { updateDetector } from '../../../redux/reducers/ad' ;
38
38
import {
@@ -64,7 +64,7 @@ import {
64
64
} from '../../../pages/utils/helpers' ;
65
65
import {
66
66
getDataSourceManagementPlugin ,
67
- getDataSourcePlugin ,
67
+ getDataSourceEnabled ,
68
68
getNotifications ,
69
69
getSavedObjectsClient ,
70
70
} from '../../../services' ;
@@ -89,7 +89,7 @@ export function ConfigureModel(props: ConfigureModelProps) {
89
89
const dispatch = useDispatch ( ) ;
90
90
const location = useLocation ( ) ;
91
91
const MDSQueryParams = getDataSourceFromURL ( location ) ;
92
- const dataSourceEnabled = getDataSourcePlugin ( ) ?. dataSourceEnabled || false ;
92
+ const dataSourceEnabled = getDataSourceEnabled ( ) . enabled ;
93
93
const dataSourceId = MDSQueryParams . dataSourceId ;
94
94
95
95
useHideSideNavBar ( true , false ) ;
@@ -122,30 +122,55 @@ export function ConfigureModel(props: ConfigureModelProps) {
122
122
} , [ detector ] ) ;
123
123
124
124
useEffect ( ( ) => {
125
- if ( props . isEdit ) {
126
- core . chrome . setBreadcrumbs ( [
127
- BREADCRUMBS . ANOMALY_DETECTOR ,
128
- BREADCRUMBS . DETECTORS ,
129
- {
130
- text : detector && detector . name ? detector . name : '' ,
131
- href : constructHrefWithDataSourceId ( `#/detectors/${ detectorId } ` , dataSourceId , false )
132
- } ,
133
- BREADCRUMBS . EDIT_MODEL_CONFIGURATION ,
134
- ] ) ;
125
+ if ( dataSourceEnabled ) {
126
+ if ( props . isEdit ) {
127
+ core . chrome . setBreadcrumbs ( [
128
+ MDS_BREADCRUMBS . ANOMALY_DETECTOR ( dataSourceId ) ,
129
+ MDS_BREADCRUMBS . DETECTORS ( dataSourceId ) ,
130
+ {
131
+ text : detector && detector . name ? detector . name : '' ,
132
+ href : constructHrefWithDataSourceId ( `#/detectors/${ detectorId } ` , dataSourceId , false )
133
+ } ,
134
+ MDS_BREADCRUMBS . EDIT_MODEL_CONFIGURATION ,
135
+ ] ) ;
136
+ } else {
137
+ core . chrome . setBreadcrumbs ( [
138
+ MDS_BREADCRUMBS . ANOMALY_DETECTOR ( dataSourceId ) ,
139
+ MDS_BREADCRUMBS . DETECTORS ( dataSourceId ) ,
140
+ MDS_BREADCRUMBS . CREATE_DETECTOR ,
141
+ ] ) ;
142
+ }
135
143
} else {
136
- core . chrome . setBreadcrumbs ( [
137
- BREADCRUMBS . ANOMALY_DETECTOR ,
138
- BREADCRUMBS . DETECTORS ,
139
- BREADCRUMBS . CREATE_DETECTOR ,
140
- ] ) ;
144
+ if ( props . isEdit ) {
145
+ core . chrome . setBreadcrumbs ( [
146
+ BREADCRUMBS . ANOMALY_DETECTOR ,
147
+ BREADCRUMBS . DETECTORS ,
148
+ {
149
+ text : detector && detector . name ? detector . name : '' ,
150
+ href : `#/detectors/${ detectorId } ` ,
151
+ } ,
152
+ BREADCRUMBS . EDIT_MODEL_CONFIGURATION ,
153
+ ] ) ;
154
+ } else {
155
+ core . chrome . setBreadcrumbs ( [
156
+ BREADCRUMBS . ANOMALY_DETECTOR ,
157
+ BREADCRUMBS . DETECTORS ,
158
+ BREADCRUMBS . CREATE_DETECTOR ,
159
+ ] ) ;
160
+ }
141
161
}
142
162
} , [ detector ] ) ;
143
163
144
164
useEffect ( ( ) => {
145
165
if ( hasError ) {
146
- props . history . push (
147
- constructHrefWithDataSourceId ( '/detectors' , dataSourceId , false )
148
- ) ;
166
+ if ( dataSourceEnabled ) {
167
+ props . history . push (
168
+ constructHrefWithDataSourceId ( '/detectors' , dataSourceId , false )
169
+ ) ;
170
+ }
171
+ else {
172
+ props . history . push ( '/detectors' ) ;
173
+ }
149
174
}
150
175
} , [ hasError ] ) ;
151
176
0 commit comments