UI: Clean up PropagationConfig

This commit is contained in:
Ilija Lazoroski 2022-07-20 15:25:23 +02:00
parent cea1d1fa28
commit d09958e079
1 changed files with 6 additions and 10 deletions

View File

@ -1,9 +1,8 @@
import Form from 'react-jsonschema-form-bs4'; import Form from 'react-jsonschema-form-bs4';
import React, {useState, useEffect} from 'react'; import React, {useState} 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',
@ -35,14 +34,10 @@ export default function PropagationConfig(props) {
onChange(configurationClone); onChange(configurationClone);
} }
const setSection = (sectionKey) => {
setSelectedSection(sectionKey);
}
const renderNav = () => { const renderNav = () => {
return (<Nav variant="tabs" return (<Nav variant="tabs"
fill fill
activeKey={selectedSection} onSelect={setSection} activeKey={selectedSection} onSelect={setSelectedSection}
style={{'marginBottom': '2em'}} style={{'marginBottom': '2em'}}
className={'config-nav'}> className={'config-nav'}>
{sectionOrder.map(section => { {sectionOrder.map(section => {
@ -55,7 +50,6 @@ export default function PropagationConfig(props) {
} }
const getForm = () => { const getForm = () => {
let selectedSectionData = configuration[selectedSection];
let displayedSchema = getSchemaByKey(schema, selectedSection); let displayedSchema = getSchemaByKey(schema, selectedSection);
let displayedUiSchema = getUiSchemaByKey(uiSchema, selectedSection); let displayedUiSchema = getUiSchemaByKey(uiSchema, selectedSection);
if (selectedSection === 'credentials') { if (selectedSection === 'credentials') {
@ -66,17 +60,19 @@ export default function PropagationConfig(props) {
customFormats={customFormats} customFormats={customFormats}
className={className}/> className={className}/>
} else { } else {
let formForm = <Form schema={displayedSchema} let selectedSectionData = configuration[selectedSection];
return <Form schema={displayedSchema}
uiSchema={displayedUiSchema} uiSchema={displayedUiSchema}
formData={selectedSectionData} formData={selectedSectionData}
onChange={onFormDataChange} onChange={onFormDataChange}
customFormats={customFormats} customFormats={customFormats}
className={className} className={className}
// Each form must be a unique component
// which is defined by the selectedSection
key={selectedSection} key={selectedSection}
liveValidate liveValidate
// children={true} hides the submit button // children={true} hides the submit button
children={true}/> children={true}/>
return formForm;
} }
} }