refactor(parameterComponent): change setTemplate to setNodeClass to improve semantics and fix bug
refactor(codeAreaComponent): change template to nodeClass and setTemplate to setNodeClass to improve semantics refactor(API): change UpdateTemplate function parameter from template to nodeClass to improve semantics refactor(codeAreaModal): change template to nodeClass and setTemplate to setNodeClass to improve semantics and fix bug refactor(types): add APIClassType to import and change APITemplateType to import in relevant files to improve semantics
This commit is contained in:
parent
37e1ea05b4
commit
19be2e8178
5 changed files with 22 additions and 21 deletions
|
|
@ -227,8 +227,8 @@ export default function ParameterComponent({
|
||||||
</div>
|
</div>
|
||||||
) : left === true && type === "code" ? (
|
) : left === true && type === "code" ? (
|
||||||
<CodeAreaComponent
|
<CodeAreaComponent
|
||||||
setTemplate={(template)=>{data.node.template = template}}
|
setNodeClass={(nodeClass)=>{data.node = nodeClass}}
|
||||||
template={data.node.template}
|
nodeClass={data.node}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
value={data.node.template[name].value ?? ""}
|
value={data.node.template[name].value ?? ""}
|
||||||
onChange={handleOnNewValue}
|
onChange={handleOnNewValue}
|
||||||
|
|
|
||||||
|
|
@ -11,8 +11,8 @@ export default function CodeAreaComponent({
|
||||||
onChange,
|
onChange,
|
||||||
disabled,
|
disabled,
|
||||||
editNode = false,
|
editNode = false,
|
||||||
template,
|
nodeClass,
|
||||||
setTemplate,
|
setNodeClass,
|
||||||
}: CodeAreaComponentType) {
|
}: CodeAreaComponentType) {
|
||||||
const [myValue, setMyValue] = useState(value);
|
const [myValue, setMyValue] = useState(value);
|
||||||
const { openPopUp } = useContext(PopUpContext);
|
const { openPopUp } = useContext(PopUpContext);
|
||||||
|
|
@ -39,8 +39,8 @@ export default function CodeAreaComponent({
|
||||||
openPopUp(
|
openPopUp(
|
||||||
<CodeAreaModal
|
<CodeAreaModal
|
||||||
value={myValue}
|
value={myValue}
|
||||||
template={template}
|
nodeClass={nodeClass}
|
||||||
setTemplate={setTemplate}
|
setNodeClass={setNodeClass}
|
||||||
setValue={(t: string) => {
|
setValue={(t: string) => {
|
||||||
setMyValue(t);
|
setMyValue(t);
|
||||||
onChange(t);
|
onChange(t);
|
||||||
|
|
@ -63,9 +63,9 @@ export default function CodeAreaComponent({
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
openPopUp(
|
openPopUp(
|
||||||
<CodeAreaModal
|
<CodeAreaModal
|
||||||
setTemplate={setTemplate}
|
setNodeClass={setNodeClass}
|
||||||
value={myValue}
|
value={myValue}
|
||||||
template={template}
|
nodeClass={nodeClass}
|
||||||
setValue={(t: string) => {
|
setValue={(t: string) => {
|
||||||
setMyValue(t);
|
setMyValue(t);
|
||||||
onChange(t);
|
onChange(t);
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import {
|
||||||
InitTypeAPI,
|
InitTypeAPI,
|
||||||
TemplateVariableType,
|
TemplateVariableType,
|
||||||
APITemplateType,
|
APITemplateType,
|
||||||
|
APIClassType,
|
||||||
} from "./../../types/api/index";
|
} from "./../../types/api/index";
|
||||||
import { APIObjectType, sendAllProps } from "../../types/api/index";
|
import { APIObjectType, sendAllProps } from "../../types/api/index";
|
||||||
import axios, { AxiosResponse } from "axios";
|
import axios, { AxiosResponse } from "axios";
|
||||||
|
|
@ -322,6 +323,6 @@ export async function postBuildInit(
|
||||||
return await axios.post(`/api/v1/build/init`, flow);
|
return await axios.post(`/api/v1/build/init`, flow);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function UpdateTemplate(type:string, template:APITemplateType):Promise<AxiosResponse<{template:APITemplateType}>>{
|
export async function UpdateTemplate(type:string, nodeClass:APIClassType):Promise<AxiosResponse<APIClassType>>{
|
||||||
return await axios.get(`/dynamic_node`);
|
return await axios.get(`/dynamic_node`);
|
||||||
}
|
}
|
||||||
|
|
@ -23,18 +23,18 @@ import {
|
||||||
import { Button } from "../../components/ui/button";
|
import { Button } from "../../components/ui/button";
|
||||||
import { CODE_PROMPT_DIALOG_SUBTITLE } from "../../constants";
|
import { CODE_PROMPT_DIALOG_SUBTITLE } from "../../constants";
|
||||||
import Loading from "../../components/ui/loading";
|
import Loading from "../../components/ui/loading";
|
||||||
import { APITemplateType } from "../../types/api";
|
import { APIClassType, APITemplateType } from "../../types/api";
|
||||||
|
|
||||||
export default function CodeAreaModal({
|
export default function CodeAreaModal({
|
||||||
value,
|
value,
|
||||||
setValue,
|
setValue,
|
||||||
template,
|
nodeClass,
|
||||||
setTemplate
|
setNodeClass
|
||||||
}: {
|
}: {
|
||||||
setValue: (value: string) => void;
|
setValue: (value: string) => void;
|
||||||
value: string;
|
value: string;
|
||||||
template: APITemplateType,
|
nodeClass: APIClassType,
|
||||||
setTemplate: (template: APITemplateType) => void;
|
setNodeClass: (Class: APIClassType) => void;
|
||||||
}) {
|
}) {
|
||||||
const [open, setOpen] = useState(true);
|
const [open, setOpen] = useState(true);
|
||||||
const [code, setCode] = useState(value);
|
const [code, setCode] = useState(value);
|
||||||
|
|
@ -93,11 +93,11 @@ export default function CodeAreaModal({
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
UpdateTemplate('code',template).then((apiReturn) => {
|
UpdateTemplate('code',nodeClass).then((apiReturn) => {
|
||||||
const data = apiReturn.data;
|
const data = apiReturn.data;
|
||||||
if (data.template) {
|
if (data) {
|
||||||
console.log('updated')
|
console.log(data)
|
||||||
setTemplate(data.template);
|
setNodeClass(data);
|
||||||
setModalOpen(false);
|
setModalOpen(false);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { ForwardRefExoticComponent, ReactElement, ReactNode } from "react";
|
import { ForwardRefExoticComponent, ReactElement, ReactNode } from "react";
|
||||||
import { NodeDataType } from "../flow/index";
|
import { NodeDataType } from "../flow/index";
|
||||||
import { typesContextType } from "../typesContext";
|
import { typesContextType } from "../typesContext";
|
||||||
import { APITemplateType } from "../api";
|
import { APIClassType, APITemplateType } from "../api";
|
||||||
export type InputComponentType = {
|
export type InputComponentType = {
|
||||||
value: string;
|
value: string;
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
|
|
@ -56,8 +56,8 @@ export type CodeAreaComponentType = {
|
||||||
onChange: (value: string[] | string) => void;
|
onChange: (value: string[] | string) => void;
|
||||||
value: string;
|
value: string;
|
||||||
editNode?: boolean;
|
editNode?: boolean;
|
||||||
template: APITemplateType;
|
nodeClass: APIClassType;
|
||||||
setTemplate: (value: APITemplateType) => void;
|
setNodeClass: (value: APIClassType) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type FileComponentType = {
|
export type FileComponentType = {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue