From 95e796a88a023f17aa4e2ed326f6b11d8432af19 Mon Sep 17 00:00:00 2001 From: nixocio Date: Fri, 18 Jun 2021 13:54:37 -0400 Subject: [PATCH] Remove URL params when closing wizard Remove URL params when closing wizard See: https://github.com/ansible/awx/issues/10240 --- .../CredentialPlugins/CredentialPluginField.jsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/awx/ui_next/src/screens/Credential/shared/CredentialPlugins/CredentialPluginField.jsx b/awx/ui_next/src/screens/Credential/shared/CredentialPlugins/CredentialPluginField.jsx index caea121978..952eeb214a 100644 --- a/awx/ui_next/src/screens/Credential/shared/CredentialPlugins/CredentialPluginField.jsx +++ b/awx/ui_next/src/screens/Credential/shared/CredentialPlugins/CredentialPluginField.jsx @@ -1,6 +1,6 @@ import React, { useEffect, useState } from 'react'; import PropTypes from 'prop-types'; - +import { useLocation, useHistory } from 'react-router-dom'; import { t } from '@lingui/macro'; import { useField } from 'formik'; import { @@ -23,6 +23,8 @@ function CredentialPluginInput(props) { const [showPluginWizard, setShowPluginWizard] = useState(false); const [inputField, meta, helpers] = useField(`inputs.${fieldOptions.id}`); const [passwordPromptField] = useField(`passwordPrompts.${fieldOptions.id}`); + const location = useLocation(); + const history = useHistory(); const disableFieldAndButtons = !!passwordPromptField.value || @@ -32,6 +34,11 @@ function CredentialPluginInput(props) { meta.value === meta.initialValue ); + const handlePluginWizardClose = () => { + setShowPluginWizard(false); + history.push(location.pathname); + }; + return ( <> {inputField?.value?.credential ? ( @@ -73,7 +80,7 @@ function CredentialPluginInput(props) { initialValues={ typeof inputField.value === 'object' ? inputField.value : {} } - onClose={() => setShowPluginWizard(false)} + onClose={() => handlePluginWizardClose()} onSubmit={val => { val.touched = true; helpers.setValue(val);