diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_delete_provider.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_delete_provider.tsx index 5a1ca420a6227..c80a257c93bcd 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_delete_provider.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_delete_provider.tsx @@ -10,8 +10,16 @@ import { EuiConfirmModal, EuiCallOut } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n-react'; +import { useHistory } from 'react-router-dom'; + import { AGENTS_PREFIX } from '../../../constants'; -import { sendDeleteAgentPolicy, useStartServices, useConfig, sendRequest } from '../../../hooks'; +import { + sendDeleteAgentPolicy, + useStartServices, + useConfig, + sendRequest, + useLink, +} from '../../../hooks'; import { API_VERSIONS } from '../../../../../../common/constants'; interface Props { @@ -37,6 +45,8 @@ export const AgentPolicyDeleteProvider: React.FunctionComponent = ({ const [agentsCount, setAgentsCount] = useState(0); const [isLoading, setIsLoading] = useState(false); const onSuccessCallback = useRef(null); + const { getPath } = useLink(); + const history = useHistory(); const deleteAgentPolicyPrompt: DeleteAgentPolicy = ( agentPolicyToDelete, @@ -92,6 +102,7 @@ export const AgentPolicyDeleteProvider: React.FunctionComponent = ({ ); } closeModal(); + history.push(getPath('policies_list')); }; const fetchAgentsCount = async (agentPolicyToCheck: string) => {