Skip to content

Commit 4bc7c59

Browse files
authored
[7.x] [Logs UI] Add missing ML capabilities checks (#72606) (#72905)
Backports the following commits to 7.x: - [Logs UI] Add missing ML capabilities checks (#72606)
1 parent cb1c763 commit 4bc7c59

20 files changed

+175
-94
lines changed

x-pack/plugins/infra/public/components/logging/log_analysis_job_status/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,3 @@
66

77
export * from './log_analysis_job_problem_indicator';
88
export * from './notices_section';
9-
export * from './recreate_job_button';

x-pack/plugins/infra/public/components/logging/log_analysis_job_status/job_configuration_outdated_callout.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@ import React from 'react';
1111
import { RecreateJobCallout } from './recreate_job_callout';
1212

1313
export const JobConfigurationOutdatedCallout: React.FC<{
14+
hasSetupCapabilities: boolean;
1415
moduleName: string;
1516
onRecreateMlJob: () => void;
16-
}> = ({ moduleName, onRecreateMlJob }) => (
17+
}> = ({ hasSetupCapabilities, moduleName, onRecreateMlJob }) => (
1718
<RecreateJobCallout
19+
hasSetupCapabilities={hasSetupCapabilities}
1820
title={i18n.translate('xpack.infra.logs.analysis.jobConfigurationOutdatedCalloutTitle', {
1921
defaultMessage: 'The {moduleName} ML job configuration is outdated',
2022
values: {

x-pack/plugins/infra/public/components/logging/log_analysis_job_status/job_definition_outdated_callout.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@ import React from 'react';
1111
import { RecreateJobCallout } from './recreate_job_callout';
1212

1313
export const JobDefinitionOutdatedCallout: React.FC<{
14+
hasSetupCapabilities: boolean;
1415
moduleName: string;
1516
onRecreateMlJob: () => void;
16-
}> = ({ moduleName, onRecreateMlJob }) => (
17+
}> = ({ hasSetupCapabilities, moduleName, onRecreateMlJob }) => (
1718
<RecreateJobCallout
19+
hasSetupCapabilities={hasSetupCapabilities}
1820
title={i18n.translate('xpack.infra.logs.analysis.jobDefinitionOutdatedCalloutTitle', {
1921
defaultMessage: 'The {moduleName} ML job definition is outdated',
2022
values: {

x-pack/plugins/infra/public/components/logging/log_analysis_job_status/log_analysis_job_problem_indicator.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { FirstUseCallout } from '../log_analysis_results';
1414
export const LogAnalysisJobProblemIndicator: React.FC<{
1515
hasOutdatedJobConfigurations: boolean;
1616
hasOutdatedJobDefinitions: boolean;
17+
hasSetupCapabilities: boolean;
1718
hasStoppedJobs: boolean;
1819
isFirstUse: boolean;
1920
moduleName: string;
@@ -22,6 +23,7 @@ export const LogAnalysisJobProblemIndicator: React.FC<{
2223
}> = ({
2324
hasOutdatedJobConfigurations,
2425
hasOutdatedJobDefinitions,
26+
hasSetupCapabilities,
2527
hasStoppedJobs,
2628
isFirstUse,
2729
moduleName,
@@ -32,12 +34,14 @@ export const LogAnalysisJobProblemIndicator: React.FC<{
3234
<>
3335
{hasOutdatedJobDefinitions ? (
3436
<JobDefinitionOutdatedCallout
37+
hasSetupCapabilities={hasSetupCapabilities}
3538
moduleName={moduleName}
3639
onRecreateMlJob={onRecreateMlJobForUpdate}
3740
/>
3841
) : null}
3942
{hasOutdatedJobConfigurations ? (
4043
<JobConfigurationOutdatedCallout
44+
hasSetupCapabilities={hasSetupCapabilities}
4145
moduleName={moduleName}
4246
onRecreateMlJob={onRecreateMlJobForReconfiguration}
4347
/>

x-pack/plugins/infra/public/components/logging/log_analysis_job_status/notices_section.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { CategoryQualityWarnings } from './quality_warning_notices';
1212
export const CategoryJobNoticesSection: React.FC<{
1313
hasOutdatedJobConfigurations: boolean;
1414
hasOutdatedJobDefinitions: boolean;
15+
hasSetupCapabilities: boolean;
1516
hasStoppedJobs: boolean;
1617
isFirstUse: boolean;
1718
moduleName: string;
@@ -21,6 +22,7 @@ export const CategoryJobNoticesSection: React.FC<{
2122
}> = ({
2223
hasOutdatedJobConfigurations,
2324
hasOutdatedJobDefinitions,
25+
hasSetupCapabilities,
2426
hasStoppedJobs,
2527
isFirstUse,
2628
moduleName,
@@ -32,6 +34,7 @@ export const CategoryJobNoticesSection: React.FC<{
3234
<LogAnalysisJobProblemIndicator
3335
hasOutdatedJobConfigurations={hasOutdatedJobConfigurations}
3436
hasOutdatedJobDefinitions={hasOutdatedJobDefinitions}
37+
hasSetupCapabilities={hasSetupCapabilities}
3538
hasStoppedJobs={hasStoppedJobs}
3639
isFirstUse={isFirstUse}
3740
moduleName={moduleName}

x-pack/plugins/infra/public/components/logging/log_analysis_job_status/recreate_job_button.tsx

Lines changed: 0 additions & 18 deletions
This file was deleted.

x-pack/plugins/infra/public/components/logging/log_analysis_job_status/recreate_job_callout.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,21 @@
44
* you may not use this file except in compliance with the Elastic License.
55
*/
66

7-
import React from 'react';
87
import { EuiCallOut } from '@elastic/eui';
9-
10-
import { RecreateJobButton } from './recreate_job_button';
8+
import React from 'react';
9+
import { RecreateJobButton } from '../log_analysis_setup/create_job_button';
1110

1211
export const RecreateJobCallout: React.FC<{
12+
hasSetupCapabilities?: boolean;
1313
onRecreateMlJob: () => void;
1414
title?: React.ReactNode;
15-
}> = ({ children, onRecreateMlJob, title }) => (
15+
}> = ({ children, hasSetupCapabilities, onRecreateMlJob, title }) => (
1616
<EuiCallOut color="warning" iconType="alert" title={title}>
1717
<p>{children}</p>
18-
<RecreateJobButton color="warning" onClick={onRecreateMlJob} />
18+
<RecreateJobButton
19+
color="warning"
20+
hasSetupCapabilities={hasSetupCapabilities}
21+
onClick={onRecreateMlJob}
22+
/>
1923
</EuiCallOut>
2024
);
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License;
4+
* you may not use this file except in compliance with the Elastic License.
5+
*/
6+
7+
import { EuiButton, PropsOf } from '@elastic/eui';
8+
import { FormattedMessage } from '@kbn/i18n/react';
9+
import React from 'react';
10+
import { MissingSetupPrivilegesToolTip } from './missing_setup_privileges_tooltip';
11+
12+
export const CreateJobButton: React.FunctionComponent<
13+
{
14+
hasSetupCapabilities?: boolean;
15+
} & PropsOf<typeof EuiButton>
16+
> = ({ hasSetupCapabilities = true, children, ...buttonProps }) => {
17+
const button = (
18+
<EuiButton isDisabled={!hasSetupCapabilities} {...buttonProps}>
19+
{children ?? (
20+
<FormattedMessage
21+
id="xpack.infra.logs.analysis.createJobButtonLabel"
22+
defaultMessage="Create ML jobs"
23+
/>
24+
)}
25+
</EuiButton>
26+
);
27+
28+
return hasSetupCapabilities ? (
29+
button
30+
) : (
31+
<MissingSetupPrivilegesToolTip position="bottom" delay="regular">
32+
{button}
33+
</MissingSetupPrivilegesToolTip>
34+
);
35+
};
36+
37+
export const RecreateJobButton: React.FunctionComponent<PropsOf<typeof CreateJobButton>> = ({
38+
children,
39+
...otherProps
40+
}) => (
41+
<CreateJobButton {...otherProps}>
42+
{children ?? (
43+
<FormattedMessage
44+
id="xpack.infra.logs.analysis.recreateJobButtonLabel"
45+
defaultMessage="Recreate ML job"
46+
/>
47+
)}
48+
</CreateJobButton>
49+
);
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License;
4+
* you may not use this file except in compliance with the Elastic License.
5+
*/
6+
7+
import { i18n } from '@kbn/i18n';
8+
9+
export const missingMlPrivilegesTitle = i18n.translate(
10+
'xpack.infra.logs.analysis.missingMlPrivilegesTitle',
11+
{
12+
defaultMessage: 'Additional Machine Learning privileges required',
13+
}
14+
);
15+
16+
export const missingMlResultsPrivilegesDescription = i18n.translate(
17+
'xpack.infra.logs.analysis.missingMlResultsPrivilegesDescription',
18+
{
19+
defaultMessage:
20+
'This feature makes use of Machine Learning jobs, which require at least the read permission for the Machine Learning app in order to access their status and results.',
21+
}
22+
);
23+
24+
export const missingMlSetupPrivilegesDescription = i18n.translate(
25+
'xpack.infra.logs.analysis.missingMlSetupPrivilegesDescription',
26+
{
27+
defaultMessage:
28+
'This feature makes use of Machine Learning jobs, which require all permissions for the Machine Learning app in order to be set up.',
29+
}
30+
);

x-pack/plugins/infra/public/components/logging/log_analysis_setup/missing_results_privileges_prompt.tsx

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,34 +4,19 @@
44
* you may not use this file except in compliance with the Elastic License.
55
*/
66

7-
import { EuiEmptyPrompt, EuiCode } from '@elastic/eui';
8-
import { FormattedMessage } from '@kbn/i18n/react';
7+
import { EuiEmptyPrompt } from '@elastic/eui';
98
import React from 'react';
10-
119
import { euiStyled } from '../../../../../observability/public';
10+
import {
11+
missingMlPrivilegesTitle,
12+
missingMlResultsPrivilegesDescription,
13+
} from './missing_privileges_messages';
1214
import { UserManagementLink } from './user_management_link';
1315

1416
export const MissingResultsPrivilegesPrompt: React.FunctionComponent = () => (
1517
<EmptyPrompt
16-
title={
17-
<h2>
18-
<FormattedMessage
19-
id="xpack.infra.logs.analysis.missingMlResultsPrivilegesTitle"
20-
defaultMessage="Additional Machine Learning privileges required"
21-
/>
22-
</h2>
23-
}
24-
body={
25-
<p>
26-
<FormattedMessage
27-
id="xpack.infra.logs.analysis.missingMlResultsPrivilegesBody"
28-
defaultMessage="This feature makes use of Machine Learning jobs, which require at least the {machineLearningUserRole} role in order to access their status and results."
29-
values={{
30-
machineLearningUserRole: <EuiCode>machine_learning_user</EuiCode>,
31-
}}
32-
/>
33-
</p>
34-
}
18+
title={<h2>{missingMlPrivilegesTitle}</h2>}
19+
body={<p>{missingMlResultsPrivilegesDescription}</p>}
3520
actions={<UserManagementLink />}
3621
/>
3722
);

0 commit comments

Comments
 (0)