fix(parameterComponent): add readonly prop to CodeAreaComponent and PromptAreaComponent based on dynamic property in template
fix(GenericNode): remove console.log statement fix(codeAreaComponent): add readonly prop to CodeAreaModal fix(codeTabsComponent): add readonly prop to CodeAreaComponent and PromptAreaComponent fix(promptComponent): add readonly prop to GenericModal fix(EditNodeModal): add readonly prop to CodeAreaComponent fix(codeAreaModal): add readonly prop to AceEditor in CodeAreaModal fix(genericModal): add readonly prop to Textarea in GenericModal fix(reactflowUtils): remove unnecessary code in updateGroupNodeTemplate function
This commit is contained in:
parent
a273aab2cc
commit
be1ee757a4
11 changed files with 23 additions and 7 deletions
|
|
@ -43,6 +43,7 @@ class PromptFrontendNode(FrontendNode):
|
||||||
|
|
||||||
# All prompt fields should be password=False
|
# All prompt fields should be password=False
|
||||||
field.password = False
|
field.password = False
|
||||||
|
field.dynamic = True
|
||||||
|
|
||||||
|
|
||||||
class PromptTemplateNode(FrontendNode):
|
class PromptTemplateNode(FrontendNode):
|
||||||
|
|
|
||||||
|
|
@ -299,6 +299,7 @@ export default function ParameterComponent({
|
||||||
) : left === true && type === "code" ? (
|
) : left === true && type === "code" ? (
|
||||||
<div className="mt-2 w-full">
|
<div className="mt-2 w-full">
|
||||||
<CodeAreaComponent
|
<CodeAreaComponent
|
||||||
|
readonly={data.node?.flow && data.node.template[name].dynamic?true:false}
|
||||||
dynamic={data.node?.template[name].dynamic ?? false}
|
dynamic={data.node?.template[name].dynamic ?? false}
|
||||||
setNodeClass={(nodeClass) => {
|
setNodeClass={(nodeClass) => {
|
||||||
data.node = nodeClass;
|
data.node = nodeClass;
|
||||||
|
|
@ -334,6 +335,7 @@ export default function ParameterComponent({
|
||||||
) : left === true && type === "prompt" ? (
|
) : left === true && type === "prompt" ? (
|
||||||
<div className="mt-2 w-full">
|
<div className="mt-2 w-full">
|
||||||
<PromptAreaComponent
|
<PromptAreaComponent
|
||||||
|
readonly={data.node?.flow && data.node.template[name].dynamic?true:false}
|
||||||
field_name={name}
|
field_name={name}
|
||||||
setNodeClass={(nodeClass) => {
|
setNodeClass={(nodeClass) => {
|
||||||
data.node = nodeClass;
|
data.node = nodeClass;
|
||||||
|
|
|
||||||
|
|
@ -74,6 +74,7 @@ export default function GenericNode({
|
||||||
setValidationStatus(null);
|
setValidationStatus(null);
|
||||||
}
|
}
|
||||||
}, [sseData, data.id]);
|
}, [sseData, data.id]);
|
||||||
|
console.log(data.node)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ export default function CodeAreaComponent({
|
||||||
nodeClass,
|
nodeClass,
|
||||||
dynamic,
|
dynamic,
|
||||||
setNodeClass,
|
setNodeClass,
|
||||||
|
readonly=false
|
||||||
}: CodeAreaComponentType) {
|
}: CodeAreaComponentType) {
|
||||||
const [myValue, setMyValue] = useState(
|
const [myValue, setMyValue] = useState(
|
||||||
typeof value == "string" ? value : JSON.stringify(value)
|
typeof value == "string" ? value : JSON.stringify(value)
|
||||||
|
|
@ -30,6 +31,7 @@ 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
|
||||||
|
readonly={readonly}
|
||||||
dynamic={dynamic}
|
dynamic={dynamic}
|
||||||
value={myValue}
|
value={myValue}
|
||||||
nodeClass={nodeClass}
|
nodeClass={nodeClass}
|
||||||
|
|
|
||||||
|
|
@ -633,6 +633,7 @@ export default function CodeTabsComponent({
|
||||||
>
|
>
|
||||||
<div className="mx-auto">
|
<div className="mx-auto">
|
||||||
<PromptAreaComponent
|
<PromptAreaComponent
|
||||||
|
readonly={node.data.node?.flow && node.data.node.template[templateField].dynamic? true : false}
|
||||||
editNode={true}
|
editNode={true}
|
||||||
disabled={false}
|
disabled={false}
|
||||||
value={
|
value={
|
||||||
|
|
@ -688,6 +689,7 @@ export default function CodeTabsComponent({
|
||||||
>
|
>
|
||||||
<div className="mx-auto">
|
<div className="mx-auto">
|
||||||
<CodeAreaComponent
|
<CodeAreaComponent
|
||||||
|
readonly={node.data.node?.flow && node.data.node.template[templateField].dynamic? true : false}
|
||||||
disabled={false}
|
disabled={false}
|
||||||
editNode={true}
|
editNode={true}
|
||||||
value={
|
value={
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ export default function PromptAreaComponent({
|
||||||
onChange,
|
onChange,
|
||||||
disabled,
|
disabled,
|
||||||
editNode = false,
|
editNode = false,
|
||||||
|
readonly=false
|
||||||
}: TextAreaComponentType): JSX.Element {
|
}: TextAreaComponentType): JSX.Element {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (disabled) {
|
if (disabled) {
|
||||||
|
|
@ -22,7 +23,7 @@ export default function PromptAreaComponent({
|
||||||
}, [disabled]);
|
}, [disabled]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (value !== "" && !editNode) {
|
if (value !== "" && !editNode && !readonly) {
|
||||||
postValidatePrompt(field_name!, value, nodeClass!).then((apiReturn) => {
|
postValidatePrompt(field_name!, value, nodeClass!).then((apiReturn) => {
|
||||||
if (apiReturn.data) {
|
if (apiReturn.data) {
|
||||||
setNodeClass!(apiReturn.data.frontend_node);
|
setNodeClass!(apiReturn.data.frontend_node);
|
||||||
|
|
@ -35,6 +36,7 @@ export default function PromptAreaComponent({
|
||||||
return (
|
return (
|
||||||
<div className={disabled ? "pointer-events-none w-full " : " w-full"}>
|
<div className={disabled ? "pointer-events-none w-full " : " w-full"}>
|
||||||
<GenericModal
|
<GenericModal
|
||||||
|
readonly={readonly}
|
||||||
type={TypeModal.PROMPT}
|
type={TypeModal.PROMPT}
|
||||||
value={value}
|
value={value}
|
||||||
buttonText="Check & Save"
|
buttonText="Check & Save"
|
||||||
|
|
|
||||||
|
|
@ -297,6 +297,7 @@ const EditNodeModal = forwardRef(
|
||||||
"prompt" ? (
|
"prompt" ? (
|
||||||
<div className="mx-auto">
|
<div className="mx-auto">
|
||||||
<PromptAreaComponent
|
<PromptAreaComponent
|
||||||
|
readonly={myData.node?.flow && myData.node.template[templateParam].dynamic? true : false}
|
||||||
field_name={templateParam}
|
field_name={templateParam}
|
||||||
editNode={true}
|
editNode={true}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
|
|
@ -317,6 +318,7 @@ const EditNodeModal = forwardRef(
|
||||||
"code" ? (
|
"code" ? (
|
||||||
<div className="mx-auto">
|
<div className="mx-auto">
|
||||||
<CodeAreaComponent
|
<CodeAreaComponent
|
||||||
|
readonly={myData.node?.flow && myData.node.template[templateParam].dynamic? true : false}
|
||||||
dynamic={
|
dynamic={
|
||||||
data.node!.template[templateParam]
|
data.node!.template[templateParam]
|
||||||
.dynamic ?? false
|
.dynamic ?? false
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ export default function CodeAreaModal({
|
||||||
setNodeClass,
|
setNodeClass,
|
||||||
children,
|
children,
|
||||||
dynamic,
|
dynamic,
|
||||||
|
readonly=false
|
||||||
}: codeAreaModalPropsType): JSX.Element {
|
}: codeAreaModalPropsType): JSX.Element {
|
||||||
const [code, setCode] = useState(value);
|
const [code, setCode] = useState(value);
|
||||||
const { dark } = useContext(darkContext);
|
const { dark } = useContext(darkContext);
|
||||||
|
|
@ -147,6 +148,7 @@ export default function CodeAreaModal({
|
||||||
<div className="flex h-full w-full flex-col transition-all">
|
<div className="flex h-full w-full flex-col transition-all">
|
||||||
<div className="h-full w-full">
|
<div className="h-full w-full">
|
||||||
<AceEditor
|
<AceEditor
|
||||||
|
readOnly={readonly}
|
||||||
value={code}
|
value={code}
|
||||||
mode="python"
|
mode="python"
|
||||||
height={height ?? "100%"}
|
height={height ?? "100%"}
|
||||||
|
|
@ -181,7 +183,7 @@ export default function CodeAreaModal({
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex h-fit w-full justify-end">
|
<div className="flex h-fit w-full justify-end">
|
||||||
<Button className="mt-3" onClick={handleClick} type="submit">
|
<Button disabled={readonly} className="mt-3" onClick={handleClick} type="submit">
|
||||||
Check & Save
|
Check & Save
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@ export default function GenericModal({
|
||||||
nodeClass,
|
nodeClass,
|
||||||
setNodeClass,
|
setNodeClass,
|
||||||
children,
|
children,
|
||||||
|
readonly=false,
|
||||||
}: genericModalPropsType): JSX.Element {
|
}: genericModalPropsType): JSX.Element {
|
||||||
const [myButtonText] = useState(buttonText);
|
const [myButtonText] = useState(buttonText);
|
||||||
const [myModalTitle] = useState(modalTitle);
|
const [myModalTitle] = useState(modalTitle);
|
||||||
|
|
@ -194,7 +195,7 @@ export default function GenericModal({
|
||||||
"flex h-full w-full"
|
"flex h-full w-full"
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{type === TypeModal.PROMPT && isEdit ? (
|
{type === TypeModal.PROMPT && isEdit && !readonly ? (
|
||||||
<Textarea
|
<Textarea
|
||||||
ref={divRefPrompt}
|
ref={divRefPrompt}
|
||||||
className="form-input h-full w-full rounded-lg custom-scroll focus-visible:ring-1"
|
className="form-input h-full w-full rounded-lg custom-scroll focus-visible:ring-1"
|
||||||
|
|
@ -212,7 +213,7 @@ export default function GenericModal({
|
||||||
handleKeyDown(e, inputValue, "");
|
handleKeyDown(e, inputValue, "");
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
) : type === TypeModal.PROMPT && !isEdit ? (
|
) : type === TypeModal.PROMPT && (!isEdit || readonly) ? (
|
||||||
<TextAreaContentView />
|
<TextAreaContentView />
|
||||||
) : type !== TypeModal.PROMPT ? (
|
) : type !== TypeModal.PROMPT ? (
|
||||||
<Textarea
|
<Textarea
|
||||||
|
|
@ -227,6 +228,7 @@ export default function GenericModal({
|
||||||
onKeyDown={(e) => {
|
onKeyDown={(e) => {
|
||||||
handleKeyDown(e, value, "");
|
handleKeyDown(e, value, "");
|
||||||
}}
|
}}
|
||||||
|
readOnly={readonly}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<></>
|
<></>
|
||||||
|
|
@ -283,6 +285,7 @@ export default function GenericModal({
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<Button
|
<Button
|
||||||
|
disabled={readonly}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
switch (myModalType) {
|
switch (myModalType) {
|
||||||
case TypeModal.TEXT:
|
case TypeModal.TEXT:
|
||||||
|
|
|
||||||
|
|
@ -65,6 +65,7 @@ export type TextAreaComponentType = {
|
||||||
onChange: (value: string[] | string) => void;
|
onChange: (value: string[] | string) => void;
|
||||||
value: string;
|
value: string;
|
||||||
editNode?: boolean;
|
editNode?: boolean;
|
||||||
|
readonly?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type CodeAreaComponentType = {
|
export type CodeAreaComponentType = {
|
||||||
|
|
@ -75,6 +76,7 @@ export type CodeAreaComponentType = {
|
||||||
nodeClass?: APIClassType;
|
nodeClass?: APIClassType;
|
||||||
setNodeClass?: (value: APIClassType) => void;
|
setNodeClass?: (value: APIClassType) => void;
|
||||||
dynamic?: boolean;
|
dynamic?: boolean;
|
||||||
|
readonly?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type FileComponentType = {
|
export type FileComponentType = {
|
||||||
|
|
|
||||||
|
|
@ -533,9 +533,6 @@ function updateGroupNodeTemplate(template: APITemplateType) {
|
||||||
!input_types
|
!input_types
|
||||||
) {
|
) {
|
||||||
template[key].advanced = true;
|
template[key].advanced = true;
|
||||||
if (template[key].dynamic) {
|
|
||||||
template[key].readonly = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return template;
|
return template;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue