diff --git a/src/frontend/src/modals/exportModal/index.tsx b/src/frontend/src/modals/exportModal/index.tsx index 5d3281ecd..29357ac07 100644 --- a/src/frontend/src/modals/exportModal/index.tsx +++ b/src/frontend/src/modals/exportModal/index.tsx @@ -53,46 +53,54 @@ const ExportModal = forwardRef( size="smaller-h-full" open={open} setOpen={setOpen} - onSubmit={() => { - if (checked) { - downloadFlow( - { - id: currentFlow!.id, - data: currentFlow!.data!, + onSubmit={async () => { + try { + if (checked) { + await downloadFlow( + { + id: currentFlow!.id, + data: currentFlow!.data!, + description, + name, + last_tested_version: version, + endpoint_name: currentFlow!.endpoint_name, + is_component: false, + tags: currentFlow!.tags, + }, + name!, description, - name, - last_tested_version: version, - endpoint_name: currentFlow!.endpoint_name, - is_component: false, - tags: currentFlow!.tags, - }, - name!, - description, - ); - setNoticeData({ - title: API_WARNING_NOTICE_ALERT, - }); - } else - downloadFlow( - removeApiKeys({ - id: currentFlow!.id, - data: currentFlow!.data!, + ); + + setNoticeData({ + title: API_WARNING_NOTICE_ALERT, + }); + setOpen(false); + track("Flow Exported", { flowId: currentFlow!.id }); + } else { + await downloadFlow( + removeApiKeys({ + id: currentFlow!.id, + data: currentFlow!.data!, + description, + name, + last_tested_version: version, + endpoint_name: currentFlow!.endpoint_name, + is_component: false, + tags: currentFlow!.tags, + }), + name!, description, - name, - last_tested_version: version, - endpoint_name: currentFlow!.endpoint_name, - is_component: false, - tags: currentFlow!.tags, - }), - name!, - description, - ).then(() => { + ); + setSuccessData({ title: "Flow exported successfully", }); - }); - setOpen(false); - track("Flow Exported", { flowId: currentFlow!.id }); + setOpen(false); + track("Flow Exported", { flowId: currentFlow!.id }); + } + } catch (error) { + console.error("Error exporting flow:", error); + } }} > {props.children ?? <>} diff --git a/src/frontend/src/utils/reactflowUtils.ts b/src/frontend/src/utils/reactflowUtils.ts index ee38c8012..a3d991f74 100644 --- a/src/frontend/src/utils/reactflowUtils.ts +++ b/src/frontend/src/utils/reactflowUtils.ts @@ -1904,7 +1904,7 @@ export async function downloadFlow( flow: FlowType, flowName: string, flowDescription?: string, -) { +): Promise { try { const clonedFlow = cloneDeep(flow); @@ -1919,9 +1919,10 @@ export async function downloadFlow( const sortedData = sortJsonStructure(flowData); const sortedJsonString = JSON.stringify(sortedData, null, 2); - customDownloadFlow(flow, sortedJsonString, flowName); + return await customDownloadFlow(flow, sortedJsonString, flowName); } catch (error) { console.error("Error downloading flow:", error); + throw error; } }