ソースを参照

feat: add option to auto-save workflow when execute(#1580)

Ahmad Kholid 1 年間 前
コミット
62532770e5

+ 8 - 1
src/components/newtab/workflow/editor/EditorLocalActions.vue

@@ -131,7 +131,7 @@
         :class="[
           { 'cursor-default': isDataChanged },
           workflow.testingMode
-            ? 'bg-primary bg-primary bg-opacity-20 text-primary'
+            ? 'bg-primary bg-opacity-20 text-primary'
             : 'hoverable',
         ]"
         class="rounded-lg p-2"
@@ -333,6 +333,7 @@ import { useToast } from 'vue-toastification';
 import browser from 'webextension-polyfill';
 import { fetchApi } from '@/utils/api';
 import { useUserStore } from '@/stores/user';
+import { useStore } from '@/stores/main';
 import { useWorkflowStore } from '@/stores/workflow';
 import { useTeamWorkflowStore } from '@/stores/teamWorkflow';
 import { useSharedWorkflowStore } from '@/stores/sharedWorkflow';
@@ -381,6 +382,7 @@ const { t } = useI18n();
 const toast = useToast();
 const router = useRouter();
 const dialog = useDialog();
+const mainStore = useStore();
 const userStore = useUserStore();
 const packageStore = usePackageStore();
 const workflowStore = useWorkflowStore();
@@ -468,6 +470,11 @@ function updateWorkflowDescription(value) {
   state.showEditDescription = false;
 }
 function executeCurrWorkflow() {
+  if (mainStore.settings.editor.saveWhenExecute && props.isDataChanged) {
+    // eslint-disable-next-line no-use-before-define
+    saveWorkflow();
+  }
+
   executeWorkflow({
     ...props.workflow,
     isTesting: props.isDataChanged,

+ 4 - 0
src/locales/en/newtab.json

@@ -123,6 +123,10 @@
       "snapGrid": {
         "title": "Snap to the grid",
         "description": "Snap to the grid when moving a block"
+      },
+      "saveWhenExecute": {
+        "title": "Auto-save when execute workflow",
+        "description": "Workflow changes will be saved when executing the workflow"
       }
     },
     "deleteLog": {

+ 11 - 0
src/newtab/pages/settings/SettingsEditor.vue

@@ -54,6 +54,17 @@
           />
         </div>
       </transition-expand>
+      <ui-list-item small>
+        <ui-switch v-model="settings.saveWhenExecute" />
+        <div class="ml-4 flex-1">
+          <p class="leading-tight">
+            {{ t('settings.editor.saveWhenExecute.title') }}
+          </p>
+          <p class="text-sm leading-tight text-gray-600 dark:text-gray-200">
+            {{ t('settings.editor.saveWhenExecute.description') }}
+          </p>
+        </div>
+      </ui-list-item>
     </ui-list>
   </div>
 </template>

+ 1 - 0
src/stores/main.js

@@ -25,6 +25,7 @@ export const useStore = defineStore('main', {
         arrow: true,
         snapToGrid: false,
         lineType: 'default',
+        saveWhenExecute: false,
         snapGrid: { 0: 15, 1: 15 },
       },
     },