adding confirmation modal and save flow integratio
This commit is contained in:
parent
79cdcaf19a
commit
405f74bef9
4 changed files with 57 additions and 9 deletions
|
|
@ -547,9 +547,9 @@ export async function addApiKeyStore(key: string) {
|
||||||
* @throws Will throw an error if saving fails.
|
* @throws Will throw an error if saving fails.
|
||||||
*/
|
*/
|
||||||
export async function saveFlowStore(newFlow: {
|
export async function saveFlowStore(newFlow: {
|
||||||
name: string;
|
name?: string;
|
||||||
data: ReactFlowJsonObject | null;
|
data: ReactFlowJsonObject | null;
|
||||||
description: string;
|
description?: string;
|
||||||
style?: FlowStyleType;
|
style?: FlowStyleType;
|
||||||
is_component?: boolean;
|
is_component?: boolean;
|
||||||
}): Promise<FlowType> {
|
}): Promise<FlowType> {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
import { cloneDeep } from "lodash";
|
import { cloneDeep } from "lodash";
|
||||||
import { useContext, useEffect, useState } from "react";
|
import { useContext, useEffect, useState } from "react";
|
||||||
|
import { ReactFlowJsonObject } from "reactflow";
|
||||||
import ShadTooltip from "../../../../components/ShadTooltipComponent";
|
import ShadTooltip from "../../../../components/ShadTooltipComponent";
|
||||||
import IconComponent from "../../../../components/genericIconComponent";
|
import IconComponent from "../../../../components/genericIconComponent";
|
||||||
import { Input } from "../../../../components/ui/input";
|
import { Input } from "../../../../components/ui/input";
|
||||||
|
|
@ -7,7 +8,9 @@ import { Separator } from "../../../../components/ui/separator";
|
||||||
import { alertContext } from "../../../../contexts/alertContext";
|
import { alertContext } from "../../../../contexts/alertContext";
|
||||||
import { TabsContext } from "../../../../contexts/tabsContext";
|
import { TabsContext } from "../../../../contexts/tabsContext";
|
||||||
import { typesContext } from "../../../../contexts/typesContext";
|
import { typesContext } from "../../../../contexts/typesContext";
|
||||||
|
import { saveFlowStore } from "../../../../controllers/API";
|
||||||
import ApiModal from "../../../../modals/ApiModal";
|
import ApiModal from "../../../../modals/ApiModal";
|
||||||
|
import ConfirmationModal from "../../../../modals/ConfirmationModal";
|
||||||
import ExportModal from "../../../../modals/exportModal";
|
import ExportModal from "../../../../modals/exportModal";
|
||||||
import { APIClassType, APIObjectType } from "../../../../types/api";
|
import { APIClassType, APIObjectType } from "../../../../types/api";
|
||||||
import {
|
import {
|
||||||
|
|
@ -97,6 +100,29 @@ export default function ExtraSidebar(): JSX.Element {
|
||||||
}
|
}
|
||||||
}, [getFilterEdge, data]);
|
}, [getFilterEdge, data]);
|
||||||
|
|
||||||
|
const handleShareFlow = () => {
|
||||||
|
const reactFlow = flow!.data as ReactFlowJsonObject;
|
||||||
|
const saveFlow = {
|
||||||
|
data: {
|
||||||
|
...reactFlow,
|
||||||
|
},
|
||||||
|
is_component: false,
|
||||||
|
};
|
||||||
|
saveFlowStore(saveFlow).then(
|
||||||
|
() => {
|
||||||
|
setSuccessData({
|
||||||
|
title: "Flow shared successfully",
|
||||||
|
});
|
||||||
|
},
|
||||||
|
(err) => {
|
||||||
|
setErrorData({
|
||||||
|
title: "Error sharing flow",
|
||||||
|
list: [err["response"]["data"]["detail"]],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (getFilterEdge?.length > 0) {
|
if (getFilterEdge?.length > 0) {
|
||||||
setFilterData((_) => {
|
setFilterData((_) => {
|
||||||
|
|
@ -145,7 +171,10 @@ export default function ExtraSidebar(): JSX.Element {
|
||||||
uploadFlow(false);
|
uploadFlow(false);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<IconComponent name="FileUp" className="side-bar-button-size " />
|
<IconComponent
|
||||||
|
name="FileDown"
|
||||||
|
className="side-bar-button-size "
|
||||||
|
/>
|
||||||
</button>
|
</button>
|
||||||
</ShadTooltip>
|
</ShadTooltip>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -153,10 +182,7 @@ export default function ExtraSidebar(): JSX.Element {
|
||||||
<ExportModal>
|
<ExportModal>
|
||||||
<ShadTooltip content="Export" side="top">
|
<ShadTooltip content="Export" side="top">
|
||||||
<div className={classNames("extra-side-bar-buttons")}>
|
<div className={classNames("extra-side-bar-buttons")}>
|
||||||
<IconComponent
|
<IconComponent name="FileUp" className="side-bar-button-size" />
|
||||||
name="FileDown"
|
|
||||||
className="side-bar-button-size"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</ShadTooltip>
|
</ShadTooltip>
|
||||||
</ExportModal>
|
</ExportModal>
|
||||||
|
|
@ -202,6 +228,28 @@ export default function ExtraSidebar(): JSX.Element {
|
||||||
</button>
|
</button>
|
||||||
</ShadTooltip>
|
</ShadTooltip>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div className="side-bar-button">
|
||||||
|
<ConfirmationModal
|
||||||
|
index={0}
|
||||||
|
modalContentTitle="Are you sure you want to share this flow?"
|
||||||
|
modalContent="This flow will be available for everyone to use."
|
||||||
|
title="Share Flow"
|
||||||
|
confirmationText="Share"
|
||||||
|
icon="Share2"
|
||||||
|
onConfirm={() => {
|
||||||
|
handleShareFlow();
|
||||||
|
}}
|
||||||
|
titleHeader=""
|
||||||
|
cancelText="Cancel"
|
||||||
|
>
|
||||||
|
<ShadTooltip content="Share" side="top">
|
||||||
|
<div className={classNames("extra-side-bar-buttons")}>
|
||||||
|
<IconComponent name="Share2" className="side-bar-button-size" />
|
||||||
|
</div>
|
||||||
|
</ShadTooltip>
|
||||||
|
</ConfirmationModal>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<Separator />
|
<Separator />
|
||||||
<div className="side-bar-search-div-placement">
|
<div className="side-bar-search-div-placement">
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@
|
||||||
@apply fixed right-4;
|
@apply fixed right-4;
|
||||||
}
|
}
|
||||||
.side-bar-arrangement {
|
.side-bar-arrangement {
|
||||||
@apply flex h-full w-52 flex-col overflow-hidden border-r scrollbar-hide;
|
@apply flex h-full w-[14.5rem] flex-col overflow-hidden border-r scrollbar-hide;
|
||||||
}
|
}
|
||||||
.side-bar-search-div-placement {
|
.side-bar-search-div-placement {
|
||||||
@apply relative mx-auto mb-2 mt-2 flex items-center;
|
@apply relative mx-auto mb-2 mt-2 flex items-center;
|
||||||
|
|
|
||||||
|
|
@ -283,7 +283,7 @@ export type ConfirmationModalType = {
|
||||||
confirmationText: string;
|
confirmationText: string;
|
||||||
children: ReactElement;
|
children: ReactElement;
|
||||||
icon: string;
|
icon: string;
|
||||||
data: any;
|
data?: any;
|
||||||
index: number;
|
index: number;
|
||||||
onConfirm: (index, data) => void;
|
onConfirm: (index, data) => void;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue