Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Use all current workflow globalData #1367

Merged
merged 2 commits into from
Sep 14, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
feat: insertAllGlobalData
  • Loading branch information
Siykt committed Sep 13, 2023
commit 9a91b62bb0c3b19d4d0b11d8c1e35343089eb2e1
7 changes: 7 additions & 0 deletions src/components/newtab/workflow/edit/EditExecuteWorkflow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@
<p class="mt-4 ml-1 mb-1 text-sm text-gray-600 dark:text-gray-200">
{{ t('common.globalData') }}
</p>
<ui-checkbox
:model-value="data.insertAllGlobalData"
class="mb-4 leading-tight text-sm"
@change="updateData({ insertAllGlobalData: $event })"
>
{{ t('workflow.blocks.execute-workflow.insertAllGlobalData') }}
</ui-checkbox>
<pre
v-if="!state.showGlobalData"
class="max-h-80 overflow-auto rounded-lg bg-gray-900 p-4 text-gray-200"
Expand Down
1 change: 1 addition & 0 deletions src/utils/shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export const tasks = {
globalData: '',
description: '',
insertAllVars: false,
insertAllGlobalData: false,
},
},
'active-tab': {
Expand Down
15 changes: 12 additions & 3 deletions src/workflowEngine/blocksHandler/handlerExecuteWorkflow.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function findWorkflow(workflows, workflowId) {
return workflow;
}

async function executeWorkflow({ id: blockId, data }) {
async function executeWorkflow({ id: blockId, data }, { refData }) {
if (data.workflowId === '') throw new Error('empty-workflow');

const { workflows, teamWorkflows } = await browser.storage.local.get([
Expand Down Expand Up @@ -74,8 +74,17 @@ async function executeWorkflow({ id: blockId, data }) {

if (workflow.testingMode) workflow.testingMode = false;

if (!isWhitespace(data.globalData))
optionsParams.globalData = data.globalData;
if (data.insertAllGlobalData) {
optionsParams.globalData = refData.globalData;
}

if (!isWhitespace(data.globalData)) {
// shallow copy
optionsParams.globalData = {
...optionsParams.globalData,
...JSON.parse(data.globalData),
};
}

if (data.insertAllVars) {
optionsParams.variables = JSON.parse(
Expand Down