Browse Source

feat: prompt

Ahmad Kholid 2 years ago
parent
commit
ac6d54ca29

+ 18 - 6
src/components/newtab/workflow/editor/EditorLocalActions.vue

@@ -674,12 +674,7 @@ async function retrieveTriggerText() {
     true
   );
 }
-async function syncWorkflow() {
-  state.loadingSync = true;
-
-  if (props.canEdit)
-    toast('Syncing workflow...', { timeout: false, id: 'sync' });
-
+async function fetchSyncWorkflow() {
   try {
     const response = await fetchApi(
       `/teams/${teamId}/workflows/${props.workflow.id}`
@@ -719,6 +714,23 @@ async function syncWorkflow() {
     toast.dismiss('sync');
   }
 }
+async function syncWorkflow() {
+  state.loadingSync = true;
+
+  if (props.canEdit) {
+    dialog.confirm({
+      title: 'Sync workflow',
+      okText: 'Sync',
+      body: 'This action will overwrite the current workflow with the one that stored in cloud',
+      onConfirm: () => {
+        fetchSyncWorkflow();
+        toast('Syncing workflow...', { timeout: false, id: 'sync' });
+      },
+    });
+  } else {
+    fetchSyncWorkflow();
+  }
+}
 
 retrieveTriggerText();
 

+ 3 - 1
src/newtab/pages/workflows/[id].vue

@@ -1062,7 +1062,9 @@ function checkWorkflowUpdate() {
       if (!result) return;
 
       updateWorkflow(result).then(() => {
-        window.location.reload();
+        editor.value.setNodes(result.drawflow.nodes || []);
+        editor.value.setEdges(result.drawflow.edges || []);
+        editor.value.fitView();
       });
     })
     .catch((error) => {