fix(parameterComponent): fix logic for setting load_from_db property in template object
fix(codeTabsComponent): fix logic for setting load_from_db property in template object fix(EditNodeModal): fix logic for setting load_from_db property in template object fix(globalVariablesPage): fix logic for deleting global variable by id feat(globalVariables): add getVariableId function to retrieve variable id by key feat(types): add getVariableId function to GlobalVariablesStore type
This commit is contained in:
parent
928ba602bb
commit
3d2a76438c
7 changed files with 101 additions and 58 deletions
|
|
@ -8,9 +8,6 @@ from langflow.services.auth import utils as auth_utils
|
||||||
from langflow.services.auth.utils import get_current_active_user
|
from langflow.services.auth.utils import get_current_active_user
|
||||||
from langflow.services.database.models.credential import Credential, CredentialCreate, CredentialRead, CredentialUpdate
|
from langflow.services.database.models.credential import Credential, CredentialCreate, CredentialRead, CredentialUpdate
|
||||||
from langflow.services.database.models.user.model import User
|
from langflow.services.database.models.user.model import User
|
||||||
from langflow.services.deps import get_session, get_settings_service
|
|
||||||
CredentialRead,
|
|
||||||
CredentialUpdate)
|
|
||||||
from langflow.services.database.models.user.model import User
|
from langflow.services.database.models.user.model import User
|
||||||
from langflow.services.deps import get_session, get_settings_service
|
from langflow.services.deps import get_session, get_settings_service
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -421,8 +421,6 @@ export default function ParameterComponent({
|
||||||
title: `the value inserted in ${data.node?.display_name} is a global variable, \n
|
title: `the value inserted in ${data.node?.display_name} is a global variable, \n
|
||||||
the real value will be update on run`,
|
the real value will be update on run`,
|
||||||
});
|
});
|
||||||
}
|
|
||||||
//mark as global variable
|
|
||||||
setNode(data.id, (oldNode) => {
|
setNode(data.id, (oldNode) => {
|
||||||
let newNode = cloneDeep(oldNode);
|
let newNode = cloneDeep(oldNode);
|
||||||
newNode.data = {
|
newNode.data = {
|
||||||
|
|
@ -431,6 +429,18 @@ export default function ParameterComponent({
|
||||||
newNode.data.node.template[name].load_from_db = true;
|
newNode.data.node.template[name].load_from_db = true;
|
||||||
return newNode;
|
return newNode;
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
setNode(data.id, (oldNode) => {
|
||||||
|
let newNode = cloneDeep(oldNode);
|
||||||
|
newNode.data = {
|
||||||
|
...newNode.data,
|
||||||
|
};
|
||||||
|
newNode.data.node.template[name].load_from_db = false;
|
||||||
|
return newNode;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
//mark as global variable
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
|
||||||
|
|
@ -394,6 +394,18 @@ export default function CodeTabsComponent({
|
||||||
title: `the value inserted in ${templateField} is a global variable, \n
|
title: `the value inserted in ${templateField} is a global variable, \n
|
||||||
the real value will be update on run`,
|
the real value will be update on run`,
|
||||||
});
|
});
|
||||||
|
newInputList![
|
||||||
|
i
|
||||||
|
].data.node.template[
|
||||||
|
templateField
|
||||||
|
].load_from_db = true;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
newInputList![
|
||||||
|
i
|
||||||
|
].data.node.template[
|
||||||
|
templateField
|
||||||
|
].load_from_db = false;
|
||||||
}
|
}
|
||||||
return newInputList;
|
return newInputList;
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -275,7 +275,6 @@ const EditNodeModal = forwardRef(
|
||||||
title: `the value inserted in ${data.node?.display_name} is a global variable, \n
|
title: `the value inserted in ${data.node?.display_name} is a global variable, \n
|
||||||
the real value will be update on run`,
|
the real value will be update on run`,
|
||||||
});
|
});
|
||||||
}
|
|
||||||
//mark as global variable
|
//mark as global variable
|
||||||
setNode(data.id, (oldNode) => {
|
setNode(data.id, (oldNode) => {
|
||||||
let newNode = cloneDeep(oldNode);
|
let newNode = cloneDeep(oldNode);
|
||||||
|
|
@ -287,6 +286,19 @@ const EditNodeModal = forwardRef(
|
||||||
].load_from_db = true;
|
].load_from_db = true;
|
||||||
return newNode;
|
return newNode;
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
setNode(data.id, (oldNode) => {
|
||||||
|
let newNode = cloneDeep(oldNode);
|
||||||
|
newNode.data = {
|
||||||
|
...newNode.data,
|
||||||
|
};
|
||||||
|
newNode.data.node.template[
|
||||||
|
templateParam
|
||||||
|
].load_from_db = false;
|
||||||
|
return newNode;
|
||||||
|
});
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
|
||||||
|
|
@ -11,12 +11,20 @@ export default function GlobalVariablesPage() {
|
||||||
const globalVariablesEntries = useGlobalVariablesStore(
|
const globalVariablesEntries = useGlobalVariablesStore(
|
||||||
(state) => state.globalVariablesEntries
|
(state) => state.globalVariablesEntries
|
||||||
);
|
);
|
||||||
|
const getVariableId = useGlobalVariablesStore((state) => state.getVariableId);
|
||||||
const removeGlobalVariable = useGlobalVariablesStore(
|
const removeGlobalVariable = useGlobalVariablesStore(
|
||||||
(state) => state.removeGlobalVariable
|
(state) => state.removeGlobalVariable
|
||||||
);
|
);
|
||||||
|
|
||||||
function handleDelete(key: string) {
|
function handleDelete(key: string) {
|
||||||
deleteGlobalVariable(key).then((_) => removeGlobalVariable(key));
|
const id = getVariableId(key);
|
||||||
|
if(id!==undefined)
|
||||||
|
{
|
||||||
|
deleteGlobalVariable(id).then((_) => removeGlobalVariable(key));
|
||||||
|
|
||||||
|
}else{
|
||||||
|
console.error("id is undefined");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<PageLayout
|
<PageLayout
|
||||||
|
|
|
||||||
|
|
@ -27,5 +27,8 @@ export const useGlobalVariablesStore = create<GlobalVariablesStore>(
|
||||||
globalVariablesEntries: Object.keys(newVariables),
|
globalVariablesEntries: Object.keys(newVariables),
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
getVariableId: (key) => {
|
||||||
|
return get().globalVariables[key]?.id;
|
||||||
|
}
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -6,4 +6,5 @@ export type GlobalVariablesStore = {
|
||||||
}) => void;
|
}) => void;
|
||||||
addGlobalVariable: (key: string, id: string, provider?: string) => void;
|
addGlobalVariable: (key: string, id: string, provider?: string) => void;
|
||||||
removeGlobalVariable: (key: string) => void;
|
removeGlobalVariable: (key: string) => void;
|
||||||
|
getVariableId: (key: string) => string | undefined;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue