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:
anovazzi1 2023-06-15 17:47:24 -03:00
commit 64b0ffcde5
2 changed files with 14 additions and 11 deletions

View file

@ -0,0 +1 @@
/usr/lib/node_modules/opencommit/out/cli.cjs

View file

@ -24,6 +24,10 @@ export default function FlowSettingsModal() {
const ref = useRef();
const { flows, tabId, updateFlow, setTabsState, saveFlow } = useContext(TabsContext);
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) {
setOpen(x);
if (x === false) {
@ -32,12 +36,14 @@ export default function FlowSettingsModal() {
}, 300);
}
}
const [name, setName] = useState(flows.find((f) => f.id === tabId).name);
const [description, setDescription] = useState(
flows.find((f) => f.id === tabId).description
);
function handleClick(){
let savedFlow = flows.find((f) => f.id === tabId)
savedFlow.name = name;
savedFlow.description = description;
saveFlow(savedFlow);
setSuccessData({ title: "Changes saved successfully" });
closePopUp();
}
return (
<Dialog open={true} onOpenChange={setModalOpen}>
<DialogTrigger asChild></DialogTrigger>
@ -62,11 +68,7 @@ export default function FlowSettingsModal() {
<DialogFooter>
<Button
onClick={() => {
saveFlow(flows.find((f) => f.id === tabId));
setSuccessData({ title: "Changes saved successfully" });
closePopUp();
}}
onClick={handleClick}
type="submit"
>
Save