forked from p15670423/monkey
UI: Add fix for propagation tabs change
This commit is contained in:
parent
7c9a95100a
commit
cea1d1fa28
|
@ -13,7 +13,6 @@ export default function CredentialsConfig(props) {
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
let credentialsCopy = _.clone(credentials);
|
let credentialsCopy = _.clone(credentials);
|
||||||
|
|
||||||
return (<>
|
return (<>
|
||||||
<Form schema={schema}
|
<Form schema={schema}
|
||||||
uiSchema={uiSchema}
|
uiSchema={uiSchema}
|
||||||
|
|
|
@ -3,6 +3,7 @@ import React, {useState, useEffect} from 'react';
|
||||||
import {Nav} from 'react-bootstrap';
|
import {Nav} from 'react-bootstrap';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import CredentialsConfig from './CredentialsConfig';
|
import CredentialsConfig from './CredentialsConfig';
|
||||||
|
import AuthComponent from '../AuthComponent';
|
||||||
|
|
||||||
const sectionOrder = [
|
const sectionOrder = [
|
||||||
'exploitation',
|
'exploitation',
|
||||||
|
@ -25,15 +26,6 @@ export default function PropagationConfig(props) {
|
||||||
onCredentialChange
|
onCredentialChange
|
||||||
} = props;
|
} = props;
|
||||||
const [selectedSection, setSelectedSection] = useState(initialSection);
|
const [selectedSection, setSelectedSection] = useState(initialSection);
|
||||||
const [displayedSchema, setDisplayedSchema] = useState(getSchemaByKey(schema, initialSection));
|
|
||||||
const [displayedSchemaUi, setDisplayedSchemaUi] = useState(getUiSchemaByKey(uiSchema, initialSection));
|
|
||||||
const [localFormData, setLocalFormData] = useState(configuration[initialSection]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
setLocalFormData(configuration[selectedSection]);
|
|
||||||
setDisplayedSchema(getSchemaByKey(schema, selectedSection));
|
|
||||||
setDisplayedSchemaUi(getUiSchemaByKey(uiSchema, selectedSection));
|
|
||||||
}, [selectedSection])
|
|
||||||
|
|
||||||
const onFormDataChange = (formData) => {
|
const onFormDataChange = (formData) => {
|
||||||
let formDataClone = _.clone(formData.formData);
|
let formDataClone = _.clone(formData.formData);
|
||||||
|
@ -63,23 +55,28 @@ export default function PropagationConfig(props) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const getForm = () => {
|
const getForm = () => {
|
||||||
|
let selectedSectionData = configuration[selectedSection];
|
||||||
|
let displayedSchema = getSchemaByKey(schema, selectedSection);
|
||||||
|
let displayedUiSchema = getUiSchemaByKey(uiSchema, selectedSection);
|
||||||
if (selectedSection === 'credentials') {
|
if (selectedSection === 'credentials') {
|
||||||
return <CredentialsConfig schema={displayedSchema}
|
return <CredentialsConfig schema={displayedSchema}
|
||||||
uiSchema={displayedSchemaUi}
|
uiSchema={displayedUiSchema}
|
||||||
credentials={credentials}
|
credentials={credentials}
|
||||||
onChange={onCredentialChange}
|
onChange={onCredentialChange}
|
||||||
customFormats={customFormats}
|
customFormats={customFormats}
|
||||||
className={className}/>
|
className={className}/>
|
||||||
} else {
|
} else {
|
||||||
return <Form schema={displayedSchema}
|
let formForm = <Form schema={displayedSchema}
|
||||||
uiSchema={displayedSchemaUi}
|
uiSchema={displayedUiSchema}
|
||||||
formData={localFormData}
|
formData={selectedSectionData}
|
||||||
onChange={onFormDataChange}
|
onChange={onFormDataChange}
|
||||||
customFormats={customFormats}
|
customFormats={customFormats}
|
||||||
className={className}
|
className={className}
|
||||||
|
key={selectedSection}
|
||||||
liveValidate
|
liveValidate
|
||||||
// children={true} hides the submit button
|
// children={true} hides the submit button
|
||||||
children={true}/>
|
children={true}/>
|
||||||
|
return formForm;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue