Merge branch 'modalRefactor' into input-refactor

This commit is contained in:
Cristhian Zanforlin Lousa 2023-07-22 09:05:38 -03:00
commit c218dc1d02
5 changed files with 19 additions and 11 deletions

View file

@ -7,7 +7,7 @@ type InputProps = {
name: string | null; name: string | null;
description: string | null; description: string | null;
maxLength?: number; maxLength?: number;
flows: Array<{ id: string; name: string }>; flows: Array<{ id: string; name: string; description: string }>;
tabId: string; tabId: string;
setName: (name: string) => void; setName: (name: string) => void;
setDescription: (description: string) => void; setDescription: (description: string) => void;
@ -37,7 +37,13 @@ export const EditFlowSettings: React.FC<InputProps> = ({
setName(value); setName(value);
}; };
const [desc, setDesc] = useState(
flows.find((f) => f.id === tabId).description
);
const handleDescriptionChange = (event: ChangeEvent<HTMLTextAreaElement>) => { const handleDescriptionChange = (event: ChangeEvent<HTMLTextAreaElement>) => {
flows.find((f) => f.id === tabId).description = event.target.value;
setDesc(flows.find((f) => f.id === tabId).description)
setDescription(event.target.value); setDescription(event.target.value);
}; };
@ -70,7 +76,7 @@ export const EditFlowSettings: React.FC<InputProps> = ({
name="description" name="description"
id="description" id="description"
onChange={handleDescriptionChange} onChange={handleDescriptionChange}
value={description ?? ""} value={desc}
placeholder="Flow description" placeholder="Flow description"
className="mt-2 max-h-[100px] font-normal" className="mt-2 max-h-[100px] font-normal"
rows={3} rows={3}

View file

@ -191,6 +191,7 @@ export default function CodeTabsComponent({
<AccordionComponent <AccordionComponent
trigger={t["data"]["id"]} trigger={t["data"]["id"]}
open={openAccordion} open={openAccordion}
keyValue={t["data"]["id"]}
> >
<div className="api-modal-table-arrangement"> <div className="api-modal-table-arrangement">
<Table className="table-fixed bg-muted outline-1"> <Table className="table-fixed bg-muted outline-1">
@ -224,8 +225,6 @@ export default function CodeTabsComponent({
t.data.node.template[n].type === "int") t.data.node.template[n].type === "int")
) )
.map((n, i) => { .map((n, i) => {
//console.log(t.data.node.template[n]);
return ( return (
<TableRow <TableRow
key={i} key={i}

View file

@ -15,12 +15,6 @@ export default function InputListComponent({
}: InputListComponentType) { }: InputListComponentType) {
const [inputList, setInputList] = useState(value ?? [""]); const [inputList, setInputList] = useState(value ?? [""]);
useEffect(() => {
if (value) {
setInputList(value);
}
}, [value]);
useEffect(() => { useEffect(() => {
if (disabled) { if (disabled) {
setInputList([""]); setInputList([""]);
@ -47,7 +41,7 @@ export default function InputListComponent({
placeholder="Type something..." placeholder="Type something..."
onChange={(e) => { onChange={(e) => {
setInputList((old) => { setInputList((old) => {
let newInputList = _.cloneDeep(old); let newInputList = _.cloneDeep(inputList);
newInputList[idx] = e.target.value; newInputList[idx] = e.target.value;
return newInputList; return newInputList;
}); });

View file

@ -96,6 +96,12 @@ export default function GenericModal({
} }
}, [inputValue, type]); }, [inputValue, type]);
useEffect(() => {
setInputValue(value)
}, [value])
const coloredContent = (inputValue || "") const coloredContent = (inputValue || "")
.replace(/</g, "&lt;") .replace(/</g, "&lt;")
.replace(/>/g, "&gt;") .replace(/>/g, "&gt;")

View file

@ -93,6 +93,7 @@ export default function NodeToolbarComponent({ data, setData, deleteNode }) {
</ShadTooltip> </ShadTooltip>
<ShadTooltip content="Edit" side="top"> <ShadTooltip content="Edit" side="top">
<div>
<EditNodeModal <EditNodeModal
data={data} data={data}
setData={setData} setData={setData}
@ -109,6 +110,8 @@ export default function NodeToolbarComponent({ data, setData, deleteNode }) {
<IconComponent name="Settings2" className="h-4 w-4 " /> <IconComponent name="Settings2" className="h-4 w-4 " />
</div> </div>
</EditNodeModal> </EditNodeModal>
</div>
</ShadTooltip> </ShadTooltip>
</span> </span>
</div> </div>