@@ -13,10 +13,7 @@ import { useHistory } from 'react-router-dom';
1313import { SecurityPageName } from '../../../app/types' ;
1414import { TimelineId } from '../../../../common/types/timeline' ;
1515import { GlobalTime } from '../../../common/containers/global_time' ;
16- import {
17- indicesExistOrDataTemporarilyUnavailable ,
18- WithSource ,
19- } from '../../../common/containers/source' ;
16+ import { useWithSource } from '../../../common/containers/source' ;
2017import { UpdateDateRange } from '../../../common/components/charts/common' ;
2118import { FiltersGlobal } from '../../../common/components/filters_global' ;
2219import { getRulesUrl } from '../../../common/components/link_to/redirect_to_detection_engine' ;
@@ -82,6 +79,7 @@ export const DetectionEnginePageComponent: React.FC<PropsFromRedux> = ({
8279 const indexToAdd = useMemo ( ( ) => ( signalIndexName == null ? [ ] : [ signalIndexName ] ) , [
8380 signalIndexName ,
8481 ] ) ;
82+ const { indicesExist, indexPattern } = useWithSource ( 'default' , indexToAdd ) ;
8583
8684 if ( isUserAuthenticated != null && ! isUserAuthenticated && ! loading ) {
8785 return (
@@ -104,77 +102,73 @@ export const DetectionEnginePageComponent: React.FC<PropsFromRedux> = ({
104102 < >
105103 { hasEncryptionKey != null && ! hasEncryptionKey && < NoApiIntegrationKeyCallOut /> }
106104 { hasIndexWrite != null && ! hasIndexWrite && < NoWriteAlertsCallOut /> }
107- < WithSource sourceId = "default" indexToAdd = { indexToAdd } >
108- { ( { indicesExist, indexPattern } ) => {
109- return indicesExistOrDataTemporarilyUnavailable ( indicesExist ) ? (
110- < StickyContainer >
111- < FiltersGlobal >
112- < SiemSearchBar id = "global" indexPattern = { indexPattern } />
113- </ FiltersGlobal >
114- < WrapperPage >
115- < DetectionEngineHeaderPage
116- subtitle = {
117- lastAlerts != null && (
118- < >
119- { i18n . LAST_ALERT }
120- { ': ' }
121- { lastAlerts }
122- </ >
123- )
124- }
125- title = { i18n . PAGE_TITLE }
126- >
127- < LinkButton
128- fill
129- onClick = { goToRules }
130- href = { formatUrl ( getRulesUrl ( ) ) }
131- iconType = "gear"
132- data-test-subj = "manage-alert-detection-rules"
133- >
134- { i18n . BUTTON_MANAGE_RULES }
135- </ LinkButton >
136- </ DetectionEngineHeaderPage >
105+ { indicesExist ? (
106+ < StickyContainer >
107+ < FiltersGlobal >
108+ < SiemSearchBar id = "global" indexPattern = { indexPattern } />
109+ </ FiltersGlobal >
110+ < WrapperPage >
111+ < DetectionEngineHeaderPage
112+ subtitle = {
113+ lastAlerts != null && (
114+ < >
115+ { i18n . LAST_ALERT }
116+ { ': ' }
117+ { lastAlerts }
118+ </ >
119+ )
120+ }
121+ title = { i18n . PAGE_TITLE }
122+ >
123+ < LinkButton
124+ fill
125+ onClick = { goToRules }
126+ href = { formatUrl ( getRulesUrl ( ) ) }
127+ iconType = "gear"
128+ data-test-subj = "manage-alert-detection-rules"
129+ >
130+ { i18n . BUTTON_MANAGE_RULES }
131+ </ LinkButton >
132+ </ DetectionEngineHeaderPage >
137133
138- < GlobalTime >
139- { ( { to, from, deleteQuery, setQuery } ) => (
140- < >
141- < >
142- < AlertsHistogramPanel
143- deleteQuery = { deleteQuery }
144- filters = { filters }
145- from = { from }
146- query = { query }
147- setQuery = { setQuery }
148- showTotalAlertsCount = { true }
149- signalIndexName = { signalIndexName }
150- stackByOptions = { alertsHistogramOptions }
151- to = { to }
152- updateDateRange = { updateDateRangeCallback }
153- />
154- < EuiSpacer size = "l" />
155- < AlertsTable
156- timelineId = { TimelineId . alertsPage }
157- loading = { loading }
158- hasIndexWrite = { hasIndexWrite ?? false }
159- canUserCRUD = { ( canUserCRUD ?? false ) && ( hasEncryptionKey ?? false ) }
160- from = { from }
161- signalsIndex = { signalIndexName ?? '' }
162- to = { to }
163- />
164- </ >
165- </ >
166- ) }
167- </ GlobalTime >
168- </ WrapperPage >
169- </ StickyContainer >
170- ) : (
171- < WrapperPage >
172- < DetectionEngineHeaderPage border title = { i18n . PAGE_TITLE } />
173- < DetectionEngineEmptyPage />
174- </ WrapperPage >
175- ) ;
176- } }
177- </ WithSource >
134+ < GlobalTime >
135+ { ( { to, from, deleteQuery, setQuery } ) => (
136+ < >
137+ < >
138+ < AlertsHistogramPanel
139+ deleteQuery = { deleteQuery }
140+ filters = { filters }
141+ from = { from }
142+ query = { query }
143+ setQuery = { setQuery }
144+ showTotalAlertsCount = { true }
145+ signalIndexName = { signalIndexName }
146+ stackByOptions = { alertsHistogramOptions }
147+ to = { to }
148+ updateDateRange = { updateDateRangeCallback }
149+ />
150+ < EuiSpacer size = "l" />
151+ < AlertsTable
152+ timelineId = { TimelineId . alertsPage }
153+ loading = { loading }
154+ hasIndexWrite = { hasIndexWrite ?? false }
155+ canUserCRUD = { ( canUserCRUD ?? false ) && ( hasEncryptionKey ?? false ) }
156+ from = { from }
157+ signalsIndex = { signalIndexName ?? '' }
158+ to = { to }
159+ />
160+ </ >
161+ </ >
162+ ) }
163+ </ GlobalTime >
164+ </ WrapperPage >
165+ </ StickyContainer >
166+ ) : (
167+ < WrapperPage >
168+ < DetectionEngineHeaderPage border title = { i18n . PAGE_TITLE } />
169+ < DetectionEngineEmptyPage />
170+ </ WrapperPage >
171+ ) }
178172 < SpyRoute pageName = { SecurityPageName . alerts } />
179173 </ >
180174 ) ;
0 commit comments