mirror of
https://github.com/ansible/awx.git
synced 2026-02-28 08:18:43 -03:30
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:
@@ -1,6 +1,6 @@
|
|||||||
import React, { useEffect, useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
|
import { useLocation, useHistory } from 'react-router-dom';
|
||||||
import { t } from '@lingui/macro';
|
import { t } from '@lingui/macro';
|
||||||
import { useField } from 'formik';
|
import { useField } from 'formik';
|
||||||
import {
|
import {
|
||||||
@@ -23,6 +23,8 @@ function CredentialPluginInput(props) {
|
|||||||
const [showPluginWizard, setShowPluginWizard] = useState(false);
|
const [showPluginWizard, setShowPluginWizard] = useState(false);
|
||||||
const [inputField, meta, helpers] = useField(`inputs.${fieldOptions.id}`);
|
const [inputField, meta, helpers] = useField(`inputs.${fieldOptions.id}`);
|
||||||
const [passwordPromptField] = useField(`passwordPrompts.${fieldOptions.id}`);
|
const [passwordPromptField] = useField(`passwordPrompts.${fieldOptions.id}`);
|
||||||
|
const location = useLocation();
|
||||||
|
const history = useHistory();
|
||||||
|
|
||||||
const disableFieldAndButtons =
|
const disableFieldAndButtons =
|
||||||
!!passwordPromptField.value ||
|
!!passwordPromptField.value ||
|
||||||
@@ -32,6 +34,11 @@ function CredentialPluginInput(props) {
|
|||||||
meta.value === meta.initialValue
|
meta.value === meta.initialValue
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const handlePluginWizardClose = () => {
|
||||||
|
setShowPluginWizard(false);
|
||||||
|
history.push(location.pathname);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{inputField?.value?.credential ? (
|
{inputField?.value?.credential ? (
|
||||||
@@ -73,7 +80,7 @@ function CredentialPluginInput(props) {
|
|||||||
initialValues={
|
initialValues={
|
||||||
typeof inputField.value === 'object' ? inputField.value : {}
|
typeof inputField.value === 'object' ? inputField.value : {}
|
||||||
}
|
}
|
||||||
onClose={() => setShowPluginWizard(false)}
|
onClose={() => handlePluginWizardClose()}
|
||||||
onSubmit={val => {
|
onSubmit={val => {
|
||||||
val.touched = true;
|
val.touched = true;
|
||||||
helpers.setValue(val);
|
helpers.setValue(val);
|
||||||
|
|||||||
Reference in New Issue
Block a user