forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Fleet] Create shared package policy (elastic#185916)
## Summary Closes elastic/ingest-dev#3263 Added multi-select agent policy component to Add integration policy page. ## Steps to verify To verify: - Enable feature flag by adding `xpack.fleet.enableExperimental: ['enableReusableIntegrationPolicies']` to `kibana.dev.yml` locally - Create a few agent policies - Open Integrations UI, click on Add integration - Go to Existing hosts tab at the bottom - Verify that the agent policy selector support multiple selection - Verify that all selected agent policy ids are included in the API request (check with `Preview API Request` button) <img width="870" alt="image" src="https://github.com/elastic/kibana/assets/90178898/57649305-6be1-424d-a5be-08fabbfc475b"> ## Logstash output restriction There are a few scenarios where agent policy selection is restricted. - Add logstash output to one of the agent policies - Try to add APM integration policy - Verify that agent policy with logstash output is disabled - The new `EuiComboBox` component doesn't support a multiline custom option rendering, so added a warning icon with a tooltip instead. <img width="889" alt="image" src="https://github.com/elastic/kibana/assets/90178898/259463fa-9831-4bdc-a8b7-edfd8efbd18d"> Existing UI with `EuiSuperSelect`: <img width="781" alt="image" src="https://github.com/elastic/kibana/assets/90178898/67633284-9c89-4509-b80b-5710c7b22a63"> ## Limited packages restriction The other restrictions don't allow limited packages to be added twice to an agent policy: endpoint, osquery. Test by adding osquery_manager to one agent policy, and then try to add another integration policy to the same agent policy. It should be disabled. <img width="871" alt="image" src="https://github.com/elastic/kibana/assets/90178898/50035517-cbe5-439b-bd10-ca5a8f600ba8"> ## Agent policies used by agents The UI shows the sum of agents enrolled to the selected agent policies <img width="874" alt="image" src="https://github.com/elastic/kibana/assets/90178898/53cc760a-896a-4ae3-a588-86debff3af23"> The `Preview API Request` feature should keep the `policy_ids` list in sync when adding/removing agent policies. <img width="731" alt="image" src="https://github.com/elastic/kibana/assets/90178898/131bca40-70e3-44eb-9bbd-3563646bb597"> The confirmation modal should also show a sum of enrolled agents and list of selected agent policies. <img width="779" alt="image" src="https://github.com/elastic/kibana/assets/90178898/d6453006-18fd-463f-8ce4-cc18c142e265"> ### Checklist - [x] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md) - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios --------- Co-authored-by: Kyle Pollich <kpollich1@gmail.com>
- Loading branch information
1 parent
9b4bd89
commit 74738c0
Showing
21 changed files
with
688 additions
and
328 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
...licy/create_package_policy_page/components/steps/components/agent_policy_multi_select.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import type { EuiComboBoxOptionOption } from '@elastic/eui'; | ||
import { EuiComboBox } from '@elastic/eui'; | ||
|
||
import { i18n } from '@kbn/i18n'; | ||
|
||
import React, { useMemo } from 'react'; | ||
|
||
import type { PackageInfo } from '../../../../../../../../../common'; | ||
|
||
export interface Props { | ||
isLoading: boolean; | ||
agentPolicyMultiOptions: Array<EuiComboBoxOptionOption<string>>; | ||
selectedPolicyIds: string[]; | ||
setSelectedPolicyIds: (policyIds: string[]) => void; | ||
packageInfo?: PackageInfo; | ||
} | ||
|
||
export const AgentPolicyMultiSelect: React.FunctionComponent<Props> = ({ | ||
isLoading, | ||
agentPolicyMultiOptions, | ||
selectedPolicyIds, | ||
setSelectedPolicyIds, | ||
}) => { | ||
const selectedOptions = useMemo(() => { | ||
return agentPolicyMultiOptions.filter((option) => selectedPolicyIds.includes(option.key!)); | ||
}, [agentPolicyMultiOptions, selectedPolicyIds]); | ||
|
||
return ( | ||
<EuiComboBox | ||
aria-label="Select Multiple Agent Policies" | ||
data-test-subj="agentPolicyMultiSelect" | ||
placeholder={i18n.translate( | ||
'xpack.fleet.createPackagePolicy.StepSelectPolicy.agentPolicyMultiPlaceholderText', | ||
{ | ||
defaultMessage: 'Select agent policies to add this integration to', | ||
} | ||
)} | ||
options={agentPolicyMultiOptions} | ||
selectedOptions={selectedOptions} | ||
onChange={(newOptions) => { | ||
setSelectedPolicyIds(newOptions.map((option: any) => option.key)); | ||
}} | ||
isClearable={true} | ||
isLoading={isLoading} | ||
/> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.