diff --git a/x-pack/plugins/security_solution/public/management/pages/policy/view/policy_settings_layout/policy_settings_layout.tsx b/x-pack/plugins/security_solution/public/management/pages/policy/view/policy_settings_layout/policy_settings_layout.tsx index 3ee9506e6ad44..1a3a62c1e2ebf 100644 --- a/x-pack/plugins/security_solution/public/management/pages/policy/view/policy_settings_layout/policy_settings_layout.tsx +++ b/x-pack/plugins/security_solution/public/management/pages/policy/view/policy_settings_layout/policy_settings_layout.tsx @@ -7,6 +7,7 @@ import React, { memo, useCallback, useEffect, useMemo, useState } from 'react'; import { useLocation } from 'react-router-dom'; +import { useDispatch } from 'react-redux'; import type { ApplicationStart } from '@kbn/core-application-browser'; import { FormattedMessage } from '@kbn/i18n-react'; import { EuiButton, EuiButtonEmpty, EuiFlexGroup, EuiFlexItem, EuiSpacer } from '@elastic/eui'; @@ -42,6 +43,7 @@ export const PolicySettingsLayout = memo(({ policy: _ }, } = useKibana(); const toasts = useToasts(); + const dispatch = useDispatch(); const { state: locationRouteState } = useLocation(); const { canWritePolicyManagement } = useUserPrivileges().endpointPrivileges; const { isLoading: isUpdating, mutateAsync: sendPolicyUpdate } = useUpdateEndpointPolicy(); @@ -89,7 +91,7 @@ export const PolicySettingsLayout = memo(({ policy: _ update.inputs[0].config.policy.value = policySettings; sendPolicyUpdate({ policy: update }) - .then(() => { + .then(({ item: policyItem }) => { toasts.addSuccess({ 'data-test-subj': 'policyDetailsSuccessMessage', title: i18n.translate( @@ -109,6 +111,14 @@ export const PolicySettingsLayout = memo(({ policy: _ if (routeState && routeState.onSaveNavigateTo) { navigateToApp(...routeState.onSaveNavigateTo); + } else { + // Since the 'policyItem' is stored in a store and fetched as a result of an action on urlChange, we still need to dispatch an action even though Redux was removed from this component. + dispatch({ + type: 'serverReturnedPolicyDetailsData', + payload: { + policyItem, + }, + }); } }) .catch((err) => { @@ -123,6 +133,7 @@ export const PolicySettingsLayout = memo(({ policy: _ handleSaveCancel(); }, [ + dispatch, handleSaveCancel, navigateToApp, policy,