diff --git a/x-pack/plugins/fleet/cypress/e2e/agents/agentless.cy.ts b/x-pack/plugins/fleet/cypress/e2e/agents/agentless.cy.ts new file mode 100644 index 0000000000000..2003a9f165d3b --- /dev/null +++ b/x-pack/plugins/fleet/cypress/e2e/agents/agentless.cy.ts @@ -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'); + }); +}); diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/details_page/components/package_policies/package_policies_table.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/details_page/components/package_policies/package_policies_table.tsx index 83e18d77f2a06..3fe016d5e35f1 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/details_page/components/package_policies/package_policies_table.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/details_page/components/package_policies/package_policies_table.tsx @@ -400,45 +400,46 @@ export const PackagePoliciesTable: React.FunctionComponent = ({ }} {...rest} search={{ - toolsRight: agentPolicy.is_managed - ? [] - : [ - { - application.navigateToApp(INTEGRATIONS_PLUGIN_ID, { - path: pagePathGetters.integrations_all({})[1], - state: { forAgentPolicyId: agentPolicy.id }, - }); - }} - data-test-subj="addPackagePolicyButton" - tooltip={ - !canWriteIntegrationPolicies - ? { - content: missingSecurityConfiguration ? ( - - ) : ( - - ), - } - : undefined - } - > - - , - ], + toolsRight: + agentPolicy.is_managed || agentPolicy.supports_agentless + ? [] + : [ + { + application.navigateToApp(INTEGRATIONS_PLUGIN_ID, { + path: pagePathGetters.integrations_all({})[1], + state: { forAgentPolicyId: agentPolicy.id }, + }); + }} + data-test-subj="addPackagePolicyButton" + tooltip={ + !canWriteIntegrationPolicies + ? { + content: missingSecurityConfiguration ? ( + + ) : ( + + ), + } + : undefined + } + > + + , + ], box: { incremental: true, schema: true,