Ver código fonte

Merge pull request #623 from mzaini30/dev

feat: collapsible description and auto install
Ahmad Kholid 2 anos atrás
pai
commit
d16dacd04d

+ 1 - 0
.eslintrc.js

@@ -34,6 +34,7 @@ module.exports = {
   rules: {
     camelcase: 'off',
     'no-await-in-loop': 'off',
+    'no-alert': 'off',
     'import/no-import-module-exports': 'off',
     'no-console': ['warn', { allow: ['warn', 'error'] }],
     'no-underscore-dangle': 'off',

+ 2 - 3
package.json

@@ -59,7 +59,7 @@
     "lodash.merge": "^4.6.2",
     "mitt": "^3.0.0",
     "mousetrap": "^1.6.5",
-    "nanoid": "^3.2.0",
+    "nanoid": "^4.0.0",
     "object-path": "^0.11.8",
     "papaparse": "^5.3.1",
     "pinia": "^2.0.14",
@@ -68,7 +68,6 @@
     "v-remixicon": "^0.1.1",
     "vue": "^3.2.37",
     "vue-i18n": "^9.2.0-beta.29",
-    "vue-inspector-agnostic": "^1.0.0",
     "vue-router": "^4.0.11",
     "vue-toastification": "^2.0.0-rc.5",
     "vuedraggable": "^4.1.0",
@@ -118,4 +117,4 @@
     "webpack-cli": "^4.10.0",
     "webpack-dev-server": "^4.9.2"
   }
-}
+}

+ 8 - 1
src/components/newtab/workflow/WorkflowDetailsCard.vue

@@ -39,7 +39,12 @@
       <p class="font-semibold mt-1 text-overflow text-lg leading-tight">
         {{ workflow.name }}
       </p>
-      <p class="line-clamp leading-tight">
+      <p
+        class="leading-tight cursor-pointer"
+        :class="descriptionCollapsed ? 'line-clamp' : null"
+        @click="descriptionCollapsed = !descriptionCollapsed"
+      >
+        <!-- description here -->
         {{ workflow.description }}
       </p>
     </div>
@@ -151,6 +156,8 @@ const categoriesExpand = Object.keys(categories).reduce((acc, key) => {
   return acc;
 }, {});
 
+const descriptionCollapsed = ref(true);
+
 const query = ref('');
 const expandList = ref(categoriesExpand);
 

+ 33 - 0
src/content/index.js

@@ -1,6 +1,8 @@
 import browser from 'webextension-polyfill';
 import findSelector from '@/lib/findSelector';
 import { toCamelCase } from '@/utils/helper';
+import cloneDeep from 'lodash.clonedeep';
+import { nanoid } from 'nanoid';
 import blocksHandler from './blocksHandler';
 import showExecutedBlock from './showExecutedBlock';
 import shortcutListener from './services/shortcutListener';
@@ -233,3 +235,34 @@ function messageListener({ data, source }) {
     });
   });
 })();
+
+// Auto install only works on Chrome
+async function autoInstall() {
+  const link = window.location.href;
+  if (/.+\.automa\.json$/.test(link)) {
+    const accept = window.confirm(
+      'Do you want to add this workflow into Automa?'
+    );
+    if (!accept) return;
+    const workflow = JSON.parse(document.body.innerText);
+
+    const { workflows: workflowsStorage } = await browser.storage.local.get(
+      'workflows'
+    );
+    const copyWorkflow = cloneDeep(workflow);
+
+    copyWorkflow.table = copyWorkflow.table || copyWorkflow.dataColumns;
+    copyWorkflow.dataColumns = [];
+
+    workflowsStorage.push({
+      ...workflow,
+      id: nanoid(),
+      createdAt: Date.now(),
+    });
+
+    await browser.storage.local.set({ workflows: workflowsStorage });
+
+    alert('Workflow installed');
+  }
+}
+autoInstall();

+ 4 - 12
src/manifest.chrome.json

@@ -2,9 +2,7 @@
   "manifest_version": 2,
   "name": "Automa",
   "background": {
-    "scripts": [
-      "background.bundle.js"
-    ],
+    "scripts": ["background.bundle.js"],
     "persistent": false
   },
   "browser_action": {
@@ -25,12 +23,8 @@
   },
   "content_scripts": [
     {
-      "matches": [
-        "<all_urls>"
-      ],
-      "js": [
-        "contentScript.bundle.js"
-      ],
+      "matches": ["<all_urls>"],
+      "js": ["contentScript.bundle.js"],
       "all_frames": true
     },
     {
@@ -39,9 +33,7 @@
         "*://*.automa.site/*",
         "*://automa.vercel.app/*"
       ],
-      "js": [
-        "webService.bundle.js"
-      ],
+      "js": ["webService.bundle.js"],
       "all_frames": false
     }
   ],

