diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/edit_package_policy_page/index.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/edit_package_policy_page/index.tsx index acaf623afa330..89f3fa7b02065 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/edit_package_policy_page/index.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/edit_package_policy_page/index.tsx @@ -190,7 +190,7 @@ export const EditPackagePolicyForm = memo<{ }) : policyId ? getHref('policy_details', { policyId }) - : '/'; + : getHref('agent_list'); }, [from, getHref, packageInfo, policyId]); const successRedirectPath = useMemo(() => { return (from === 'package-edit' || from === 'upgrade-from-integrations-policy-list') && @@ -200,7 +200,7 @@ export const EditPackagePolicyForm = memo<{ }) : policyId ? getHref('policy_details', { policyId }) - : '/'; + : getHref('agent_list'); }, [from, getHref, packageInfo, policyId]); useHistoryBlock(isEdited); diff --git a/x-pack/plugins/fleet/public/components/package_policy_actions_menu.test.tsx b/x-pack/plugins/fleet/public/components/package_policy_actions_menu.test.tsx index e099092b4b863..ad241e4eb52cd 100644 --- a/x-pack/plugins/fleet/public/components/package_policy_actions_menu.test.tsx +++ b/x-pack/plugins/fleet/public/components/package_policy_actions_menu.test.tsx @@ -157,4 +157,17 @@ describe('PackagePolicyActionsMenu', () => { expect(utils.queryByText('Add agent')).toBeNull(); }); }); + + it('Should show Edit integration with correct href when agentPolicy is defined', async () => { + const agentPolicies = createMockAgentPolicies(); + const packagePolicy = createMockPackagePolicy(); + const { utils } = renderMenu({ agentPolicies, packagePolicy }); + await act(async () => { + const editButton = utils.getByTestId('PackagePolicyActionsEditItem'); + expect(editButton).toHaveAttribute( + 'href', + '/mock/app/fleet/policies/some-uuid1/edit-integration/some-uuid2' + ); + }); + }); }); diff --git a/x-pack/plugins/fleet/public/components/package_policy_actions_menu.tsx b/x-pack/plugins/fleet/public/components/package_policy_actions_menu.tsx index a8839e23a99f9..7dc525e862271 100644 --- a/x-pack/plugins/fleet/public/components/package_policy_actions_menu.tsx +++ b/x-pack/plugins/fleet/public/components/package_policy_actions_menu.tsx @@ -89,7 +89,8 @@ export const PackagePolicyActionsMenu: React.FunctionComponent<{ data-test-subj="PackagePolicyActionsEditItem" disabled={!canWriteIntegrationPolicies || !agentPolicy} icon="pencil" - href={`${getHref('integration_policy_edit', { + href={`${getHref('edit_integration', { + policyId: agentPolicy?.id ?? '', packagePolicyId: packagePolicy.id, })}${from ? `?from=${from}` : ''}`} key="packagePolicyEdit"