diff --git a/monkey/monkey_island/cc/ui/src/components/configuration-components/CredentialsConfig.tsx b/monkey/monkey_island/cc/ui/src/components/configuration-components/CredentialsConfig.tsx new file mode 100644 index 000000000..dbe9e4e91 --- /dev/null +++ b/monkey/monkey_island/cc/ui/src/components/configuration-components/CredentialsConfig.tsx @@ -0,0 +1,27 @@ +import Form from 'react-jsonschema-form-bs4'; +import React from 'react'; +import _ from 'lodash'; + +export default function CredentialsConfig(props) { + const { + schema, + uiSchema, + credentials, + onChange, + customFormats, + className + } = props; + + let credentialsCopy = _.clone(credentials); + + return (<> +
{onChange(formData.formData)}} + customFormats={customFormats} + className={className} + liveValidate + children={true}/> + ) +} diff --git a/monkey/monkey_island/cc/ui/src/components/configuration-components/PropagationConfig.tsx b/monkey/monkey_island/cc/ui/src/components/configuration-components/PropagationConfig.tsx index b00e4653d..5418853be 100644 --- a/monkey/monkey_island/cc/ui/src/components/configuration-components/PropagationConfig.tsx +++ b/monkey/monkey_island/cc/ui/src/components/configuration-components/PropagationConfig.tsx @@ -2,6 +2,7 @@ import Form from 'react-jsonschema-form-bs4'; import React, {useState, useEffect} from 'react'; import {Nav} from 'react-bootstrap'; import _ from 'lodash'; +import CredentialsConfig from './CredentialsConfig'; const sectionOrder = [ 'exploitation', @@ -19,30 +20,27 @@ export default function PropagationConfig(props) { onChange, customFormats, className, - formData + configuration, + credentials, + onCredentialChange } = props; const [selectedSection, setSelectedSection] = useState(initialSection); const [displayedSchema, setDisplayedSchema] = useState(getSchemaByKey(schema, initialSection)); const [displayedSchemaUi, setDisplayedSchemaUi] = useState(getUiSchemaByKey(uiSchema, initialSection)); - const [localFormData, setLocalFormData] = useState(formData[initialSection]); + const [localFormData, setLocalFormData] = useState(configuration[initialSection]); useEffect(() => { - setLocalFormData(formData[selectedSection]); + setLocalFormData(configuration[selectedSection]); setDisplayedSchema(getSchemaByKey(schema, selectedSection)); setDisplayedSchemaUi(getUiSchemaByKey(uiSchema, selectedSection)); - setLocalFormData(formData[selectedSection]); }, [selectedSection]) - useEffect(() => { - setLocalFormData(formData[selectedSection]); - }, [formData]) + const onFormDataChange = (formData) => { + let formDataClone = _.clone(formData.formData); + let configurationClone = _.clone(configuration); - const onInnerDataChange = (innerData) => { - let innerDataClone = _.clone(innerData); - let formDataClone = _.clone(formData); - - formDataClone[selectedSection] = innerDataClone.formData; - onChange({formData: formDataClone}); + configurationClone[selectedSection] = formDataClone; + onChange(configurationClone); } const setSection = (sectionKey) => { @@ -50,7 +48,7 @@ export default function PropagationConfig(props) { } const renderNav = () => { - return (