Skip to content

Commit

Permalink
[8.15][Fleet] fix edit package policy navigation (#187463) (#189042)
Browse files Browse the repository at this point in the history
Backport #187463 to 8.15
  • Loading branch information
juliaElastic authored Jul 24, 2024
1 parent 5981eae commit f7f7b12
Showing 1 changed file with 15 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -184,24 +184,23 @@ export const EditPackagePolicyForm = memo<{
// if `from === 'edit'` then it links back to Policy Details
// if `from === 'package-edit'`, or `upgrade-from-integrations-policy-list` then it links back to the Integration Policy List
const cancelUrl = useMemo((): string => {
if (packageInfo && policyId) {
return from === 'package-edit'
? getHref('integration_details_policies', {
pkgkey: pkgKeyFromPackageInfo(packageInfo!),
})
: getHref('policy_details', { policyId });
}
return '/';
return from === 'package-edit' && packageInfo
? getHref('integration_details_policies', {
pkgkey: pkgKeyFromPackageInfo(packageInfo!),
})
: policyId
? getHref('policy_details', { policyId })
: '/';
}, [from, getHref, packageInfo, policyId]);
const successRedirectPath = useMemo(() => {
if (packageInfo && policyId) {
return from === 'package-edit' || from === 'upgrade-from-integrations-policy-list'
? getHref('integration_details_policies', {
pkgkey: pkgKeyFromPackageInfo(packageInfo!),
})
: getHref('policy_details', { policyId });
}
return '/';
return (from === 'package-edit' || from === 'upgrade-from-integrations-policy-list') &&
packageInfo
? getHref('integration_details_policies', {
pkgkey: pkgKeyFromPackageInfo(packageInfo!),
})
: policyId
? getHref('policy_details', { policyId })
: '/';
}, [from, getHref, packageInfo, policyId]);

useHistoryBlock(isEdited);
Expand Down

0 comments on commit f7f7b12

Please sign in to comment.