Skip to content

Commit

Permalink
[8.x] [Cloud Security] Remove `Add integration` button from…
Browse files Browse the repository at this point in the history
… agent policy details page when the agent policy `supports_agentless` (elastic#202211) (elastic#202363)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[Cloud Security] Remove `Add integration` button from agent
policy details page when the agent policy `supports_agentless`
(elastic#202211)](elastic#202211)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT
[{"author":{"name":"seanrathier","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-11-29T18:33:03Z","message":"[Cloud
Security] Remove `Add integration` button from agent policy details page
when the agent policy `supports_agentless`
(elastic#202211)","sha":"3520e696f424b964e9b2cc71dbfa8faab3e07e9c","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:Fleet","v9.0.0","Team:Cloud
Security","backport:prev-minor","8.18 candidate"],"title":"[Cloud
Security] Remove `Add integration` button from agent policy details page
when the agent policy
`supports_agentless`","number":202211,"url":"https://github.com/elastic/kibana/pull/202211","mergeCommit":{"message":"[Cloud
Security] Remove `Add integration` button from agent policy details page
when the agent policy `supports_agentless`
(elastic#202211)","sha":"3520e696f424b964e9b2cc71dbfa8faab3e07e9c"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/202211","number":202211,"mergeCommit":{"message":"[Cloud
Security] Remove `Add integration` button from agent policy details page
when the agent policy `supports_agentless`
(elastic#202211)","sha":"3520e696f424b964e9b2cc71dbfa8faab3e07e9c"}}]}]
BACKPORT-->

Co-authored-by: seanrathier <[email protected]>
  • Loading branch information
kibanamachine and seanrathier authored Nov 29, 2024
1 parent 058ff76 commit e6bfd79
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 39 deletions.
40 changes: 40 additions & 0 deletions x-pack/plugins/fleet/cypress/e2e/agents/agentless.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* 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 { ADD_PACKAGE_POLICY_BTN } from '../../screens/fleet';
import { login } from '../../tasks/login';

describe('View agentless policy details', () => {
beforeEach(() => {
login();
cy.intercept('/api/fleet/agent_policies/policy-1', {
item: {
id: 'policy-1',
name: 'Agentless policy for cspm-1',
description: '',
namespace: 'default',
monitoring_enabled: ['logs', 'metrics'],
status: 'active',
supports_agentless: true,
package_policies: [
{
id: 'cspm-1',
name: 'cspm-1',
policy_id: 'policy-1',
policy_ids: ['policy-1'],
inputs: [],
},
],
},
});
});

it('should not show the add integration button if the policy support agentless', () => {
cy.visit('/app/fleet/policies/policy-1');
cy.getBySel(ADD_PACKAGE_POLICY_BTN).should('not.exist');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -400,45 +400,46 @@ export const PackagePoliciesTable: React.FunctionComponent<Props> = ({
}}
{...rest}
search={{
toolsRight: agentPolicy.is_managed
? []
: [
<EuiButtonWithTooltip
key="addPackagePolicyButton"
fill
isDisabled={!canWriteIntegrationPolicies}
iconType="plusInCircle"
onClick={() => {
application.navigateToApp(INTEGRATIONS_PLUGIN_ID, {
path: pagePathGetters.integrations_all({})[1],
state: { forAgentPolicyId: agentPolicy.id },
});
}}
data-test-subj="addPackagePolicyButton"
tooltip={
!canWriteIntegrationPolicies
? {
content: missingSecurityConfiguration ? (
<FormattedMessage
id="xpack.fleet.epm.addPackagePolicyButtonSecurityRequiredTooltip"
defaultMessage="To add Elastic Agent Integrations, you must have security enabled and have the All privilege for Fleet. Contact your administrator."
/>
) : (
<FormattedMessage
id="xpack.fleet.epm.addPackagePolicyButtonPrivilegesRequiredTooltip"
defaultMessage="Elastic Agent Integrations require the All privilege for Agent policies and All privilege for Integrations. Contact your administrator."
/>
),
}
: undefined
}
>
<FormattedMessage
id="xpack.fleet.policyDetails.addPackagePolicyButtonText"
defaultMessage="Add integration"
/>
</EuiButtonWithTooltip>,
],
toolsRight:
agentPolicy.is_managed || agentPolicy.supports_agentless
? []
: [
<EuiButtonWithTooltip
key="addPackagePolicyButton"
fill
isDisabled={!canWriteIntegrationPolicies}
iconType="plusInCircle"
onClick={() => {
application.navigateToApp(INTEGRATIONS_PLUGIN_ID, {
path: pagePathGetters.integrations_all({})[1],
state: { forAgentPolicyId: agentPolicy.id },
});
}}
data-test-subj="addPackagePolicyButton"
tooltip={
!canWriteIntegrationPolicies
? {
content: missingSecurityConfiguration ? (
<FormattedMessage
id="xpack.fleet.epm.addPackagePolicyButtonSecurityRequiredTooltip"
defaultMessage="To add Elastic Agent Integrations, you must have security enabled and have the All privilege for Fleet. Contact your administrator."
/>
) : (
<FormattedMessage
id="xpack.fleet.epm.addPackagePolicyButtonPrivilegesRequiredTooltip"
defaultMessage="Elastic Agent Integrations require the All privilege for Agent policies and All privilege for Integrations. Contact your administrator."
/>
),
}
: undefined
}
>
<FormattedMessage
id="xpack.fleet.policyDetails.addPackagePolicyButtonText"
defaultMessage="Add integration"
/>
</EuiButtonWithTooltip>,
],
box: {
incremental: true,
schema: true,
Expand Down

0 comments on commit e6bfd79

Please sign in to comment.