Skip to content

Commit

Permalink
[Fleet] fix edit package policy navigation (elastic#187463)
Browse files Browse the repository at this point in the history
## Summary

Closes elastic#187336

Fix navigating back to Integration policies list after
Cancelling/Submitting the Edit integration policy page.

See steps to verify in the linked issue.

<img width="1119" alt="image"
src="https://github.com/elastic/kibana/assets/90178898/f89028a6-ef71-4b25-aabc-4f80cb36214b">
<img width="1123" alt="image"
src="https://github.com/elastic/kibana/assets/90178898/e844344c-caff-45ee-9ce7-772ba672e328">
  • Loading branch information
juliaElastic authored Jul 4, 2024
1 parent 27d2808 commit d861456
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 d861456

Please sign in to comment.