Skip to content

Commit 46ff0d8

Browse files
committed
Remove endpoint specific logic from fleet and move it to UI extension
1 parent bb1ca9b commit 46ff0d8

File tree

2 files changed

+22
-13
lines changed

2 files changed

+22
-13
lines changed

x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/step_define_package_policy.tsx

+6-11
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,12 @@ export const StepDefinePackagePolicy: React.FunctionComponent<{
4747
.sort();
4848

4949
updatePackagePolicy({
50-
name:
51-
// For Endpoint packages, the user must fill in the name, thus we don't attempt to generate
52-
// a default one here.
53-
// FIXME: Improve package policies name uniqueness - https://github.com/elastic/kibana/issues/72948
54-
packageInfo.name !== 'endpoint'
55-
? `${packageInfo.name}-${
56-
pkgPoliciesWithMatchingNames.length
57-
? pkgPoliciesWithMatchingNames[pkgPoliciesWithMatchingNames.length - 1] + 1
58-
: 1
59-
}`
60-
: '',
50+
// FIXME: Improve package policies name uniqueness - https://github.com/elastic/kibana/issues/72948
51+
name: `${packageInfo.name}-${
52+
pkgPoliciesWithMatchingNames.length
53+
? pkgPoliciesWithMatchingNames[pkgPoliciesWithMatchingNames.length - 1] + 1
54+
: 1
55+
}`,
6156
package: {
6257
name: packageInfo.name,
6358
title: packageInfo.title,

x-pack/plugins/security_solution/public/management/pages/policy/view/ingest_manager_integration/endpoint_policy_create_extension.tsx

+16-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* you may not use this file except in compliance with the Elastic License.
55
*/
66

7-
import React, { memo } from 'react';
7+
import React, { memo, useEffect } from 'react';
88
import { EuiCallOut, EuiSpacer, EuiText } from '@elastic/eui';
99
import { FormattedMessage } from '@kbn/i18n/react';
1010
import { PackagePolicyCreateExtensionComponentProps } from '../../../../../../../fleet/public';
@@ -14,7 +14,21 @@ import { PackagePolicyCreateExtensionComponentProps } from '../../../../../../..
1414
* for use in the Ingest app create / edit package policy
1515
*/
1616
export const EndpointPolicyCreateExtension = memo<PackagePolicyCreateExtensionComponentProps>(
17-
() => {
17+
({ newPolicy, onChange }) => {
18+
// Fleet will initialize the create form with a default name for the integratin policy, however,
19+
// for endpoint security, we want the user to explicitely type in a name, so we blank it out
20+
// only during 1st component render (thus why the eslint disabled rule below).
21+
useEffect(() => {
22+
onChange({
23+
isValid: false,
24+
updatedPolicy: {
25+
...newPolicy,
26+
name: '',
27+
},
28+
});
29+
// eslint-disable-next-line react-hooks/exhaustive-deps
30+
}, []);
31+
1832
return (
1933
<>
2034
<EuiSpacer size="m" />

0 commit comments

Comments
 (0)