-
Notifications
You must be signed in to change notification settings - Fork 8.3k
/
page.tsx
45 lines (42 loc) · 1.69 KB
/
page.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import React, { useContext } from 'react';
import chrome from 'ui/chrome';
import { i18n } from '@kbn/i18n';
import { ColumnarPage } from '../../../components/page';
import { LoadingPage } from '../../../components/loading_page';
import { AnalysisPageProviders } from './page_providers';
import { AnalysisResultsContent } from './page_results_content';
import { AnalysisSetupContent } from './page_setup_content';
import { useLogAnalysisJobs } from '../../../containers/logs/log_analysis/log_analysis_jobs';
import { Source } from '../../../containers/source';
export const AnalysisPage = () => {
const { sourceId, source } = useContext(Source.Context);
const spaceId = chrome.getInjected('activeSpace').space.id;
const { isSetupRequired, isLoadingSetupStatus } = useLogAnalysisJobs({
indexPattern: source ? source.configuration.logAlias : '',
sourceId,
spaceId,
timeField: source ? source.configuration.fields.timestamp : '',
});
return (
<AnalysisPageProviders>
<ColumnarPage data-test-subj="infraLogsAnalysisPage">
{isLoadingSetupStatus ? (
<LoadingPage
message={i18n.translate('xpack.infra.logs.analysisPage.loadingMessage', {
defaultMessage: 'Checking status of analysis jobs...',
})}
/>
) : isSetupRequired ? (
<AnalysisSetupContent />
) : (
<AnalysisResultsContent />
)}
</ColumnarPage>
</AnalysisPageProviders>
);
};