feat(frontend): add flow name and description editing functionality to FlowSettingsModal component
fix(frontend): fix saveFlow function call to save edited flow name and description instead of the original flow object
This commit is contained in:
parent
e22062bba5
commit
64b0ffcde5
2 changed files with 14 additions and 11 deletions
1
src/frontend/.githooks/prepare-commit-msg
Symbolic link
1
src/frontend/.githooks/prepare-commit-msg
Symbolic link
|
|
@ -0,0 +1 @@
|
||||||
|
/usr/lib/node_modules/opencommit/out/cli.cjs
|
||||||
|
|
@ -24,6 +24,10 @@ export default function FlowSettingsModal() {
|
||||||
const ref = useRef();
|
const ref = useRef();
|
||||||
const { flows, tabId, updateFlow, setTabsState, saveFlow } = useContext(TabsContext);
|
const { flows, tabId, updateFlow, setTabsState, saveFlow } = useContext(TabsContext);
|
||||||
const maxLength = 50;
|
const maxLength = 50;
|
||||||
|
const [name, setName] = useState(flows.find((f) => f.id === tabId).name);
|
||||||
|
const [description, setDescription] = useState(
|
||||||
|
flows.find((f) => f.id === tabId).description
|
||||||
|
);
|
||||||
function setModalOpen(x: boolean) {
|
function setModalOpen(x: boolean) {
|
||||||
setOpen(x);
|
setOpen(x);
|
||||||
if (x === false) {
|
if (x === false) {
|
||||||
|
|
@ -32,12 +36,14 @@ export default function FlowSettingsModal() {
|
||||||
}, 300);
|
}, 300);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
function handleClick(){
|
||||||
|
let savedFlow = flows.find((f) => f.id === tabId)
|
||||||
const [name, setName] = useState(flows.find((f) => f.id === tabId).name);
|
savedFlow.name = name;
|
||||||
const [description, setDescription] = useState(
|
savedFlow.description = description;
|
||||||
flows.find((f) => f.id === tabId).description
|
saveFlow(savedFlow);
|
||||||
);
|
setSuccessData({ title: "Changes saved successfully" });
|
||||||
|
closePopUp();
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
<Dialog open={true} onOpenChange={setModalOpen}>
|
<Dialog open={true} onOpenChange={setModalOpen}>
|
||||||
<DialogTrigger asChild></DialogTrigger>
|
<DialogTrigger asChild></DialogTrigger>
|
||||||
|
|
@ -62,11 +68,7 @@ export default function FlowSettingsModal() {
|
||||||
|
|
||||||
<DialogFooter>
|
<DialogFooter>
|
||||||
<Button
|
<Button
|
||||||
onClick={() => {
|
onClick={handleClick}
|
||||||
saveFlow(flows.find((f) => f.id === tabId));
|
|
||||||
setSuccessData({ title: "Changes saved successfully" });
|
|
||||||
closePopUp();
|
|
||||||
}}
|
|
||||||
type="submit"
|
type="submit"
|
||||||
>
|
>
|
||||||
Save
|
Save
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue