Browse Source

feat: add error doc

Ahmad Kholid 2 years ago
parent
commit
517c77733d

+ 50 - 9
src/components/newtab/logs/LogsHistory.vue

@@ -17,6 +17,20 @@
           <div v-if="currentLog.status === 'error' && errorBlock">
             <p class="leading-tight line-clamp">
               {{ errorBlock.message }}
+              <a
+                v-if="errorBlock.messageId"
+                :href="`https://docs.automa.site/guide/workflow-errors.html#${errorBlock.messageId}`"
+                target="_blank"
+                title="About the error"
+                @click.stop
+              >
+                <v-remixicon
+                  name="riArrowLeftLine"
+                  size="20"
+                  class="text-gray-300 inline-block"
+                  rotate="135"
+                />
+              </a>
             </p>
             <p class="cursor-pointer" title="Jump to item" @click="jumpToError">
               On the {{ errorBlock.name }} block
@@ -28,6 +42,7 @@
               />
             </p>
           </div>
+          <slot name="header-prepend" />
           <div class="flex-grow" />
           <ui-input
             v-model="state.search"
@@ -91,6 +106,20 @@
                 class="text-sm line-clamp ml-2 flex-1 leading-tight text-gray-600 dark:text-gray-200"
               >
                 {{ item.message }}
+                <a
+                  v-if="item.messageId"
+                  :href="`https://docs.automa.site/guide/workflow-errors.html#${item.messageId}`"
+                  target="_blank"
+                  title="About the error"
+                  @click.stop
+                >
+                  <v-remixicon
+                    name="riArrowLeftLine"
+                    size="20"
+                    class="text-gray-300 inline-block"
+                    rotate="135"
+                  />
+                </a>
               </p>
               <router-link
                 v-if="item.logId"
@@ -140,14 +169,14 @@
           </select>
           {{
             t('components.pagination.text2', {
-              count: currentLog.history.length,
+              count: filteredLog.length,
             })
           }}
         </div>
         <ui-pagination
           v-model="pagination.currentPage"
           :per-page="pagination.perPage"
-          :records="currentLog.history.length"
+          :records="filteredLog.length"
         />
       </div>
     </div>
@@ -293,6 +322,13 @@ const tabs = [
   { id: 'referenceData.prevBlockData', name: 'Previous block data' },
   { id: 'replacedValue', name: 'Replaced value' },
 ];
+const messageHasReferences = [
+  'no-tab',
+  'invalid-active-tab',
+  'no-match-tab',
+  'invalid-body',
+  'element-not-found',
+];
 
 const { t, te } = useI18n();
 
@@ -310,16 +346,15 @@ const activeLog = shallowRef(null);
 const translatedLog = computed(() =>
   props.currentLog.history.map(translateLog)
 );
-const filteredLog = computed(() =>
-  translatedLog.value.filter((log) => {
-    const query = state.search.toLocaleLowerCase();
+const filteredLog = computed(() => {
+  const query = state.search.toLocaleLowerCase();
 
-    return (
+  return translatedLog.value.filter(
+    (log) =>
       log.name.toLocaleLowerCase().includes(query) ||
       log.description?.toLocaleLowerCase().includes(query)
-    );
-  })
-);
+  );
+});
 const history = computed(() =>
   filteredLog.value.slice(
     (pagination.currentPage - 1) * pagination.perPage,
@@ -333,6 +368,7 @@ const errorBlock = computed(() => {
   if (!block || block.type !== 'error' || block.id < 25) return null;
 
   block = translateLog(block);
+
   let { name } = block;
   if (block.description) name += ` (${block.description})`;
 
@@ -340,6 +376,7 @@ const errorBlock = computed(() => {
     name,
     id: block.id,
     message: block.message,
+    messageId: block.messageId,
   };
 });
 const logCtxData = computed(() => {
@@ -373,6 +410,10 @@ function translateLog(log) {
     );
   }
 
+  if (copyLog.message && messageHasReferences.includes(copyLog.message)) {
+    copyLog.messageId = `${copyLog.message}`;
+  }
+
   copyLog.message = getTranslatation(
     { path: `log.messages.${log.message}`, params: log },
     log.message

+ 0 - 1
src/components/newtab/workflows/WorkflowsLocal.vue

@@ -230,7 +230,6 @@ const pinnedWorkflows = computed(() => {
 });
 
 function executeWorkflow(workflow) {
-  console.log(workflow);
   sendMessage('workflow:execute', workflow, 'background');
 }
 function toggleDisableWorkflow({ id, isDisabled }) {

+ 2 - 2
src/newtab/pages/logs/Running.vue

@@ -26,8 +26,8 @@
           workflowId: running.workflowId,
         }"
       >
-        <template #prepend>
-          <div class="mb-4 text-sm">
+        <template #header-prepend>
+          <div>
             <h3 class="leading-tight">
               {{ t('common.log', 2) }}
             </h3>

+ 1 - 1
src/stores/main.js

@@ -18,7 +18,7 @@ export const useStore = defineStore('main', {
       editor: {
         minZoom: 0.6,
         maxZoom: 1.3,
-        arrow: false,
+        arrow: true,
         snapToGrid: false,
         lineType: 'default',
         snapGrid: { 0: 15, 1: 15 },