fix(plugin-workflow): fix variable api caller in loop (#1877)
This commit is contained in:
parent
7b3e16ce63
commit
c988c3705a
@ -28,7 +28,7 @@ function AssociatedConfig({ value, onChange, ...props }): JSX.Element {
|
||||
const { getCollection } = useCollectionManager();
|
||||
const current = useNodeContext();
|
||||
const options = [nodesOptions, triggerOptions].map((item) => {
|
||||
const children = item.useOptions(current, { types: [matchToManyField] })?.filter(Boolean);
|
||||
const children = item.useOptions({ types: [matchToManyField] })?.filter(Boolean);
|
||||
return {
|
||||
label: compile(item.label),
|
||||
value: item.value,
|
||||
|
@ -411,7 +411,7 @@ export default {
|
||||
value: { rejectOnFalse: false },
|
||||
},
|
||||
],
|
||||
render(data) {
|
||||
render: function Renderer(data) {
|
||||
const { t } = useTranslation();
|
||||
const { nodes } = useFlowContext();
|
||||
const {
|
||||
|
@ -49,7 +49,7 @@ export interface Instruction {
|
||||
view?: ISchema;
|
||||
scope?: { [key: string]: any };
|
||||
components?: { [key: string]: any };
|
||||
render?(props): React.ReactNode;
|
||||
render?(props): JSX.Element;
|
||||
endding?: boolean;
|
||||
useVariables?(node, options?): VariableOptions;
|
||||
useScopeVariables?(node, options?): VariableOptions;
|
||||
|
@ -116,7 +116,7 @@ export default {
|
||||
useWorkflowVariableOptions,
|
||||
},
|
||||
components: {},
|
||||
useScopeVariables(node, types) {
|
||||
useScopeVariables(node, options) {
|
||||
const compile = useCompile();
|
||||
const { target } = node.config;
|
||||
if (!target) {
|
||||
@ -137,8 +137,8 @@ export default {
|
||||
.split('.')
|
||||
.map((path) => path.trim());
|
||||
|
||||
const options = [nodesOptions, triggerOptions].map((item: any) => {
|
||||
const opts = typeof item.useOptions === 'function' ? item.useOptions(node, { types }).filter(Boolean) : null;
|
||||
const targetOptions = [nodesOptions, triggerOptions].map((item: any) => {
|
||||
const opts = typeof item.useOptions === 'function' ? item.useOptions(options).filter(Boolean) : null;
|
||||
return {
|
||||
label: compile(item.title),
|
||||
value: item.value,
|
||||
@ -148,7 +148,7 @@ export default {
|
||||
};
|
||||
});
|
||||
|
||||
targetOption.children = findOption(options, paths);
|
||||
targetOption.children = findOption(targetOptions, paths);
|
||||
}
|
||||
|
||||
return [
|
||||
|
@ -16,7 +16,8 @@ export type VariableOptions = VariableOption[] | null;
|
||||
export const nodesOptions = {
|
||||
label: `{{t("Node result", { ns: "${NAMESPACE}" })}}`,
|
||||
value: '$jobsMapByNodeId',
|
||||
useOptions(current, options) {
|
||||
useOptions(options) {
|
||||
const current = useNodeContext();
|
||||
const upstreams = useAvailableUpstreams(current);
|
||||
const result: VariableOption[] = [];
|
||||
upstreams.forEach((node) => {
|
||||
@ -38,7 +39,7 @@ export const nodesOptions = {
|
||||
export const triggerOptions = {
|
||||
label: `{{t("Trigger variables", { ns: "${NAMESPACE}" })}}`,
|
||||
value: '$context',
|
||||
useOptions(current, options) {
|
||||
useOptions(options) {
|
||||
const { workflow } = useFlowContext();
|
||||
const trigger = triggers.get(workflow.type);
|
||||
return trigger?.useVariables?.(workflow.config, options) ?? null;
|
||||
@ -48,7 +49,8 @@ export const triggerOptions = {
|
||||
export const scopeOptions = {
|
||||
label: `{{t("Scope variables", { ns: "${NAMESPACE}" })}}`,
|
||||
value: '$scopes',
|
||||
useOptions(current, options) {
|
||||
useOptions(options) {
|
||||
const current = useNodeContext();
|
||||
const scopes = useUpstreamScopes(current);
|
||||
const result: VariableOption[] = [];
|
||||
scopes.forEach((node) => {
|
||||
@ -70,7 +72,7 @@ export const scopeOptions = {
|
||||
export const systemOptions = {
|
||||
label: `{{t("System variables", { ns: "${NAMESPACE}" })}}`,
|
||||
value: '$system',
|
||||
useOptions(current, { types }) {
|
||||
useOptions({ types }) {
|
||||
return [
|
||||
...(!types || types.includes('date')
|
||||
? [
|
||||
@ -158,9 +160,8 @@ export function filterTypedFields(fields, types, depth = 1) {
|
||||
|
||||
export function useWorkflowVariableOptions(options = {}) {
|
||||
const compile = useCompile();
|
||||
const current = useNodeContext();
|
||||
const result = [scopeOptions, nodesOptions, triggerOptions, systemOptions].map((item: any) => {
|
||||
const opts = typeof item.useOptions === 'function' ? item.useOptions(current, options).filter(Boolean) : null;
|
||||
const opts = typeof item.useOptions === 'function' ? item.useOptions(options).filter(Boolean) : null;
|
||||
return {
|
||||
label: compile(item.label),
|
||||
value: item.value,
|
||||
|
Loading…
Reference in New Issue
Block a user