🔧 fix(codeTabsComponent): remove unused onChange function parameter in CodeTabsComponent to improve code readability and maintainability
🔧 fix(dictComponent): change onChange behavior in DictComponent to set an empty object when disabled instead of an empty array 🔧 fix(ApiModal): add a check to convert changes to an object only if it is an array in ApiModal 🔧 fix(dictAreaModal): change dictObj state to a ref in DictAreaModal to avoid unnecessary re-renders 🔧 fix(dictAreaModal): update dictObj ref value instead of using setDictObj in DictAreaModal to improve performance 🔧 fix(types): remove unnecessary line breaks in TooltipComponentType to improve code readability
This commit is contained in:
parent
ea2b0dcc38
commit
d9eb22c30f
5 changed files with 29 additions and 44 deletions
|
|
@ -842,25 +842,7 @@ export default function CodeTabsComponent({
|
||||||
templateField
|
templateField
|
||||||
].value
|
].value
|
||||||
}
|
}
|
||||||
onChange={(target) => {
|
onChange={(target) => {}}
|
||||||
setData((old) => {
|
|
||||||
let newInputList =
|
|
||||||
cloneDeep(old);
|
|
||||||
newInputList![
|
|
||||||
i
|
|
||||||
].data.node.template[
|
|
||||||
templateField
|
|
||||||
].value = target;
|
|
||||||
return newInputList;
|
|
||||||
});
|
|
||||||
tweaks.buildTweakObject!(
|
|
||||||
node["data"]["id"],
|
|
||||||
target,
|
|
||||||
node.data.node.template[
|
|
||||||
templateField
|
|
||||||
]
|
|
||||||
);
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</ShadTooltip>
|
</ShadTooltip>
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { useEffect } from "react";
|
import { useEffect, useRef } from "react";
|
||||||
import { DictComponentType } from "../../types/components";
|
import { DictComponentType } from "../../types/components";
|
||||||
|
|
||||||
import DictAreaModal from "../../modals/dictAreaModal";
|
import DictAreaModal from "../../modals/dictAreaModal";
|
||||||
|
|
@ -13,13 +13,15 @@ export default function DictComponent({
|
||||||
}: DictComponentType): JSX.Element {
|
}: DictComponentType): JSX.Element {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (disabled) {
|
if (disabled) {
|
||||||
onChange([""]);
|
onChange({});
|
||||||
}
|
}
|
||||||
}, [disabled]);
|
}, [disabled]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (value) onChange(value);
|
if (value) onChange(value);
|
||||||
}, [onChange]);
|
}, [value]);
|
||||||
|
|
||||||
|
const ref = useRef(value);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
|
|
@ -31,7 +33,7 @@ export default function DictComponent({
|
||||||
{
|
{
|
||||||
<div className="flex w-full gap-3">
|
<div className="flex w-full gap-3">
|
||||||
<DictAreaModal
|
<DictAreaModal
|
||||||
value={value}
|
value={ref.current}
|
||||||
onChange={(obj) => {
|
onChange={(obj) => {
|
||||||
onChange(obj);
|
onChange(obj);
|
||||||
}}
|
}}
|
||||||
|
|
|
||||||
|
|
@ -133,7 +133,7 @@ const ApiModal = forwardRef(
|
||||||
changes = changes?.filter((x) => x !== "");
|
changes = changes?.filter((x) => x !== "");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (template.type === "dict") {
|
if (template.type === "dict" && Array.isArray(changes)) {
|
||||||
changes = convertArrayToObj(changes);
|
changes = convertArrayToObj(changes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import "ace-builds/src-noconflict/mode-python";
|
||||||
import "ace-builds/src-noconflict/theme-github";
|
import "ace-builds/src-noconflict/theme-github";
|
||||||
import "ace-builds/src-noconflict/theme-twilight";
|
import "ace-builds/src-noconflict/theme-twilight";
|
||||||
// import "ace-builds/webpack-resolver";
|
// import "ace-builds/webpack-resolver";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useRef, useState } from "react";
|
||||||
import JsonView from "react18-json-view";
|
import JsonView from "react18-json-view";
|
||||||
import "react18-json-view/src/dark.css";
|
import "react18-json-view/src/dark.css";
|
||||||
import "react18-json-view/src/style.css";
|
import "react18-json-view/src/style.css";
|
||||||
|
|
@ -19,11 +19,12 @@ export default function DictAreaModal({
|
||||||
value,
|
value,
|
||||||
}): JSX.Element {
|
}): JSX.Element {
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
const [dictObj, setDictObj] = useState(value);
|
|
||||||
|
const ref = useRef(value);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (value) setDictObj(value);
|
if (value) ref.current = value;
|
||||||
}, [dictObj]);
|
}, [ref]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<BaseModal size="medium-h-full" open={open} setOpen={setOpen}>
|
<BaseModal size="medium-h-full" open={open} setOpen={setOpen}>
|
||||||
|
|
@ -44,19 +45,19 @@ export default function DictAreaModal({
|
||||||
editable
|
editable
|
||||||
enableClipboard
|
enableClipboard
|
||||||
onEdit={(edit) => {
|
onEdit={(edit) => {
|
||||||
setDictObj(edit["src"]);
|
ref.current = edit["src"];
|
||||||
}}
|
}}
|
||||||
onChange={(edit) => {
|
onChange={(edit) => {
|
||||||
setDictObj(edit["src"]);
|
ref.current = edit["src"];
|
||||||
}}
|
}}
|
||||||
src={dictObj}
|
src={ref.current}
|
||||||
/>
|
/>
|
||||||
<div className="flex h-fit w-full justify-end">
|
<div className="flex h-fit w-full justify-end">
|
||||||
<Button
|
<Button
|
||||||
className="mt-3"
|
className="mt-3"
|
||||||
type="submit"
|
type="submit"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
onChange(dictObj);
|
onChange(ref.current);
|
||||||
setOpen(false);
|
setOpen(false);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|
|
||||||
|
|
@ -134,18 +134,18 @@ export type TooltipComponentType = {
|
||||||
children: ReactElement;
|
children: ReactElement;
|
||||||
title: string | ReactElement;
|
title: string | ReactElement;
|
||||||
placement?:
|
placement?:
|
||||||
| "bottom-end"
|
| "bottom-end"
|
||||||
| "bottom-start"
|
| "bottom-start"
|
||||||
| "bottom"
|
| "bottom"
|
||||||
| "left-end"
|
| "left-end"
|
||||||
| "left-start"
|
| "left-start"
|
||||||
| "left"
|
| "left"
|
||||||
| "right-end"
|
| "right-end"
|
||||||
| "right-start"
|
| "right-start"
|
||||||
| "right"
|
| "right"
|
||||||
| "top-end"
|
| "top-end"
|
||||||
| "top-start"
|
| "top-start"
|
||||||
| "top";
|
| "top";
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ProgressBarType = {
|
export type ProgressBarType = {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue