Skip to content

Commit

Permalink
v1.28.22
Browse files Browse the repository at this point in the history
  • Loading branch information
Kholid060 committed Nov 21, 2023
2 parents f3e75ee + e6438b9 commit 2010e7a
Show file tree
Hide file tree
Showing 19 changed files with 60 additions and 29 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "automa",
"version": "1.28.21",
"version": "1.28.22",
"description": "An extension for automating your browser by connecting blocks",
"repository": {
"type": "git",
Expand Down
6 changes: 6 additions & 0 deletions src/newtab/pages/workflows/[id].vue
Original file line number Diff line number Diff line change
Expand Up @@ -1528,6 +1528,12 @@ function checkWorkflowUpdate() {
}
/* eslint-disable consistent-return */
function onBeforeLeave() {
// disselect node before leave
const selectedNodes = editor.value.getSelectedNodes.value;
selectedNodes?.forEach((node) => {
node.selected = false;
});
updateHostedWorkflow();
const dataNotChanged = !state.dataChanged || !haveEditAccess.value;
Expand Down
8 changes: 6 additions & 2 deletions src/params/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@
</p>
<div class="px-4 pb-4">
<ul class="space-y-4 divide-y">
<li v-for="(param, paramIdx) in workflow.params" :key="paramIdx">
<li
v-for="(param, paramIdx) in workflow.params"
:key="paramIdx"
class="flex flex-col gap-3"
>
<component
:is="paramsList[param.type].valueComp"
v-if="paramsList[param.type]"
Expand All @@ -74,7 +78,7 @@
<p
v-if="param.description"
title="Description"
class="ml-1 whitespace-pre text-sm leading-tight"
class="ml-1 text-sm leading-tight"
>
{{ param.description }}
</p>
Expand Down
15 changes: 10 additions & 5 deletions src/workflowEngine/WorkflowWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class WorkflowWorker {
currentColumn.index += 1;
}

setVariable(name, value) {
async setVariable(name, value) {
let variableName = name;
const vars = this.engine.referenceData.variables;

Expand All @@ -127,10 +127,15 @@ class WorkflowWorker {
}

if (variableName.startsWith('$$')) {
dbStorage.variables.put({
value,
name: variableName.slice(2),
variableName = variableName.slice(2);

const findStorageVar = await dbStorage.variables.get({
name: variableName,
});

if (findStorageVar)
await dbStorage.variables.update(findStorageVar.id, { value });
else await dbStorage.variables.add({ name: variableName, value });
}

this.engine.addRefDataSnapshot('variables');
Expand Down Expand Up @@ -392,7 +397,7 @@ class WorkflowWorker {
value = parseJSON(value, value);

if (item.type === 'variable') {
this.setVariable(item.name, value);
await this.setVariable(item.name, value);
} else {
this.addDataToColumn(item.name, value);
}
Expand Down
2 changes: 1 addition & 1 deletion src/workflowEngine/blocksHandler/handlerClipboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export default async function ({ data, id, label }) {
valueToReturn = copiedText;

if (data.assignVariable) {
this.setVariable(data.variableName, copiedText);
await this.setVariable(data.variableName, copiedText);
}
if (data.saveData) {
this.addDataToColumn(data.dataColumn, copiedText);
Expand Down
2 changes: 1 addition & 1 deletion src/workflowEngine/blocksHandler/handlerCookie.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ async function cookie({ data, id }) {

if (data.type === 'get') {
if (data.assignVariable) {
this.setVariable(data.variableName, result);
await this.setVariable(data.variableName, result);
}
if (data.saveData) {
this.addDataToColumn(data.dataColumn, result);
Expand Down
2 changes: 1 addition & 1 deletion src/workflowEngine/blocksHandler/handlerDataMapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export async function dataMapping({ id, data }) {
}

if (data.assignVariable) {
this.setVariable(data.variableName, dataToMap);
await this.setVariable(data.variableName, dataToMap);
}
if (data.saveData) {
this.addDataToColumn(data.dataColumn, dataToMap);
Expand Down
4 changes: 2 additions & 2 deletions src/workflowEngine/blocksHandler/handlerGoogleSheets.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ export default async function ({ data, id }, { refData }) {
result = await getSpreadsheetRange(data);

if (data.assignVariable) {
this.setVariable(data.variableName, result);
await this.setVariable(data.variableName, result);
}
if (data.saveData) {
this.addDataToColumn(data.dataColumn, result);
Expand All @@ -172,7 +172,7 @@ export default async function ({ data, id }, { refData }) {
result = spreadsheetId;

if (data.assignVariable) {
this.setVariable(data.variableName, result);
await this.setVariable(data.variableName, result);
}
if (data.saveData) {
this.addDataToColumn(data.dataColumn, result);
Expand Down
2 changes: 1 addition & 1 deletion src/workflowEngine/blocksHandler/handlerHandleDownload.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ async function handleDownload({ data, id: blockId }) {
this.addDataToColumn(data.dataColumn, downloadItem.filename);
}
if (data.assignVariable) {
this.setVariable(data.variableName, downloadItem.filename);
await this.setVariable(data.variableName, downloadItem.filename);
}

return {
Expand Down
2 changes: 1 addition & 1 deletion src/workflowEngine/blocksHandler/handlerInsertData.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ async function insertData({ id, data }, { refData }) {
this.addDataToColumn(item.name, tableValue);
});
} else {
this.setVariable(item.name, value);
await this.setVariable(item.name, value);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ async function interactionHandler(block) {
}

if (block.data.assignVariable) {
this.setVariable(block.data.variableName, data);
await this.setVariable(block.data.variableName, data);
}

if (debugMode && isChrome) {
Expand Down
21 changes: 17 additions & 4 deletions src/workflowEngine/blocksHandler/handlerJavascriptCode.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,11 @@ export async function javascriptCode({ outputs, data, ...block }, { refData }) {
}

if (result.variables) {
Object.keys(result.variables).forEach((varName) => {
this.setVariable(varName, result.variables[varName]);
});
await Promise.allSettled(
Object.keys(result.variables).map(async (varName) => {
await this.setVariable(varName, result.variables[varName]);
})
);
}

let insert = true;
Expand All @@ -222,10 +224,21 @@ export async function javascriptCode({ outputs, data, ...block }, { refData }) {
insert = typeof insertData === 'boolean' ? insertData : true;

if (inputNextBlockId) {
const customNextBlockId = this.getBlockConnections(inputNextBlockId);
let customNextBlockId = this.getBlockConnections(inputNextBlockId);
if (!customNextBlockId)
throw new Error(`Can't find block with "${inputNextBlockId}" id`);

const nextBlock = this.engine.blocks[inputNextBlockId];
if (!customNextBlockId && nextBlock) {
customNextBlockId = [
{
id: inputNextBlockId,
blockId: inputNextBlockId,
connections: new Map([]),
},
];
}

nextBlockId = customNextBlockId;
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/workflowEngine/blocksHandler/handlerLogData.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export async function logData({ id, data }) {
logs = getTranslateLog(curWorkflowState, 'json');

if (data.assignVariable) {
this.setVariable(data.variableName, logs);
await this.setVariable(data.variableName, logs);
}
if (data.saveData) {
this.addDataToColumn(data.dataColumn, logs);
Expand Down
8 changes: 5 additions & 3 deletions src/workflowEngine/blocksHandler/handlerParameterPrompt.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,11 @@ export default async function ({ data, id }) {

const result = await getInputtedParams(promptId, timeout);

Object.entries(result).forEach(([varName, varValue]) => {
this.setVariable(varName, varValue);
});
await Promise.allSettled(
Object.entries(result).map(async ([varName, varValue]) =>
this.setVariable(varName, varValue)
)
);

return {
data: '',
Expand Down
2 changes: 1 addition & 1 deletion src/workflowEngine/blocksHandler/handlerSaveAssets.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export default async function ({ data, id, label }) {

if (data.saveDownloadIds) {
if (data.assignVariable) {
this.setVariable(data.variableName, downloadIds);
await this.setVariable(data.variableName, downloadIds);
}
if (data.saveData) {
this.addDataToColumn(data.dataColumn, downloadIds);
Expand Down
2 changes: 1 addition & 1 deletion src/workflowEngine/blocksHandler/handlerSortData.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export async function sliceData({ id, data }) {
});

if (data.assignVariable) {
this.setVariable(data.variableName, sortedArray);
await this.setVariable(data.variableName, sortedArray);
}
if (data.saveData) {
this.addDataToColumn(data.dataColumn, sortedArray);
Expand Down
2 changes: 1 addition & 1 deletion src/workflowEngine/blocksHandler/handlerTabUrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export async function logData({ id, data }) {
}

if (data.assignVariable) {
this.setVariable(data.variableName, urls);
await this.setVariable(data.variableName, urls);
}
if (data.saveData) {
this.addDataToColumn(data.dataColumn, urls);
Expand Down
3 changes: 2 additions & 1 deletion src/workflowEngine/blocksHandler/handlerTakeScreenshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ async function takeScreenshot({ data, id, label }) {
uri: dataUrl,
ext: data.ext,
});
if (data.assignVariable) this.setVariable(data.variableName, dataUrl);
if (data.assignVariable)
await this.setVariable(data.variableName, dataUrl);
};

if (data.captureActiveTab) {
Expand Down
2 changes: 1 addition & 1 deletion src/workflowEngine/blocksHandler/handlerWebhook.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export async function webhook({ data, id }, { refData }) {
}

if (data.assignVariable) {
this.setVariable(data.variableName, returnData);
await this.setVariable(data.variableName, returnData);
}
if (data.saveData) {
if (data.dataColumn === '$assignColumns' && Array.isArray(returnData)) {
Expand Down

0 comments on commit 2010e7a

Please sign in to comment.