Add setSuccessData function to handleAddFlow and add duplicate flow functionality
This commit is contained in:
parent
ced448c7ae
commit
633881c652
1 changed files with 25 additions and 4 deletions
|
|
@ -29,6 +29,7 @@ export const MenuBar = ({
|
||||||
const addFlow = useFlowsManagerStore((state) => state.addFlow);
|
const addFlow = useFlowsManagerStore((state) => state.addFlow);
|
||||||
const currentFlow = useFlowsManagerStore((state) => state.currentFlow);
|
const currentFlow = useFlowsManagerStore((state) => state.currentFlow);
|
||||||
const setErrorData = useAlertStore((state) => state.setErrorData);
|
const setErrorData = useAlertStore((state) => state.setErrorData);
|
||||||
|
const setSuccessData = useAlertStore((state) => state.setSuccessData);
|
||||||
const undo = useFlowsManagerStore((state) => state.undo);
|
const undo = useFlowsManagerStore((state) => state.undo);
|
||||||
const redo = useFlowsManagerStore((state) => state.redo);
|
const redo = useFlowsManagerStore((state) => state.redo);
|
||||||
const saveLoading = useFlowsManagerStore((state) => state.saveLoading);
|
const saveLoading = useFlowsManagerStore((state) => state.saveLoading);
|
||||||
|
|
@ -38,11 +39,22 @@ export const MenuBar = ({
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const isBuilding = useFlowStore((state) => state.isBuilding);
|
const isBuilding = useFlowStore((state) => state.isBuilding);
|
||||||
|
|
||||||
function handleAddFlow() {
|
function handleAddFlow(duplicate?: boolean) {
|
||||||
try {
|
try {
|
||||||
addFlow(true).then((id) => {
|
if(duplicate) {
|
||||||
navigate("/flow/" + id);
|
if (!currentFlow) {
|
||||||
});
|
throw new Error("No flow to duplicate");
|
||||||
|
}
|
||||||
|
addFlow(true, currentFlow).then((_) => {
|
||||||
|
setSuccessData({title:"Flow duplicated successfully"});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
addFlow(true).then((id) => {
|
||||||
|
navigate("/flow/" + id);
|
||||||
|
});
|
||||||
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
setErrorData(err as { title: string; list?: Array<string> });
|
setErrorData(err as { title: string; list?: Array<string> });
|
||||||
}
|
}
|
||||||
|
|
@ -88,6 +100,15 @@ export const MenuBar = ({
|
||||||
<IconComponent name="Plus" className="header-menu-options" />
|
<IconComponent name="Plus" className="header-menu-options" />
|
||||||
New
|
New
|
||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
|
<DropdownMenuItem
|
||||||
|
onClick={() => {
|
||||||
|
handleAddFlow(true);
|
||||||
|
}}
|
||||||
|
className="cursor-pointer"
|
||||||
|
>
|
||||||
|
<IconComponent name="Copy" className="header-menu-options" />
|
||||||
|
Duplicate
|
||||||
|
</DropdownMenuItem>
|
||||||
|
|
||||||
<DropdownMenuItem
|
<DropdownMenuItem
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue