PromucFlow_constructor/app/client/src/pages/Editor/ActionSettings.tsx
devrk96 ac23629647
Feature: API Pane Redesign (#2218)
Co-authored-by: Hetu Nandu <hetunandu@gmail.com>
Co-authored-by: Pawan Kumar <pawankumar@Pawans-MacBook-Pro.local>
2021-02-11 18:24:00 +05:30

48 lines
1.3 KiB
TypeScript

import React from "react";
import { ControlProps } from "components/formControls/BaseControl";
import FormControl from "./FormControl";
import { EditorTheme } from "components/editorComponents/CodeEditor/EditorConfig";
import styled from "styled-components";
interface ActionSettingsProps {
actionSettingsConfig: any;
formName: string;
theme?: EditorTheme;
}
const FormRow = styled.div`
margin-bottom: ${(props) => props.theme.spaces[10] + 1}px;
`;
const ActionSettings = (props: ActionSettingsProps): JSX.Element => {
return (
<>
{props.actionSettingsConfig.map((section: any) =>
renderEachConfig(section, props.formName),
)}
</>
);
};
const renderEachConfig = (section: any, formName: string): any => {
return section.children.map((formControlOrSection: ControlProps) => {
if ("children" in formControlOrSection) {
return renderEachConfig(formControlOrSection, formName);
} else {
try {
const { configProperty } = formControlOrSection;
return (
<FormRow key={configProperty}>
<FormControl config={formControlOrSection} formName={formName} />
</FormRow>
);
} catch (e) {
console.log(e);
}
}
return null;
});
};
export default ActionSettings;