From 2eeb2f45d80ed29d311b4bdfb407470ed1df44b6 Mon Sep 17 00:00:00 2001 From: Ahmad Kholid Date: Mon, 8 Jan 2024 15:39:18 +0800 Subject: [PATCH 1/7] fix: workflow package execution not working (#1611) --- .../blocksHandler/handlerBlockPackage.js | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/workflowEngine/blocksHandler/handlerBlockPackage.js b/src/workflowEngine/blocksHandler/handlerBlockPackage.js index d018455b2..3a49f1e28 100644 --- a/src/workflowEngine/blocksHandler/handlerBlockPackage.js +++ b/src/workflowEngine/blocksHandler/handlerBlockPackage.js @@ -30,21 +30,23 @@ export default async function ( const outputsMap = new Set(); data.inputs.forEach((item) => { - connections[addBlockPrefix(item.id)] = [ - { - id: addBlockPrefix(item.blockId), - targetId: `${addBlockPrefix(block.id)}-input-1`, - }, - ]; + connections[addBlockPrefix(item.id)] = new Map([ + [ + item.id, + { + id: addBlockPrefix(item.blockId), + targetId: `${addBlockPrefix(block.id)}-input-1`, + }, + ], + ]); }); data.outputs.forEach((output) => { - outputsMap.add(output.handleId); - const connection = this.engine.connectionsMap[`${id}-output-${output.id}`]; if (!connection) return; - connections[addBlockPrefix(output.handleId)] = [...connection.values()]; + connections[addBlockPrefix(output.handleId)] = new Map(connection); + outputsMap.add(output.handleId); }); data.data.nodes.forEach((node) => { From 3d6695f6945a485a8ef37fc786779506aec9ecde Mon Sep 17 00:00:00 2001 From: Ahmad Kholid Date: Fri, 12 Jan 2024 15:06:21 +0800 Subject: [PATCH 2/7] feat: sorter in workflow table columns (#1616) --- .../newtab/storage/StorageEditTable.vue | 75 ++++++++++++------- src/locales/en/newtab.json | 1 + src/newtab/pages/storage/Tables.vue | 1 + 3 files changed, 49 insertions(+), 28 deletions(-) diff --git a/src/components/newtab/storage/StorageEditTable.vue b/src/components/newtab/storage/StorageEditTable.vue index fbf66deb1..b5bca220c 100644 --- a/src/components/newtab/storage/StorageEditTable.vue +++ b/src/components/newtab/storage/StorageEditTable.vue @@ -6,7 +6,7 @@ style="height: 600px" >

- {{ t('storage.table.add') }} + {{ title || t('storage.table.add') }}

{{ t('message.noData') }}

-
    -
  • - - - - - -
  • -
+ + +
@@ -73,6 +84,7 @@ import { reactive, toRaw, watch } from 'vue'; import { useI18n } from 'vue-i18n'; import { nanoid } from 'nanoid'; +import draggable from 'vuedraggable'; import cloneDeep from 'lodash.clonedeep'; import { dataTypes } from '@/utils/constants/table'; @@ -85,6 +97,10 @@ const props = defineProps({ type: String, default: '', }, + title: { + type: String, + default: '', + }, columns: { type: Array, default: () => [], @@ -122,7 +138,10 @@ function updateColumnName(index, target) { state.columns[index].name = columnName; } function saveTable() { - const rawState = toRaw(state); + const rawState = { + ...toRaw(state), + columns: state.columns.map(toRaw), + }; emit('save', { ...rawState, changes }); } diff --git a/src/locales/en/newtab.json b/src/locales/en/newtab.json index b1f34d90a..2cf0a7263 100644 --- a/src/locales/en/newtab.json +++ b/src/locales/en/newtab.json @@ -42,6 +42,7 @@ "title": "Storage", "table": { "add": "Add table", + "edit": "Edit table", "createdAt": "Created at", "modifiedAt": "Modified at", "rowsCount": "Rows count", diff --git a/src/newtab/pages/storage/Tables.vue b/src/newtab/pages/storage/Tables.vue index 22995224a..5e0e2e96a 100644 --- a/src/newtab/pages/storage/Tables.vue +++ b/src/newtab/pages/storage/Tables.vue @@ -75,6 +75,7 @@
Date: Fri, 12 Jan 2024 15:20:14 +0800 Subject: [PATCH 3/7] fix: double backslash in variable value (#1608) --- src/components/newtab/logs/LogsVariables.vue | 4 +++- src/newtab/pages/settings/SettingsBackup.vue | 1 + src/stores/workflow.js | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/components/newtab/logs/LogsVariables.vue b/src/components/newtab/logs/LogsVariables.vue index ec8752259..d93752283 100644 --- a/src/components/newtab/logs/LogsVariables.vue +++ b/src/components/newtab/logs/LogsVariables.vue @@ -29,7 +29,9 @@ readonly /> { settings: { publicId: '', blockDelay: 0, - saveLog: false, + saveLog: true, debugMode: false, restartTimes: 3, notification: true, From f3c2deca10bd09a7cd346965600a506e598cbf7a Mon Sep 17 00:00:00 2001 From: Ahmad Kholid Date: Fri, 12 Jan 2024 15:37:41 +0800 Subject: [PATCH 4/7] fix: duplicate when restore workflows backup (#1615) --- src/newtab/pages/settings/SettingsBackup.vue | 4 +++- src/stores/workflow.js | 8 ++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/newtab/pages/settings/SettingsBackup.vue b/src/newtab/pages/settings/SettingsBackup.vue index c029813c8..bbda77186 100644 --- a/src/newtab/pages/settings/SettingsBackup.vue +++ b/src/newtab/pages/settings/SettingsBackup.vue @@ -410,7 +410,9 @@ async function restoreWorkflows() { }; if (state.updateIfExists) { - return workflowStore.insertOrUpdate(newWorkflows).then(showMessage); + return workflowStore + .insertOrUpdate(newWorkflows, { duplicateId: true }) + .then(showMessage); } return workflowStore.insert(newWorkflows).then(showMessage); diff --git a/src/stores/workflow.js b/src/stores/workflow.js index b7b06a1ab..870b3a238 100644 --- a/src/stores/workflow.js +++ b/src/stores/workflow.js @@ -211,11 +211,15 @@ export const useWorkflowStore = defineStore('workflow', { return updatedWorkflows; }, - async insertOrUpdate(data = [], { checkUpdateDate = false } = {}) { + async insertOrUpdate( + data = [], + { checkUpdateDate = false, duplicateId = false } = {} + ) { const insertedData = {}; data.forEach((item) => { const currentWorkflow = this.workflows[item.id]; + if (currentWorkflow) { let insert = true; if (checkUpdateDate && currentWorkflow.createdAt && item.updatedAt) { @@ -229,7 +233,7 @@ export const useWorkflowStore = defineStore('workflow', { insertedData[item.id] = mergedData; } } else { - const workflow = defaultWorkflow(item); + const workflow = defaultWorkflow(item, { duplicateId }); this.workflows[workflow.id] = workflow; insertedData[workflow.id] = workflow; } From 5f1caf11735e2b0c55c6418918a3932e900451b2 Mon Sep 17 00:00:00 2001 From: Ahmad Kholid Date: Fri, 12 Jan 2024 16:18:12 +0800 Subject: [PATCH 5/7] feat: executing workflow through URL(#1607) --- src/execute/index.html | 10 +++++++ src/execute/index.js | 61 ++++++++++++++++++++++++++++++++++++++++++ webpack.config.js | 7 +++++ 3 files changed, 78 insertions(+) create mode 100644 src/execute/index.html create mode 100644 src/execute/index.js diff --git a/src/execute/index.html b/src/execute/index.html new file mode 100644 index 000000000..ba2f77bf4 --- /dev/null +++ b/src/execute/index.html @@ -0,0 +1,10 @@ + + + + + + Execute + + + + diff --git a/src/execute/index.js b/src/execute/index.js new file mode 100644 index 000000000..360726f00 --- /dev/null +++ b/src/execute/index.js @@ -0,0 +1,61 @@ +import { sendMessage } from '@/utils/message'; +import Browser from 'webextension-polyfill'; + +function getWorkflowDetail() { + let hash = window.location.hash.slice(1); + if (!hash.startsWith('/')) hash = `/${hash}`; + + const { pathname, searchParams } = new URL(window.location.origin + hash); + + const variables = {}; + const { 1: workflowId } = pathname.split('/'); + + searchParams.forEach((key, value) => { + variables[key] = decodeURIComponent(value); + }); + + return { workflowId: workflowId ?? '', variables }; +} + +function writeResult(text) { + document.body.innerText = text; +} + +(async () => { + try { + const { workflowId, variables } = getWorkflowDetail(); + if (!workflowId) { + writeResult('Invalid path'); + return; + } + + const { workflows } = await Browser.storage.local.get('workflows'); + + let workflow = workflows[workflowId]; + if (!workflow && Array.isArray(workflows)) { + workflow = workflows.find((item) => item.id === workflowId); + } + + if (!workflow) { + writeResult('Workflow not found'); + return; + } + + const hasVariables = Object.keys(variables).length > 0; + + writeResult('Executing workflow'); + + sendMessage( + 'workflow:execute', + { + ...workflow, + options: { checkParam: !hasVariables, data: { variables } }, + }, + 'background' + ).then(() => { + setTimeout(window.close, 1000); + }); + } catch (error) { + console.error(error); + } +})(); diff --git a/webpack.config.js b/webpack.config.js index 9f9af9fb7..46f196b5a 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -41,6 +41,7 @@ const options = { mode: process.env.NODE_ENV || 'development', entry: { sandbox: path.join(__dirname, 'src', 'sandbox', 'index.js'), + execute: path.join(__dirname, 'src', 'execute', 'index.js'), newtab: path.join(__dirname, 'src', 'newtab', 'index.js'), popup: path.join(__dirname, 'src', 'popup', 'index.js'), params: path.join(__dirname, 'src', 'params', 'index.js'), @@ -200,6 +201,12 @@ const options = { chunks: ['sandbox'], cache: false, }), + new HtmlWebpackPlugin({ + template: path.join(__dirname, 'src', 'execute', 'index.html'), + filename: 'execute.html', + chunks: ['execute'], + cache: false, + }), new HtmlWebpackPlugin({ template: path.join(__dirname, 'src', 'popup', 'index.html'), filename: 'popup.html', From b5200ca1b2f4b44a42e21fc9ee5aacdf40683d20 Mon Sep 17 00:00:00 2001 From: Ahmad Kholid Date: Fri, 12 Jan 2024 16:53:55 +0800 Subject: [PATCH 6/7] v1.28.26 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 31167c9b5..18192ccfd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "automa", - "version": "1.28.25", + "version": "1.28.26", "description": "An extension for automating your browser by connecting blocks", "repository": { "type": "git", From 1332572991e1f3c27834ffcc2caa2b25fbca85d0 Mon Sep 17 00:00:00 2001 From: Ahmad Kholid Date: Fri, 12 Jan 2024 17:03:46 +0800 Subject: [PATCH 7/7] fix: query value --- src/execute/index.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/execute/index.js b/src/execute/index.js index 360726f00..08dc4832f 100644 --- a/src/execute/index.js +++ b/src/execute/index.js @@ -1,3 +1,4 @@ +import { parseJSON } from '@/utils/helper'; import { sendMessage } from '@/utils/message'; import Browser from 'webextension-polyfill'; @@ -11,7 +12,10 @@ function getWorkflowDetail() { const { 1: workflowId } = pathname.split('/'); searchParams.forEach((key, value) => { - variables[key] = decodeURIComponent(value); + const varValue = parseJSON(decodeURIComponent(value), '##_empty'); + if (varValue === '##_empty') return; + + variables[key] = varValue; }); return { workflowId: workflowId ?? '', variables };