Skip to content

Commit

Permalink
Merge pull request #1411 from AutomaApp/dev
Browse files Browse the repository at this point in the history
v1.28.14
  • Loading branch information
Kholid060 committed Oct 2, 2023
2 parents 3d02666 + e9be664 commit 13b0c12
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 28 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.13",
"version": "1.28.14",
"description": "An extension for automating your browser by connecting blocks",
"repository": {
"type": "git",
Expand Down
18 changes: 3 additions & 15 deletions src/newtab/pages/workflows/[id].vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div v-if="workflow" class="flex h-screen">
<div v-if="workflow" class="flex" style="height: calc(100vh - 40px)">
<div
v-if="state.showSidebar && haveEditAccess"
:class="
Expand Down Expand Up @@ -167,7 +167,8 @@
:data="editorData"
:disabled="isTeamWorkflow && !haveEditAccess"
:class="{ 'animate-blocks': state.animateBlocks }"
class="workflow-editor h-screen focus:outline-none"
class="workflow-editor focus:outline-none"
style="height: calc(100vh - 40px)"
tabindex="0"
@init="onEditorInit"
@edit="initEditBlock"
Expand Down Expand Up @@ -295,8 +296,6 @@ import {
computed,
onMounted,
shallowRef,
onActivated,
onDeactivated,
onBeforeUnmount,
} from 'vue';
import cloneDeep from 'lodash.clonedeep';
Expand Down Expand Up @@ -1527,7 +1526,6 @@ function checkWorkflowUpdate() {
}
/* eslint-disable consistent-return */
function onBeforeLeave() {
document.documentElement.classList.remove('scroll');
updateHostedWorkflow();
const dataNotChanged = !state.dataChanged || !haveEditAccess.value;
Expand Down Expand Up @@ -1574,20 +1572,12 @@ watch(
);
onBeforeRouteLeave(onBeforeLeave);
onActivated(() => {
document.documentElement.classList.add('scroll');
});
onDeactivated(() => {
document.documentElement.classList.remove('scroll');
});
onMounted(() => {
if (!workflow.value) {
router.replace(isPackage ? '/packages' : '/');
return null;
}
document.documentElement.classList.add('scroll');
const sidebarState =
JSON.parse(localStorage.getItem('workflow:sidebar')) ?? true;
state.showSidebar = sidebarState;
Expand Down Expand Up @@ -1616,8 +1606,6 @@ onMounted(() => {
initAutocomplete();
});
onBeforeUnmount(() => {
document.documentElement.classList.remove('scroll');
if (isPackage && workflow.value.isExternal) return;
updateHostedWorkflow();
});
Expand Down
17 changes: 11 additions & 6 deletions src/newtab/pages/workflows/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -457,12 +457,17 @@ function updateActiveTab(data = {}) {
Object.assign(state, data);
}
function addWorkflow() {
workflowStore.insert({
name: addWorkflowModal.name,
folderId: state.activeFolder,
description: addWorkflowModal.description,
});
clearAddWorkflowModal();
workflowStore
.insert({
name: addWorkflowModal.name,
folderId: state.activeFolder,
description: addWorkflowModal.description,
})
.then((workflows) => {
const workflowId = Object.keys(workflows)[0];
router.push(`/workflows/${workflowId}`);
})
.finally(clearAddWorkflowModal);
}
async function checkWorkflowPermissions(workflows) {
let requiredPermissions = [];
Expand Down
11 changes: 8 additions & 3 deletions src/workflowEngine/templating/mustacheReplacer.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ export function keyParser(key, data) {
return { dataKey: 'table', path };
}

function replacer(str, { regex, tagLen, modifyPath, data }) {
function replacer(
str,
{ regex, tagLen, modifyPath, data, disableStringify = false }
) {
const replaceResult = {
list: {},
value: str,
Expand Down Expand Up @@ -113,7 +116,7 @@ function replacer(str, { regex, tagLen, modifyPath, data }) {
}

const finalResult =
typeof result === 'string' && !stringify
disableStringify || (typeof result === 'string' && !stringify)
? result
: JSON.stringify(result);

Expand All @@ -125,7 +128,7 @@ function replacer(str, { regex, tagLen, modifyPath, data }) {
return replaceResult;
}

export default function (str, refData) {
export default function (str, refData, options = {}) {
if (!str || typeof str !== 'string') return '';

const data = { ...refData, functions: templatingFunctions };
Expand All @@ -140,11 +143,13 @@ export default function (str, refData) {
data,
tagLen: 1,
regex: /\[(.*?)\]/g,
...options,
});
Object.assign(replacedList, list);

return value;
},
...options,
});

Object.assign(replacedStr.list, replacedList);
Expand Down
4 changes: 2 additions & 2 deletions src/workflowEngine/templating/renderString.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import mustacheReplacer from './mustacheReplacer';
const isFirefox = BROWSER_TYPE === 'firefox';
const isMV2 = browser.runtime.getManifest().manifest_version === 2;

export default async function (str, data, isPopup = true) {
export default async function (str, data, isPopup = true, options = {}) {
if (!str || typeof str !== 'string') return '';

const hasMustacheTag = /\{\{(.*?)\}\}/.test(str);
Expand All @@ -32,7 +32,7 @@ export default async function (str, data, isPopup = true) {
let copyStr = `${str}`;
if (evaluateJS) copyStr = copyStr.slice(2);

renderedValue = mustacheReplacer(copyStr, data);
renderedValue = mustacheReplacer(copyStr, data, options);
}

return renderedValue;
Expand Down
2 changes: 1 addition & 1 deletion src/workflowEngine/utils/testConditions.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export default async function (conditionsArr, workflowData) {
workflowData.isPopup
);

copyData[key] = parseJSON(value, value);
copyData[key] = value ?? '';
Object.assign(result.replacedValue, list);
}

Expand Down

0 comments on commit 13b0c12

Please sign in to comment.