Remove URL params when closing wizard

Remove URL params when closing wizard

See: https://github.com/ansible/awx/issues/10240
This commit is contained in:
nixocio 2021-06-18 13:54:37 -04:00 committed by Shane McDonald
parent 0c0028541d
commit 95e796a88a
No known key found for this signature in database
GPG Key ID: 6F374AF6E9EB9374

View File

@ -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);