+ 6 - 21
src/manifest.firefox.json

@@ -7,9 +7,7 @@
     }
   },
   "background": {
-    "scripts": [
-      "background.bundle.js"
-    ],
+    "scripts": ["background.bundle.js"],
     "persistent": false
   },
   "browser_action": {
@@ -30,30 +28,17 @@
   },
   "content_scripts": [
     {
-      "matches": [
-        "<all_urls>"
-      ],
-      "js": [
-        "contentScript.bundle.js"
-      ],
+      "matches": ["<all_urls>"],
+      "js": ["contentScript.bundle.js"],
       "all_frames": true
     },
     {
-      "matches": [
-        "*://*.automa.site/*",
-        "*://automa.vercel.app/*"
-      ],
-      "js": [
-        "webService.bundle.js"
-      ],
+      "matches": ["*://*.automa.site/*", "*://automa.vercel.app/*"],
+      "js": ["webService.bundle.js"],
       "all_frames": false
     }
   ],
-  "optional_permissions": [
-    "clipboardRead",
-    "downloads",
-    "notifications"
-  ],
+  "optional_permissions": ["clipboardRead", "downloads", "notifications"],
   "permissions": [
     "tabs",
     "proxy",

+ 3 - 0
src/newtab/App.vue

@@ -231,12 +231,15 @@ html,
 body {
   @apply bg-gray-50 dark:bg-gray-900 text-black dark:text-gray-100;
 }
+
 body {
   min-height: 100vh;
 }
+
 #app {
   height: 100%;
 }
+
 h1,
 h2,
 h3 {

+ 1 - 1
src/utils/workflowData.js

@@ -206,7 +206,7 @@ export function exportWorkflow(workflow) {
   });
   const url = URL.createObjectURL(blob);
 
-  fileSaver(`${workflow.name}.json`, url);
+  fileSaver(`${workflow.name}.automa.json`, url);
 }
 
 export default {

+ 6 - 6
yarn.lock

@@ -4800,11 +4800,16 @@ multicast-dns@^7.2.5:
     dns-packet "^5.2.2"
     thunky "^1.0.2"
 
-nanoid@^3.2.0, nanoid@^3.3.4:
+nanoid@^3.3.4:
   version "3.3.4"
   resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.4.tgz#730b67e3cd09e2deacf03c027c81c9d9dbc5e8ab"
   integrity sha512-MqBkQh/OHTS2egovRtLk45wEyNXwF+cokD+1YPf9u5VfJiRdAiRwB2froX5Co9Rh20xs4siNPm8naNotSD6RBw==
 
+nanoid@^4.0.0:
+  version "4.0.0"
+  resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-4.0.0.tgz#6e144dee117609232c3f415c34b0e550e64999a5"
+  integrity sha512-IgBP8piMxe/gf73RTQx7hmnhwz0aaEXYakvqZyE302IXW3HyVNhdNGC+O2MwMAVhLEnvXlvKtGbtJf6wvHihCg==
+
 natural-compare@^1.4.0:
   version "1.4.0"
   resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7"
@@ -6405,11 +6410,6 @@ vue-i18n@^9.2.0-beta.29:
     "@intlify/vue-devtools" "9.2.0-beta.36"
     "@vue/devtools-api" "^6.0.0-beta.13"
 
-vue-inspector-agnostic@^1.0.0:
-  version "1.0.0"
-  resolved "https://registry.yarnpkg.com/vue-inspector-agnostic/-/vue-inspector-agnostic-1.0.0.tgz#e98d317a1c37619e84c69b1f216eab94970fa253"
-  integrity sha512-8awtLkMS1ohA6xplv/f/L6cJoAJNFO6vhHz61xjCJZMwPveMI45k1yMUkxmVJJOkZJoR8SCWSUN7RLbZeOUsRQ==
-
 vue-loader@^17.0.0:
   version "17.0.0"
   resolved "https://registry.yarnpkg.com/vue-loader/-/vue-loader-17.0.0.tgz#2eaa80aab125b19f00faa794b5bd867b17f85acb"