Merge branch 'zustand/io/migration' of personal:logspace-ai/langflow into zustand/io/migration
This commit is contained in:
commit
9a4babc6d0
4 changed files with 31 additions and 28 deletions
|
|
@ -14,7 +14,8 @@ export default function CodeAreaComponent({
|
||||||
setNodeClass,
|
setNodeClass,
|
||||||
id = "",
|
id = "",
|
||||||
readonly = false,
|
readonly = false,
|
||||||
openModal,
|
open,
|
||||||
|
setOpen,
|
||||||
}: CodeAreaComponentType) {
|
}: CodeAreaComponentType) {
|
||||||
const [myValue, setMyValue] = useState(
|
const [myValue, setMyValue] = useState(
|
||||||
typeof value == "string" ? value : JSON.stringify(value)
|
typeof value == "string" ? value : JSON.stringify(value)
|
||||||
|
|
@ -33,7 +34,8 @@ export default function CodeAreaComponent({
|
||||||
return (
|
return (
|
||||||
<div className={disabled ? "pointer-events-none w-full " : " w-full"}>
|
<div className={disabled ? "pointer-events-none w-full " : " w-full"}>
|
||||||
<CodeAreaModal
|
<CodeAreaModal
|
||||||
openModal={openModal}
|
open={open}
|
||||||
|
setOpen={setOpen}
|
||||||
readonly={readonly}
|
readonly={readonly}
|
||||||
dynamic={dynamic}
|
dynamic={dynamic}
|
||||||
value={myValue}
|
value={myValue}
|
||||||
|
|
|
||||||
|
|
@ -35,9 +35,11 @@ export default function CodeAreaModal({
|
||||||
children,
|
children,
|
||||||
dynamic,
|
dynamic,
|
||||||
readonly = false,
|
readonly = false,
|
||||||
openModal,
|
open: myOpen,
|
||||||
|
setOpen: mySetOpen,
|
||||||
}: codeAreaModalPropsType): JSX.Element {
|
}: codeAreaModalPropsType): JSX.Element {
|
||||||
const [code, setCode] = useState(value);
|
const [code, setCode] = useState(value);
|
||||||
|
const [open, setOpen] = (mySetOpen !== undefined && myOpen !== undefined) ? [myOpen, mySetOpen] : useState(false);
|
||||||
const dark = useDarkStore((state) => state.dark);
|
const dark = useDarkStore((state) => state.dark);
|
||||||
const unselectAll = useFlowStore((state) => state.unselectAll);
|
const unselectAll = useFlowStore((state) => state.unselectAll);
|
||||||
|
|
||||||
|
|
@ -56,10 +58,6 @@ export default function CodeAreaModal({
|
||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (openModal) setOpen(true);
|
|
||||||
}, [openModal]);
|
|
||||||
|
|
||||||
function processNonDynamicField() {
|
function processNonDynamicField() {
|
||||||
postValidateCode(code)
|
postValidateCode(code)
|
||||||
.then((apiReturn) => {
|
.then((apiReturn) => {
|
||||||
|
|
@ -143,8 +141,6 @@ export default function CodeAreaModal({
|
||||||
};
|
};
|
||||||
}, [error, setHeight]);
|
}, [error, setHeight]);
|
||||||
|
|
||||||
const [open, setOpen] = useState(false);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setCode(value);
|
setCode(value);
|
||||||
}, [value, open]);
|
}, [value, open]);
|
||||||
|
|
|
||||||
|
|
@ -219,23 +219,6 @@ export default function NodeToolbarComponent({
|
||||||
}}
|
}}
|
||||||
data-testid="code-button-modal"
|
data-testid="code-button-modal"
|
||||||
>
|
>
|
||||||
<div className="hidden">
|
|
||||||
<CodeAreaComponent
|
|
||||||
openModal={openModal}
|
|
||||||
readonly={
|
|
||||||
data.node?.flow && data.node.template[name].dynamic
|
|
||||||
? true
|
|
||||||
: false
|
|
||||||
}
|
|
||||||
dynamic={data.node?.template[name].dynamic ?? false}
|
|
||||||
setNodeClass={handleNodeClass}
|
|
||||||
nodeClass={data.node}
|
|
||||||
disabled={false}
|
|
||||||
value={data.node?.template[name].value ?? ""}
|
|
||||||
onChange={handleOnNewValue}
|
|
||||||
id={"code-input-node-toolbar-" + name}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<IconComponent name="TerminalSquare" className="h-4 w-4" />
|
<IconComponent name="TerminalSquare" className="h-4 w-4" />
|
||||||
</button>
|
</button>
|
||||||
</ShadTooltip>
|
</ShadTooltip>
|
||||||
|
|
@ -492,6 +475,26 @@ export default function NodeToolbarComponent({
|
||||||
is_component={true}
|
is_component={true}
|
||||||
component={flowComponent!}
|
component={flowComponent!}
|
||||||
/>
|
/>
|
||||||
|
{hasCode && (
|
||||||
|
<div className="hidden">
|
||||||
|
<CodeAreaComponent
|
||||||
|
open={openModal}
|
||||||
|
setOpen={setOpenModal}
|
||||||
|
readonly={
|
||||||
|
data.node?.flow && data.node.template[name].dynamic
|
||||||
|
? true
|
||||||
|
: false
|
||||||
|
}
|
||||||
|
dynamic={data.node?.template[name].dynamic ?? false}
|
||||||
|
setNodeClass={handleNodeClass}
|
||||||
|
nodeClass={data.node}
|
||||||
|
disabled={false}
|
||||||
|
value={data.node?.template[name].value ?? ""}
|
||||||
|
onChange={handleOnNewValue}
|
||||||
|
id={"code-input-node-toolbar-" + name}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
|
|
|
||||||
|
|
@ -113,7 +113,8 @@ export type CodeAreaComponentType = {
|
||||||
dynamic?: boolean;
|
dynamic?: boolean;
|
||||||
id?: string;
|
id?: string;
|
||||||
readonly?: boolean;
|
readonly?: boolean;
|
||||||
openModal?: boolean;
|
open?: boolean;
|
||||||
|
setOpen?: (open: boolean) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type FileComponentType = {
|
export type FileComponentType = {
|
||||||
|
|
@ -519,7 +520,8 @@ export type codeAreaModalPropsType = {
|
||||||
children: ReactNode;
|
children: ReactNode;
|
||||||
dynamic?: boolean;
|
dynamic?: boolean;
|
||||||
readonly?: boolean;
|
readonly?: boolean;
|
||||||
openModal?: boolean;
|
open?: boolean;
|
||||||
|
setOpen?: (open: boolean) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type chatMessagePropsType = {
|
export type chatMessagePropsType = {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue