fix(plugin-workflow): fix loop scope variable (#2989)
This commit is contained in:
parent
3802ca38f8
commit
30de7865c5
@ -8,7 +8,14 @@ import { Branch } from '../Branch';
|
|||||||
import { useFlowContext } from '../FlowContext';
|
import { useFlowContext } from '../FlowContext';
|
||||||
import { NAMESPACE, lang } from '../locale';
|
import { NAMESPACE, lang } from '../locale';
|
||||||
import useStyles from '../style';
|
import useStyles from '../style';
|
||||||
import { VariableOption, WorkflowVariableInput, defaultFieldNames, nodesOptions, triggerOptions } from '../variable';
|
import {
|
||||||
|
VariableOption,
|
||||||
|
WorkflowVariableInput,
|
||||||
|
defaultFieldNames,
|
||||||
|
nodesOptions,
|
||||||
|
scopeOptions,
|
||||||
|
triggerOptions,
|
||||||
|
} from '../variable';
|
||||||
|
|
||||||
function findOption(options: VariableOption[], paths: string[]) {
|
function findOption(options: VariableOption[], paths: string[]) {
|
||||||
let opts = options;
|
let opts = options;
|
||||||
@ -121,8 +128,8 @@ export default {
|
|||||||
.split('.')
|
.split('.')
|
||||||
.map((path) => path.trim());
|
.map((path) => path.trim());
|
||||||
|
|
||||||
const targetOptions = [nodesOptions, triggerOptions].map((item: any) => {
|
const targetOptions = [scopeOptions, nodesOptions, triggerOptions].map((item: any) => {
|
||||||
const opts = item.useOptions(options).filter(Boolean);
|
const opts = item.useOptions({ ...options, current: node }).filter(Boolean);
|
||||||
return {
|
return {
|
||||||
[fieldNames.label]: compile(item.label),
|
[fieldNames.label]: compile(item.label),
|
||||||
[fieldNames.value]: item.value,
|
[fieldNames.value]: item.value,
|
||||||
|
@ -34,6 +34,7 @@ export type OptionsOfUseVariableOptions = {
|
|||||||
};
|
};
|
||||||
appends?: string[] | null;
|
appends?: string[] | null;
|
||||||
depth?: number;
|
depth?: number;
|
||||||
|
current?: any;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const defaultFieldNames = { label: 'label', value: 'value', children: 'children' } as const;
|
export const defaultFieldNames = { label: 'label', value: 'value', children: 'children' } as const;
|
||||||
@ -70,9 +71,10 @@ export const scopeOptions = {
|
|||||||
label: `{{t("Scope variables", { ns: "${NAMESPACE}" })}}`,
|
label: `{{t("Scope variables", { ns: "${NAMESPACE}" })}}`,
|
||||||
value: '$scopes',
|
value: '$scopes',
|
||||||
useOptions(options: OptionsOfUseVariableOptions) {
|
useOptions(options: OptionsOfUseVariableOptions) {
|
||||||
const { fieldNames = defaultFieldNames } = options;
|
const { fieldNames = defaultFieldNames, current } = options;
|
||||||
const current = useNodeContext();
|
const source = useNodeContext();
|
||||||
const scopes = useUpstreamScopes(current);
|
const from = current ?? source;
|
||||||
|
const scopes = useUpstreamScopes(from);
|
||||||
const result: VariableOption[] = [];
|
const result: VariableOption[] = [];
|
||||||
scopes.forEach((node) => {
|
scopes.forEach((node) => {
|
||||||
const instruction = instructions.get(node.type);
|
const instruction = instructions.get(node.type);
|
||||||
|
Loading…
Reference in New Issue
Block a user