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 6f835651e6dbf..934fee64b4043 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 @@ -238,6 +238,7 @@ export const PackagePoliciesTable: React.FunctionComponent = ({ return canWriteIntegrationPolicies ? ( { @@ -17,6 +18,7 @@ export const Policy = memo(() => { params: { packagePolicyId }, } = useRouteMatch<{ packagePolicyId: string }>(); + const { search } = useLocation(); const { data: packagePolicyData } = useGetOnePackagePolicyQuery(packagePolicyId); const extensionView = useUIExtension( @@ -24,10 +26,21 @@ export const Policy = memo(() => { 'package-policy-edit' ); + const qs = new URLSearchParams(search); + const fromQs = qs.get('from'); + + let from: EditPackagePolicyFrom | undefined; + + if (fromQs && fromQs === 'fleet-policy-list') { + from = 'edit'; + } else { + from = 'package-edit'; + } + return ( ); 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 24525ce709efd..e2f581d38d1db 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 @@ -24,12 +24,14 @@ export const PackagePolicyActionsMenu: React.FunctionComponent<{ showAddAgent?: boolean; defaultIsOpen?: boolean; upgradePackagePolicyHref?: string; + from?: 'fleet-policy-list' | undefined; }> = ({ agentPolicy, packagePolicy, showAddAgent, upgradePackagePolicyHref, defaultIsOpen = false, + from, }) => { const [isEnrollmentFlyoutOpen, setIsEnrollmentFlyoutOpen] = useState(false); const { getHref } = useLink(); @@ -80,9 +82,9 @@ export const PackagePolicyActionsMenu: React.FunctionComponent<{ data-test-subj="PackagePolicyActionsEditItem" disabled={!canWriteIntegrationPolicies || !agentPolicy} icon="pencil" - href={getHref('integration_policy_edit', { + href={`${getHref('integration_policy_edit', { packagePolicyId: packagePolicy.id, - })} + })}${from ? `?from=${from}` : ''}`} key="packagePolicyEdit" >