-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Fleet] Make default integration install explicit #121628
Merged
juliaElastic
merged 119 commits into
elastic:main
from
juliaElastic:feat-remove-default-pkgs
Feb 1, 2022
Merged
Changes from 3 commits
Commits
Show all changes
119 commits
Select commit
Hold shift + click to select a range
fd1deba
first draft
juliaElastic 666cb42
Merge branch 'main' into feat-remove-default-pkgs
juliaElastic 4312eac
added new text with badge
juliaElastic 5f7ee9a
updated labels
juliaElastic d80039a
added tabs
juliaElastic 8ccfe99
fix checks
juliaElastic 8249dd4
ignore tests
juliaElastic 5c28e7b
fix i18n
juliaElastic d187ff9
Merge branch 'main' into feat-remove-default-pkgs
juliaElastic 23de22c
use max instead of sort
juliaElastic a453c20
Add agent and Fleet server policy
juliaElastic be86eb5
fix bug with monitoring checkbox
juliaElastic 0eca9f6
fix test
juliaElastic b0d476f
skip test
juliaElastic fef2032
fixed validation
juliaElastic 1264ffc
fixed fleet server policy install and missing enrollment keys
juliaElastic 3bafb80
fixed test
juliaElastic d9611bf
fixed test
juliaElastic 9383a7d
cypress tests
juliaElastic a0dc73b
Merge branch 'main' into feat-remove-default-pkgs
kibanamachine 9f18b8f
fix test
juliaElastic 2ae5d47
Merge branch 'feat-remove-default-pkgs' of https://github.com/juliaEl…
juliaElastic 8728d1e
added is_default, fixed test
juliaElastic 8833d02
Merge branch 'main' into feat-remove-default-pkgs
kibanamachine c9fd581
fix cypress
juliaElastic b4f12b5
cypress fix
juliaElastic 2d7cbdf
added missing link
juliaElastic 6176a4a
removed is_default, default from naming
juliaElastic 01ad43c
fix tests
juliaElastic 7d9fa31
revert osquery change
juliaElastic 854d2ad
changes in cypress fleet server start
juliaElastic c04eba2
fix fleet enroll and cypress
juliaElastic 92bae14
Merge branch 'main' into feat-remove-default-pkgs
kibanamachine 95faa50
fixed add agent flyout when fleet agent unenrolled
juliaElastic a742327
fix tests
juliaElastic 6078869
existing hosts no policy selected when more than one
juliaElastic 3ff1f80
updated openapi spec
juliaElastic 1f03ecd
refactor and unit test for increment policy name
juliaElastic 3d34f05
fix checks
juliaElastic d75d554
fix jest
juliaElastic 5ba4f3a
Merge branch 'main' into feat-remove-default-pkgs
kibanamachine d25eb2a
fix tests
juliaElastic eb3ca36
using fleet-server-policy id for first
juliaElastic cb87b56
fixed refresh after policy created, removed toast
juliaElastic 633693d
fixed smaller review comments
juliaElastic a7aa263
added missing catch
juliaElastic 5ac31c1
changed to bulk install
juliaElastic 95b7dfb
moved service logic from handler, measuring time in cypress
juliaElastic fb73010
fcypress comment out fleet server enroll
juliaElastic 89a1d6b
cypress fix
juliaElastic b2beb39
cypress fix
juliaElastic c4a81ab
changed toast to callout
juliaElastic 45e6994
changed toast to callout
juliaElastic 52edebc
removed label
juliaElastic cdcbef9
fix checks, added more tests
juliaElastic 63eff1b
fix test
juliaElastic ea3e3ba
Merge branch 'main' into feat-remove-default-pkgs
juliaElastic 50bd3a0
fix checks
juliaElastic 8a5aea2
added more cypress asserts
juliaElastic e90f55f
fix checks
juliaElastic 343e5c2
refactored agent policy create and select
juliaElastic 6cfbab2
update label
juliaElastic ec66136
fix checks, hide badges for fleet server policy
juliaElastic 2bb3c89
added back is_default flags
juliaElastic 0e5750f
added fleet server specific confirm message to delete policy modal
juliaElastic 02be154
added unit tests for agent_policy_create logic
juliaElastic c027024
Merge branch 'main' into feat-remove-default-pkgs
juliaElastic d1c5539
fixed condition to show fleet server instructions
juliaElastic 41a4c4d
fixed tests
juliaElastic 5d318ad
fixed jumping
juliaElastic fdf9919
fixed bug where add integration stayed invalid when going back to new…
juliaElastic d08c0fc
fix tests
juliaElastic 39e1edf
Merge branch 'main' into feat-remove-default-pkgs
juliaElastic f4ed727
fix tests
juliaElastic e39794a
show invalid if policy not selected
juliaElastic 1b3e5e9
resolved conflict
juliaElastic d1f67a2
add missing texts
juliaElastic a0fdb13
fix radio groups when fleet server instructions are rendered twice
juliaElastic cf2444c
fix test, fixed bug where fleet server policy was not filtered out
juliaElastic 34caedd
fixed add integration from agent policy
juliaElastic 8bae9a5
fixed add integration to agent policy navigation
juliaElastic 5eec441
Merge branch 'main' into feat-remove-default-pkgs
kibanamachine 601d0ec
fixed cypress
juliaElastic 3d9c044
added cypress test for policy add integration
juliaElastic 5e102e9
added cypress test for upgrade integration without policy and upgrade…
juliaElastic 0d23701
added unit test for policy select empty default
juliaElastic 643d4aa
added cypress test for update outputs, settings
juliaElastic 1ca8d91
added cypress test for update agent policy
juliaElastic cbebb62
added cypress test for update package policy
juliaElastic 0767d35
added cypress test for install package without policy
juliaElastic 12dca7d
fix checks and test
juliaElastic ee7baa8
removed create link from existing hosts tab
juliaElastic 969fb95
Merge branch 'main' into feat-remove-default-pkgs
kibanamachine 979d374
fixed checks
juliaElastic b3a3fb1
updated deprecation, throw error and rollback if package policy failed
juliaElastic f579d32
Merge branch 'main' into feat-remove-default-pkgs
juliaElastic 2faa013
fix formatting
juliaElastic f676146
fix test
juliaElastic eccf4b7
documented dependent projects
juliaElastic 1152cd6
Merge branch 'main' into feat-remove-default-pkgs
kibanamachine 5219ea1
cypress speed up
juliaElastic 520aba7
added back integration uninstall
juliaElastic 986f4f8
cypress further speed up
juliaElastic 33fd898
fix checks
juliaElastic 5b6e72d
resolve conflicts with main
juliaElastic ffc1597
Update x-pack/plugins/fleet/public/components/agent_enrollment_flyout…
juliaElastic 2f9f7e8
review fixes
juliaElastic e82240c
aria label and onSubmit refactor
juliaElastic 62c5f23
agent policy validation test
juliaElastic f2c373a
renamed to getFleetServerAgentPolicyId
juliaElastic fd62227
Merge branch 'main' into feat-remove-default-pkgs
kibanamachine 68bd12a
fixed cypress test
juliaElastic 9d42aec
Merge branch 'main' into feat-remove-default-pkgs
kibanamachine ac8a0ff
Merge branch 'main' into feat-remove-default-pkgs
kibanamachine 247c279
fixed package policy error message condition
juliaElastic 809d192
Merge branch 'main' into feat-remove-default-pkgs
juliaElastic ce5de0c
fixed import
juliaElastic 511c236
fixed authz
juliaElastic a8ed804
fix cypress
juliaElastic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
327 changes: 327 additions & 0 deletions
327
...blic/applications/fleet/sections/agent_policy/components/agent_policy_advanced_fields.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,327 @@ | ||
/* | ||
* 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 React, { useState } from 'react'; | ||
import { | ||
EuiDescribedFormGroup, | ||
EuiFormRow, | ||
EuiSpacer, | ||
EuiText, | ||
EuiComboBox, | ||
EuiIconTip, | ||
EuiCheckboxGroup, | ||
EuiButton, | ||
EuiLink, | ||
EuiFieldNumber, | ||
EuiFieldText, | ||
} from '@elastic/eui'; | ||
import { FormattedMessage } from '@kbn/i18n-react'; | ||
import { i18n } from '@kbn/i18n'; | ||
|
||
import { dataTypes } from '../../../../../../common'; | ||
import type { NewAgentPolicy, AgentPolicy } from '../../../types'; | ||
import { useStartServices } from '../../../hooks'; | ||
|
||
import { AgentPolicyPackageBadge } from '../../../components'; | ||
|
||
import { AgentPolicyDeleteProvider } from './agent_policy_delete_provider'; | ||
import type { ValidationResults } from './agent_policy_validation'; | ||
|
||
interface Props { | ||
agentPolicy: Partial<NewAgentPolicy | AgentPolicy>; | ||
updateAgentPolicy: (u: Partial<NewAgentPolicy | AgentPolicy>) => void; | ||
validation: ValidationResults; | ||
isEditing?: boolean; | ||
onDelete?: () => void; | ||
} | ||
|
||
export const AgentPolicyAdvancedOptionsContent: React.FunctionComponent<Props> = ({ | ||
agentPolicy, | ||
updateAgentPolicy, | ||
validation, | ||
isEditing = false, | ||
onDelete = () => {}, | ||
}) => { | ||
const { docLinks } = useStartServices(); | ||
const [touchedFields, setTouchedFields] = useState<{ [key: string]: boolean }>({}); | ||
|
||
return ( | ||
<> | ||
<EuiDescribedFormGroup | ||
title={ | ||
<h4> | ||
<FormattedMessage | ||
id="xpack.fleet.agentPolicyForm.descriptionFieldLabel" | ||
defaultMessage="Description" | ||
/> | ||
</h4> | ||
} | ||
description={ | ||
<FormattedMessage | ||
id="xpack.fleet.agentPolicyForm.descriptionDescription" | ||
defaultMessage="Add a description of how this policy will be used." | ||
/> | ||
} | ||
> | ||
<EuiFormRow | ||
fullWidth | ||
key="description" | ||
error={ | ||
touchedFields.description && validation.description ? validation.description : null | ||
} | ||
isInvalid={Boolean(touchedFields.description && validation.description)} | ||
> | ||
<EuiFieldText | ||
disabled={agentPolicy.is_managed === true} | ||
fullWidth | ||
value={agentPolicy.description} | ||
onChange={(e) => updateAgentPolicy({ description: e.target.value })} | ||
isInvalid={Boolean(touchedFields.description && validation.description)} | ||
onBlur={() => setTouchedFields({ ...touchedFields, description: true })} | ||
placeholder={i18n.translate('xpack.fleet.agentPolicyForm.descriptionFieldPlaceholder', { | ||
defaultMessage: 'Optional description', | ||
})} | ||
/> | ||
</EuiFormRow> | ||
</EuiDescribedFormGroup> | ||
<EuiDescribedFormGroup | ||
title={ | ||
<h4> | ||
<FormattedMessage | ||
id="xpack.fleet.agentPolicyForm.namespaceFieldLabel" | ||
defaultMessage="Default namespace" | ||
/> | ||
</h4> | ||
} | ||
description={ | ||
<FormattedMessage | ||
id="xpack.fleet.agentPolicyForm.namespaceFieldDescription" | ||
defaultMessage="Namespaces are a user-configurable arbitrary grouping that makes it easier to search for data and manage user permissions. A policy namespace is used to name its integration's data streams. {fleetUserGuide}." | ||
values={{ | ||
fleetUserGuide: ( | ||
<EuiLink href={docLinks.links.fleet.datastreamsNamingScheme} target="_blank"> | ||
{i18n.translate( | ||
'xpack.fleet.agentPolicyForm.nameSpaceFieldDescription.fleetUserGuideLabel', | ||
{ defaultMessage: 'Learn more' } | ||
)} | ||
</EuiLink> | ||
), | ||
}} | ||
/> | ||
} | ||
> | ||
<EuiFormRow | ||
fullWidth | ||
error={touchedFields.namespace && validation.namespace ? validation.namespace : null} | ||
isInvalid={Boolean(touchedFields.namespace && validation.namespace)} | ||
> | ||
<EuiComboBox | ||
fullWidth | ||
singleSelection | ||
noSuggestions | ||
selectedOptions={agentPolicy.namespace ? [{ label: agentPolicy.namespace }] : []} | ||
onCreateOption={(value: string) => { | ||
updateAgentPolicy({ namespace: value }); | ||
}} | ||
onChange={(selectedOptions) => { | ||
updateAgentPolicy({ | ||
namespace: (selectedOptions.length ? selectedOptions[0] : '') as string, | ||
}); | ||
}} | ||
isInvalid={Boolean(touchedFields.namespace && validation.namespace)} | ||
onBlur={() => setTouchedFields({ ...touchedFields, namespace: true })} | ||
/> | ||
</EuiFormRow> | ||
</EuiDescribedFormGroup> | ||
<EuiDescribedFormGroup | ||
title={ | ||
<h4> | ||
<FormattedMessage | ||
id="xpack.fleet.agentPolicyForm.monitoringLabel" | ||
defaultMessage="Agent monitoring" | ||
/> | ||
</h4> | ||
} | ||
description={ | ||
<FormattedMessage | ||
id="xpack.fleet.agentPolicyForm.monitoringDescription" | ||
defaultMessage="Collecting monitoring logs and metrics will also create an {agent} integration. Monitoring data will be written to the default namespace specified above." | ||
values={{ | ||
agent: ( | ||
<AgentPolicyPackageBadge pkgName={'elastic_agent'} pkgTitle={'Elastic Agent'} /> | ||
), | ||
}} | ||
/> | ||
} | ||
> | ||
<EuiCheckboxGroup | ||
disabled={agentPolicy.is_managed === true} | ||
options={[ | ||
{ | ||
id: dataTypes.Logs, | ||
label: ( | ||
<> | ||
<FormattedMessage | ||
id="xpack.fleet.agentPolicyForm.monitoringLogsFieldLabel" | ||
defaultMessage="Collect agent logs" | ||
/>{' '} | ||
<EuiIconTip | ||
content={i18n.translate( | ||
'xpack.fleet.agentPolicyForm.monitoringLogsTooltipText', | ||
{ | ||
defaultMessage: 'Collect logs from Elastic Agents that use this policy.', | ||
} | ||
)} | ||
position="right" | ||
type="iInCircle" | ||
color="subdued" | ||
/> | ||
</> | ||
), | ||
}, | ||
{ | ||
id: dataTypes.Metrics, | ||
label: ( | ||
<> | ||
<FormattedMessage | ||
id="xpack.fleet.agentPolicyForm.monitoringMetricsFieldLabel" | ||
defaultMessage="Collect agent metrics" | ||
/>{' '} | ||
<EuiIconTip | ||
content={i18n.translate( | ||
'xpack.fleet.agentPolicyForm.monitoringMetricsTooltipText', | ||
{ | ||
defaultMessage: 'Collect metrics from Elastic Agents that use this policy.', | ||
} | ||
)} | ||
position="right" | ||
type="iInCircle" | ||
color="subdued" | ||
/> | ||
</> | ||
), | ||
}, | ||
]} | ||
idToSelectedMap={(agentPolicy.monitoring_enabled || []).reduce( | ||
(acc: { logs: boolean; metrics: boolean }, key) => { | ||
acc[key] = true; | ||
return acc; | ||
}, | ||
{ logs: false, metrics: false } | ||
)} | ||
onChange={(id) => { | ||
if (id !== dataTypes.Logs && id !== dataTypes.Metrics) { | ||
return; | ||
} | ||
|
||
const hasLogs = | ||
agentPolicy.monitoring_enabled && agentPolicy.monitoring_enabled.indexOf(id) >= 0; | ||
|
||
const previousValues = agentPolicy.monitoring_enabled || []; | ||
updateAgentPolicy({ | ||
monitoring_enabled: hasLogs | ||
? previousValues.filter((type) => type !== id) | ||
: [...previousValues, id], | ||
}); | ||
}} | ||
/> | ||
</EuiDescribedFormGroup> | ||
<EuiDescribedFormGroup | ||
title={ | ||
<h4> | ||
<FormattedMessage | ||
id="xpack.fleet.agentPolicyForm.unenrollmentTimeoutLabel" | ||
defaultMessage="Unenrollment timeout" | ||
/> | ||
</h4> | ||
} | ||
description={ | ||
<FormattedMessage | ||
id="xpack.fleet.agentPolicyForm.unenrollmentTimeoutDescription" | ||
defaultMessage="An optional timeout in seconds. If provided, an agent will automatically unenroll after being gone for this period of time." | ||
/> | ||
} | ||
> | ||
<EuiFormRow | ||
fullWidth | ||
error={ | ||
touchedFields.unenroll_timeout && validation.unenroll_timeout | ||
? validation.unenroll_timeout | ||
: null | ||
} | ||
isInvalid={Boolean(touchedFields.unenroll_timeout && validation.unenroll_timeout)} | ||
> | ||
<EuiFieldNumber | ||
fullWidth | ||
disabled={agentPolicy.is_managed === true} | ||
value={agentPolicy.unenroll_timeout || ''} | ||
min={0} | ||
onChange={(e) => { | ||
updateAgentPolicy({ | ||
unenroll_timeout: e.target.value ? Number(e.target.value) : 0, | ||
}); | ||
}} | ||
isInvalid={Boolean(touchedFields.unenroll_timeout && validation.unenroll_timeout)} | ||
onBlur={() => setTouchedFields({ ...touchedFields, unenroll_timeout: true })} | ||
/> | ||
</EuiFormRow> | ||
</EuiDescribedFormGroup> | ||
{isEditing && | ||
'id' in agentPolicy && | ||
!agentPolicy.is_managed && | ||
!agentPolicy.is_default && | ||
!agentPolicy.is_default_fleet_server ? ( | ||
<EuiDescribedFormGroup | ||
title={ | ||
<h4> | ||
<FormattedMessage | ||
id="xpack.fleet.policyForm.deletePolicyGroupTitle" | ||
defaultMessage="Delete policy" | ||
/> | ||
</h4> | ||
} | ||
description={ | ||
<> | ||
<FormattedMessage | ||
id="xpack.fleet.policyForm.deletePolicyGroupDescription" | ||
defaultMessage="Existing data will not be deleted." | ||
/> | ||
<EuiSpacer size="s" /> | ||
<AgentPolicyDeleteProvider> | ||
{(deleteAgentPolicyPrompt) => { | ||
return ( | ||
<EuiButton | ||
color="danger" | ||
disabled={Boolean(agentPolicy.is_default)} | ||
onClick={() => deleteAgentPolicyPrompt(agentPolicy.id!, onDelete)} | ||
> | ||
<FormattedMessage | ||
id="xpack.fleet.policyForm.deletePolicyActionText" | ||
defaultMessage="Delete policy" | ||
/> | ||
</EuiButton> | ||
); | ||
}} | ||
</AgentPolicyDeleteProvider> | ||
{agentPolicy.is_default ? ( | ||
<> | ||
<EuiSpacer size="xs" /> | ||
<EuiText color="subdued" size="xs"> | ||
<FormattedMessage | ||
id="xpack.fleet.policyForm.unableToDeleteDefaultPolicyText" | ||
defaultMessage="Default policy cannot be deleted" | ||
/> | ||
</EuiText> | ||
</> | ||
) : null} | ||
</> | ||
} | ||
/> | ||
) : null} | ||
</> | ||
); | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
currently displaying a generic badge. in order to display the package's real badge, I would need to know the latest version number, which seems overkill