@coding-flow/flow-design 0.0.38 → 0.0.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/script.d.ts +4 -0
- package/dist/api/script.js +10 -0
- package/dist/components/design-editor/node-components/condition/index.js +42 -32
- package/dist/components/design-editor/node-components/node-hint/index.js +16 -8
- package/dist/components/design-editor/node-components/strategy/error-trigger.js +40 -29
- package/dist/components/design-editor/node-components/strategy/node-title.js +40 -32
- package/dist/components/design-editor/node-components/strategy/operator-load.js +40 -29
- package/dist/components/design-editor/node-components/strategy/router.js +40 -30
- package/dist/components/design-editor/node-components/strategy/sub-process.js +40 -30
- package/dist/components/design-editor/node-components/strategy/trigger.js +40 -29
- package/dist/components/design-editor/nodes/condition-branch/form-meta.js +1 -1
- package/dist/components/design-editor/nodes/start/form-meta.js +8 -1
- package/dist/components/design-panel/tabs/base/index.js +4 -1
- package/dist/components/design-panel/tabs/base/operator.d.ts +1 -0
- package/dist/components/design-panel/tabs/base/operator.js +1 -0
- package/dist/components/groovy-code/index.d.ts +5 -0
- package/dist/components/groovy-code/index.js +29 -155
- package/dist/plugins/trigger-view-type.d.ts +2 -0
- package/dist/script-components/components/advanced-script-editor.d.ts +1 -23
- package/dist/script-components/components/advanced-script-editor.js +22 -60
- package/dist/script-components/components/groovy-script-loader.d.ts +12 -0
- package/dist/script-components/components/groovy-script-loader.js +39 -0
- package/dist/script-components/components/groovy-script-modal.d.ts +11 -1
- package/dist/script-components/components/groovy-script-modal.js +3 -1
- package/dist/script-components/modal/condition-config-modal.d.ts +3 -1
- package/dist/script-components/modal/condition-config-modal.js +2 -1
- package/dist/script-components/modal/error-trigger-config-modal.d.ts +3 -1
- package/dist/script-components/modal/error-trigger-config-modal.js +2 -1
- package/dist/script-components/modal/node-title-config-modal.d.ts +3 -1
- package/dist/script-components/modal/node-title-config-modal.js +2 -1
- package/dist/script-components/modal/operator-create-config-modal.d.ts +3 -1
- package/dist/script-components/modal/operator-create-config-modal.js +3 -2
- package/dist/script-components/modal/operator-load-config-modal.d.ts +3 -1
- package/dist/script-components/modal/operator-load-config-modal.js +2 -1
- package/dist/script-components/modal/router-config-modal.d.ts +3 -1
- package/dist/script-components/modal/router-config-modal.js +2 -1
- package/dist/script-components/modal/sub-process-config-modal.d.ts +3 -1
- package/dist/script-components/modal/sub-process-config-modal.js +2 -1
- package/dist/script-components/modal/trigger-config-modal.d.ts +3 -1
- package/dist/script-components/modal/trigger-config-modal.js +3 -2
- package/package.json +8 -13
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import "react";
|
|
2
3
|
import { provideJsonSchemaOutputs, syncVariableTitle } from "@flowgram.ai/form-materials";
|
|
3
4
|
import { ValidateTrigger } from "@flowgram.ai/fixed-layout-editor";
|
|
4
5
|
import { useIsSidebar } from "../../hooks/index.js";
|
|
5
6
|
import { NodeHeader } from "../../node-components/header/index.js";
|
|
6
7
|
import { NodePanel } from "../../node-components/panel/index.js";
|
|
7
8
|
import { ConditionScript } from "../../node-components/condition/index.js";
|
|
8
|
-
import "react";
|
|
9
9
|
import { NodeHint } from "../../node-components/node-hint/index.js";
|
|
10
10
|
import { NodeOrder } from "../../node-components/node-order/index.js";
|
|
11
11
|
const renderForm = (data)=>{
|
|
@@ -10,6 +10,10 @@ import { RevokeStrategy } from "../../node-components/strategy/revoke.js";
|
|
|
10
10
|
import { View } from "../../node-components/view/index.js";
|
|
11
11
|
import { useDesignContext } from "../../../design-panel/hooks/use-design-context.js";
|
|
12
12
|
import { GroovyScriptConvertorUtil } from "@coding-flow/flow-core";
|
|
13
|
+
import { GroovyScriptLoader } from "../../../../script-components/components/groovy-script-loader.js";
|
|
14
|
+
const ScriptContent = (props)=>/*#__PURE__*/ jsx("div", {
|
|
15
|
+
children: GroovyScriptConvertorUtil.getScriptTitle(props.value || '')
|
|
16
|
+
});
|
|
13
17
|
const renderForm = (data)=>{
|
|
14
18
|
const isSidebar = useIsSidebar();
|
|
15
19
|
const { state } = useDesignContext();
|
|
@@ -30,7 +34,10 @@ const renderForm = (data)=>{
|
|
|
30
34
|
data: data,
|
|
31
35
|
children: [
|
|
32
36
|
/*#__PURE__*/ jsx(NodeHeader, {}),
|
|
33
|
-
|
|
37
|
+
/*#__PURE__*/ jsx(GroovyScriptLoader, {
|
|
38
|
+
content: ScriptContent,
|
|
39
|
+
value: state.workflow.operatorCreateScript
|
|
40
|
+
})
|
|
34
41
|
]
|
|
35
42
|
});
|
|
36
43
|
};
|
|
@@ -4,6 +4,7 @@ import { Input } from "antd";
|
|
|
4
4
|
import { CardForm, Panel } from "@coding-flow/flow-pc-ui";
|
|
5
5
|
import { useDesignContext } from "../../hooks/use-design-context.js";
|
|
6
6
|
import { FlowCreateOperatorEditor } from "./operator.js";
|
|
7
|
+
import { GroovyScriptLoader } from "../../../../script-components/components/groovy-script-loader.js";
|
|
7
8
|
const TabBase = ()=>{
|
|
8
9
|
const [baseForm] = CardForm.useForm();
|
|
9
10
|
const [operatorForm] = CardForm.useForm();
|
|
@@ -98,7 +99,9 @@ const TabBase = ()=>{
|
|
|
98
99
|
message: '请输入发起人范围'
|
|
99
100
|
}
|
|
100
101
|
],
|
|
101
|
-
children: /*#__PURE__*/ jsx(
|
|
102
|
+
children: /*#__PURE__*/ jsx(GroovyScriptLoader, {
|
|
103
|
+
content: FlowCreateOperatorEditor
|
|
104
|
+
})
|
|
102
105
|
})
|
|
103
106
|
})
|
|
104
107
|
]
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { ToolbarItem } from '@coding-script/script-engine';
|
|
2
3
|
interface GroovyCodeEditorProps {
|
|
4
|
+
title?: string;
|
|
3
5
|
value?: string;
|
|
6
|
+
toolbar?: ToolbarItem[];
|
|
7
|
+
scriptKey?: string;
|
|
4
8
|
readonly?: boolean;
|
|
5
9
|
onChange?: (value: string) => void;
|
|
10
|
+
resetScript?: () => string;
|
|
6
11
|
placeholder?: string;
|
|
7
12
|
theme?: 'dark' | 'light';
|
|
8
13
|
options?: {
|
|
@@ -1,163 +1,37 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { HighlightStyle, bracketMatching, defaultHighlightStyle, foldGutter, foldKeymap, indentOnInput, syntaxHighlighting } from "@codemirror/language";
|
|
7
|
-
import { java } from "@codemirror/lang-java";
|
|
8
|
-
import { oneDark } from "@codemirror/theme-one-dark";
|
|
9
|
-
import { tags } from "@lezer/highlight";
|
|
10
|
-
const darkHighlightStyle = HighlightStyle.define([
|
|
11
|
-
{
|
|
12
|
-
tag: tags.keyword,
|
|
13
|
-
color: '#c678dd'
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
tag: tags.operator,
|
|
17
|
-
color: '#56b6c2'
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
tag: tags.variableName,
|
|
21
|
-
color: '#e5c07b'
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
tag: tags.string,
|
|
25
|
-
color: '#98c379'
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
tag: tags.comment,
|
|
29
|
-
color: '#5c6370',
|
|
30
|
-
fontStyle: 'italic'
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
tag: tags.number,
|
|
34
|
-
color: '#d19a66'
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
tag: tags.bool,
|
|
38
|
-
color: '#d19a66'
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
tag: tags["null"],
|
|
42
|
-
color: '#d19a66'
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
tag: tags.propertyName,
|
|
46
|
-
color: '#e06c75'
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
tag: tags["function"](tags.variableName),
|
|
50
|
-
color: '#61afef'
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
tag: tags.definition(tags.variableName),
|
|
54
|
-
color: '#e5c07b'
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
tag: tags.typeName,
|
|
58
|
-
color: '#e5c07b'
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
tag: tags.className,
|
|
62
|
-
color: '#e5c07b'
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
tag: tags.annotation,
|
|
66
|
-
color: '#d19a66'
|
|
67
|
-
}
|
|
68
|
-
]);
|
|
2
|
+
import react from "react";
|
|
3
|
+
import { message } from "antd";
|
|
4
|
+
import { ScriptCodeEditor } from "@coding-script/script-engine";
|
|
5
|
+
import { getMetadata } from "../../api/script.js";
|
|
69
6
|
const GroovyCodeEditor = (props)=>{
|
|
70
|
-
const
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
lineNumbers(),
|
|
78
|
-
highlightActiveLineGutter(),
|
|
79
|
-
highlightSpecialChars(),
|
|
80
|
-
commands_history(),
|
|
81
|
-
foldGutter(),
|
|
82
|
-
drawSelection(),
|
|
83
|
-
dropCursor(),
|
|
84
|
-
EditorState.allowMultipleSelections.of(true),
|
|
85
|
-
indentOnInput(),
|
|
86
|
-
bracketMatching(),
|
|
87
|
-
rectangularSelection(),
|
|
88
|
-
crosshairCursor(),
|
|
89
|
-
highlightActiveLine(),
|
|
90
|
-
keymap.of([
|
|
91
|
-
...defaultKeymap,
|
|
92
|
-
...historyKeymap,
|
|
93
|
-
...foldKeymap,
|
|
94
|
-
indentWithTab
|
|
95
|
-
]),
|
|
96
|
-
java(),
|
|
97
|
-
view_placeholder(placeholder),
|
|
98
|
-
EditorView.updateListener.of((update)=>{
|
|
99
|
-
if (update.docChanged && onChange) onChange(update.state.doc.toString());
|
|
100
|
-
}),
|
|
101
|
-
EditorView.theme({
|
|
102
|
-
'&': {
|
|
103
|
-
fontSize: `${fontSize}px`
|
|
104
|
-
},
|
|
105
|
-
'.cm-scroller': {
|
|
106
|
-
overflow: 'auto',
|
|
107
|
-
minHeight: `${minHeight}px`,
|
|
108
|
-
maxHeight: `${maxHeight}px`
|
|
109
|
-
},
|
|
110
|
-
'.cm-content': {
|
|
111
|
-
fontFamily: 'monospace',
|
|
112
|
-
minHeight: `${minHeight}px`
|
|
113
|
-
},
|
|
114
|
-
'.cm-gutters': {
|
|
115
|
-
minHeight: `${minHeight}px`
|
|
116
|
-
}
|
|
117
|
-
})
|
|
118
|
-
];
|
|
119
|
-
if ('dark' === theme) {
|
|
120
|
-
extensions.push(oneDark);
|
|
121
|
-
extensions.push(syntaxHighlighting(darkHighlightStyle));
|
|
122
|
-
} else extensions.push(syntaxHighlighting(defaultHighlightStyle));
|
|
123
|
-
if (readonly) extensions.push(EditorState.readOnly.of(true));
|
|
124
|
-
const state = EditorState.create({
|
|
125
|
-
doc: value,
|
|
126
|
-
extensions
|
|
127
|
-
});
|
|
128
|
-
const view = new EditorView({
|
|
129
|
-
state,
|
|
130
|
-
parent: editorRef.current
|
|
131
|
-
});
|
|
132
|
-
viewRef.current = view;
|
|
133
|
-
return ()=>{
|
|
134
|
-
view.destroy();
|
|
135
|
-
};
|
|
136
|
-
}, [
|
|
137
|
-
theme,
|
|
138
|
-
fontSize,
|
|
139
|
-
minHeight,
|
|
140
|
-
maxHeight,
|
|
141
|
-
placeholder,
|
|
142
|
-
readonly
|
|
143
|
-
]);
|
|
144
|
-
useEffect(()=>{
|
|
145
|
-
if (viewRef.current && value !== viewRef.current.state.doc.toString()) viewRef.current.dispatch({
|
|
146
|
-
changes: {
|
|
147
|
-
from: 0,
|
|
148
|
-
to: viewRef.current.state.doc.length,
|
|
149
|
-
insert: value
|
|
150
|
-
}
|
|
7
|
+
const title = props.title || '脚本编辑器';
|
|
8
|
+
const [metadata, setMetadata] = react.useState();
|
|
9
|
+
react.useEffect(()=>{
|
|
10
|
+
if (props.scriptKey) getMetadata(props.scriptKey).then((res)=>{
|
|
11
|
+
setMetadata(res.data);
|
|
12
|
+
}).catch((err)=>{
|
|
13
|
+
message.error('获取脚本元数据失败');
|
|
151
14
|
});
|
|
152
15
|
}, [
|
|
153
|
-
|
|
16
|
+
props.scriptKey
|
|
154
17
|
]);
|
|
155
|
-
return /*#__PURE__*/ jsx(
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
18
|
+
return /*#__PURE__*/ jsx(ScriptCodeEditor, {
|
|
19
|
+
title: title,
|
|
20
|
+
toolbar: props.toolbar,
|
|
21
|
+
value: props.value,
|
|
22
|
+
onChange: props.onChange,
|
|
23
|
+
placeholder: props.placeholder,
|
|
24
|
+
readonly: props.readonly,
|
|
25
|
+
options: props.options,
|
|
26
|
+
defaultTheme: props.theme || 'light',
|
|
27
|
+
metadata: metadata,
|
|
28
|
+
enableCompile: true,
|
|
29
|
+
enableFormat: true,
|
|
30
|
+
enableFullscreen: true,
|
|
31
|
+
enableThemeToggle: true,
|
|
32
|
+
onCompile: (code)=>{
|
|
33
|
+
console.log('编译脚本:', code);
|
|
34
|
+
message.success('脚本编译测试已提交');
|
|
161
35
|
}
|
|
162
36
|
});
|
|
163
37
|
};
|
|
@@ -1,25 +1,3 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { GroovyScriptContent } from "./groovy-script-modal";
|
|
3
|
-
|
|
4
|
-
interface ScriptEditorProps {
|
|
5
|
-
/** 脚本类型 */
|
|
6
|
-
type: ScriptType;
|
|
7
|
-
/** 当前脚本内容 */
|
|
8
|
-
script: string;
|
|
9
|
-
/** 变量映射列表 */
|
|
10
|
-
variables: GroovyVariableMapping[];
|
|
11
|
-
/** 脚本变更回调 */
|
|
12
|
-
onChange: (script: string) => void;
|
|
13
|
-
/** 是否只读 */
|
|
14
|
-
readonly?: boolean;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* 高级脚本编辑器组件
|
|
18
|
-
* 支持自由编辑 Groovy 脚本
|
|
19
|
-
*/
|
|
20
|
-
export declare const ScriptEditor: React.FC<ScriptEditorProps>;
|
|
21
|
-
interface AdvancedScriptEditorProps extends GroovyScriptContent {
|
|
22
|
-
resetScript(): string;
|
|
23
|
-
}
|
|
24
|
-
export declare const AdvancedScriptEditor: React.FC<AdvancedScriptEditorProps>;
|
|
25
|
-
export {};
|
|
3
|
+
export declare const AdvancedScriptEditor: React.FC<GroovyScriptContent>;
|
|
@@ -1,24 +1,33 @@
|
|
|
1
|
-
import { jsx
|
|
2
|
-
import { Button, Space } from "antd";
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
2
|
import "react";
|
|
4
|
-
import { MenuUnfoldOutlined, ReloadOutlined } from "@ant-design/icons";
|
|
5
3
|
import { GroovyCodeEditor } from "../../components/groovy-code/index.js";
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
fontSize: 12,
|
|
9
|
-
color: 'rgba(0, 0, 0, 0.25)'
|
|
10
|
-
};
|
|
11
|
-
const ScriptEditor = (props)=>{
|
|
12
|
-
const { script, onChange, readonly = false, variables } = props;
|
|
4
|
+
const AdvancedScriptEditor = (props)=>{
|
|
5
|
+
const { script, onChange, readonly } = props;
|
|
13
6
|
const handleChange = (value)=>{
|
|
14
7
|
if (!readonly) onChange(value);
|
|
15
8
|
};
|
|
16
9
|
return /*#__PURE__*/ jsx(GroovyCodeEditor, {
|
|
17
10
|
value: script,
|
|
11
|
+
scriptKey: props.scriptKey,
|
|
18
12
|
readonly: readonly,
|
|
19
13
|
onChange: handleChange,
|
|
20
|
-
placeholder: "
|
|
21
|
-
|
|
14
|
+
placeholder: "请输入脚本...",
|
|
15
|
+
toolbar: [
|
|
16
|
+
{
|
|
17
|
+
key: 'reset',
|
|
18
|
+
title: '重置',
|
|
19
|
+
label: '重置脚本',
|
|
20
|
+
backgroundColor: '#ff4d4f',
|
|
21
|
+
hoverBackgroundColor: '#ff7875',
|
|
22
|
+
textColor: '#fff',
|
|
23
|
+
borderColor: '#ff4d4f',
|
|
24
|
+
onClick: ()=>{
|
|
25
|
+
const newScript = props.resetScript?.() || '';
|
|
26
|
+
handleChange(newScript);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
],
|
|
30
|
+
theme: 'light',
|
|
22
31
|
options: {
|
|
23
32
|
fontSize: 14,
|
|
24
33
|
minHeight: 300,
|
|
@@ -26,51 +35,4 @@ const ScriptEditor = (props)=>{
|
|
|
26
35
|
}
|
|
27
36
|
});
|
|
28
37
|
};
|
|
29
|
-
|
|
30
|
-
children: [
|
|
31
|
-
/*#__PURE__*/ jsx(ScriptEditor, {
|
|
32
|
-
type: props.type,
|
|
33
|
-
script: props.script,
|
|
34
|
-
variables: props.variables || [],
|
|
35
|
-
onChange: props.onChange
|
|
36
|
-
}),
|
|
37
|
-
/*#__PURE__*/ jsxs(Space, {
|
|
38
|
-
style: {
|
|
39
|
-
marginTop: 8
|
|
40
|
-
},
|
|
41
|
-
children: [
|
|
42
|
-
/*#__PURE__*/ jsx(Button, {
|
|
43
|
-
icon: /*#__PURE__*/ jsx(MenuUnfoldOutlined, {}),
|
|
44
|
-
onClick: ()=>{
|
|
45
|
-
props.onChange(GroovyScriptConvertorUtil.formatScript(props.script));
|
|
46
|
-
},
|
|
47
|
-
children: "格式化代码"
|
|
48
|
-
}),
|
|
49
|
-
/*#__PURE__*/ jsx(Button, {
|
|
50
|
-
icon: /*#__PURE__*/ jsx(ReloadOutlined, {}),
|
|
51
|
-
danger: true,
|
|
52
|
-
onClick: ()=>{
|
|
53
|
-
props.onChange(props.resetScript());
|
|
54
|
-
},
|
|
55
|
-
children: "重置脚本"
|
|
56
|
-
})
|
|
57
|
-
]
|
|
58
|
-
}),
|
|
59
|
-
/*#__PURE__*/ jsxs("div", {
|
|
60
|
-
style: {
|
|
61
|
-
marginTop: 8
|
|
62
|
-
},
|
|
63
|
-
children: [
|
|
64
|
-
/*#__PURE__*/ jsx("div", {
|
|
65
|
-
style: hintStyle,
|
|
66
|
-
children: '// @CUSTOM_SCRIPT 是自定义脚本的标识'
|
|
67
|
-
}),
|
|
68
|
-
/*#__PURE__*/ jsx("div", {
|
|
69
|
-
style: hintStyle,
|
|
70
|
-
children: '// @SCRIPT_TITLE 是脚本的展示内容'
|
|
71
|
-
})
|
|
72
|
-
]
|
|
73
|
-
})
|
|
74
|
-
]
|
|
75
|
-
});
|
|
76
|
-
export { AdvancedScriptEditor, ScriptEditor };
|
|
38
|
+
export { AdvancedScriptEditor };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface GroovyScriptLoaderProps {
|
|
3
|
+
value?: string;
|
|
4
|
+
onChange?: (value: string) => void;
|
|
5
|
+
content: React.ComponentType<GroovyScriptContent>;
|
|
6
|
+
}
|
|
7
|
+
export interface GroovyScriptContent {
|
|
8
|
+
scriptKey: string;
|
|
9
|
+
value?: string;
|
|
10
|
+
onChange?: (value: string) => void;
|
|
11
|
+
}
|
|
12
|
+
export declare const GroovyScriptLoader: React.FC<GroovyScriptLoaderProps>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { getScript, save } from "../../api/script.js";
|
|
3
|
+
import { message } from "antd";
|
|
4
|
+
import react from "react";
|
|
5
|
+
const GroovyScriptLoader = (props)=>{
|
|
6
|
+
const scriptKey = props.value || '';
|
|
7
|
+
const [script, setScript] = react.useState('');
|
|
8
|
+
const ScriptContent = props.content;
|
|
9
|
+
const handlerSaveScript = (script)=>{
|
|
10
|
+
save({
|
|
11
|
+
key: scriptKey,
|
|
12
|
+
script: script
|
|
13
|
+
}).then((res)=>{
|
|
14
|
+
if (res.success) message.success('规则脚本已经更新');
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
const handleScriptChange = (currentScript)=>{
|
|
18
|
+
if (script === currentScript) return;
|
|
19
|
+
console.log("script changed", currentScript);
|
|
20
|
+
handlerSaveScript(currentScript);
|
|
21
|
+
props.onChange?.(scriptKey);
|
|
22
|
+
};
|
|
23
|
+
react.useEffect(()=>{
|
|
24
|
+
if (scriptKey) getScript(scriptKey).then((res)=>{
|
|
25
|
+
setScript(res.data);
|
|
26
|
+
});
|
|
27
|
+
}, [
|
|
28
|
+
scriptKey
|
|
29
|
+
]);
|
|
30
|
+
react.useEffect(()=>()=>{
|
|
31
|
+
setScript('');
|
|
32
|
+
}, []);
|
|
33
|
+
return /*#__PURE__*/ jsx(ScriptContent, {
|
|
34
|
+
scriptKey: scriptKey,
|
|
35
|
+
value: script,
|
|
36
|
+
onChange: handleScriptChange
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
export { GroovyScriptLoader };
|
|
@@ -5,8 +5,12 @@ export interface GroovyScriptModalProps {
|
|
|
5
5
|
open: boolean;
|
|
6
6
|
/** 脚本类型 */
|
|
7
7
|
type: ScriptType;
|
|
8
|
-
/**
|
|
8
|
+
/** 脚本 */
|
|
9
9
|
script: string;
|
|
10
|
+
/** 脚本键 */
|
|
11
|
+
scriptKey: string;
|
|
12
|
+
/** 重置脚本 */
|
|
13
|
+
resetScript?: () => string;
|
|
10
14
|
/** 变量映射列表 */
|
|
11
15
|
variables: GroovyVariableMapping[];
|
|
12
16
|
/** 确认回调 */
|
|
@@ -24,12 +28,18 @@ export interface GroovyScriptContent {
|
|
|
24
28
|
type: ScriptType;
|
|
25
29
|
/** 当前脚本 */
|
|
26
30
|
script: string;
|
|
31
|
+
/** 脚本键 */
|
|
32
|
+
scriptKey: string;
|
|
27
33
|
/** 变量映射列表 */
|
|
28
34
|
variables: GroovyVariableMapping[];
|
|
29
35
|
/** 确认回调 */
|
|
30
36
|
onChange: (script: string) => void;
|
|
31
37
|
/** 动作控制 */
|
|
32
38
|
action?: React.Ref<DesignViewPluginAction>;
|
|
39
|
+
/** 重置脚本 */
|
|
40
|
+
resetScript?: () => string;
|
|
41
|
+
/** 是否只读 */
|
|
42
|
+
readonly?: boolean;
|
|
33
43
|
}
|
|
34
44
|
/**
|
|
35
45
|
* 通用脚本配置弹框
|
|
@@ -22,9 +22,11 @@ const GroovyScriptContentComponent = (props)=>{
|
|
|
22
22
|
return /*#__PURE__*/ jsx(GroovyContent, {
|
|
23
23
|
action: actionRef,
|
|
24
24
|
type: props.type,
|
|
25
|
+
scriptKey: props.scriptKey,
|
|
25
26
|
script: content,
|
|
26
27
|
variables: props.variables,
|
|
27
|
-
onChange: setContent
|
|
28
|
+
onChange: setContent,
|
|
29
|
+
resetScript: props.resetScript
|
|
28
30
|
});
|
|
29
31
|
};
|
|
30
32
|
const GroovyScriptModal = (props)=>{
|
|
@@ -3,8 +3,10 @@ import { GroovyVariableMapping } from "../typings";
|
|
|
3
3
|
export interface ConditionConfigModalProps {
|
|
4
4
|
/** 是否展示 **/
|
|
5
5
|
open: boolean;
|
|
6
|
-
/**
|
|
6
|
+
/** 脚本内容 */
|
|
7
7
|
script: string;
|
|
8
|
+
/** 脚本key */
|
|
9
|
+
scriptKey: string;
|
|
8
10
|
/** 表单字段(用于动态生成变量) */
|
|
9
11
|
variables?: GroovyVariableMapping[];
|
|
10
12
|
/** 取消回调 */
|
|
@@ -29,6 +29,7 @@ const ConditionConfigModal = (props)=>/*#__PURE__*/ jsx(GroovyScriptModal, {
|
|
|
29
29
|
onCancel: props.onCancel,
|
|
30
30
|
title: "条件配置",
|
|
31
31
|
width: "70%",
|
|
32
|
-
content: ConditionConfigContent
|
|
32
|
+
content: ConditionConfigContent,
|
|
33
|
+
scriptKey: props.scriptKey
|
|
33
34
|
});
|
|
34
35
|
export { ConditionConfigModal };
|
|
@@ -3,8 +3,10 @@ import { GroovyVariableMapping } from "../typings";
|
|
|
3
3
|
export interface ErrorTriggerConfigModalProps {
|
|
4
4
|
/** 是否展示 **/
|
|
5
5
|
open: boolean;
|
|
6
|
-
/**
|
|
6
|
+
/** 脚本内容 */
|
|
7
7
|
script: string;
|
|
8
|
+
/** 脚本key */
|
|
9
|
+
scriptKey: string;
|
|
8
10
|
/** 表单字段(用于动态生成变量) */
|
|
9
11
|
variables?: GroovyVariableMapping[];
|
|
10
12
|
/** 取消回调 */
|
|
@@ -29,6 +29,7 @@ const ErrorTriggerConfigModal = (props)=>/*#__PURE__*/ jsx(GroovyScriptModal, {
|
|
|
29
29
|
onConfirm: props.onConfirm,
|
|
30
30
|
onCancel: props.onCancel,
|
|
31
31
|
title: "异常配置",
|
|
32
|
-
content: ErrorTriggerConfigContent
|
|
32
|
+
content: ErrorTriggerConfigContent,
|
|
33
|
+
scriptKey: props.scriptKey
|
|
33
34
|
});
|
|
34
35
|
export { ErrorTriggerConfigModal };
|
|
@@ -3,8 +3,10 @@ import { GroovyVariableMapping } from "../typings";
|
|
|
3
3
|
export interface NodeTitleConfigModalProps {
|
|
4
4
|
/** 是否展示 **/
|
|
5
5
|
open: boolean;
|
|
6
|
-
/**
|
|
6
|
+
/** 脚本内容 */
|
|
7
7
|
script: string;
|
|
8
|
+
/** 脚本key */
|
|
9
|
+
scriptKey: string;
|
|
8
10
|
/** 表单字段(用于动态生成变量) */
|
|
9
11
|
variables?: GroovyVariableMapping[];
|
|
10
12
|
/** 取消回调 */
|
|
@@ -29,6 +29,7 @@ const NodeTitleConfigModal = (props)=>/*#__PURE__*/ jsx(GroovyScriptModal, {
|
|
|
29
29
|
onConfirm: props.onConfirm,
|
|
30
30
|
onCancel: props.onCancel,
|
|
31
31
|
title: "标题配置",
|
|
32
|
-
content: NodeTitleConfigContent
|
|
32
|
+
content: NodeTitleConfigContent,
|
|
33
|
+
scriptKey: props.scriptKey
|
|
33
34
|
});
|
|
34
35
|
export { NodeTitleConfigModal };
|
|
@@ -27,10 +27,11 @@ const OperatorCreateConfigModal = (props)=>/*#__PURE__*/ jsx(GroovyScriptModal,
|
|
|
27
27
|
width: "70%",
|
|
28
28
|
type: ScriptType.OPERATOR_CREATE,
|
|
29
29
|
variables: [],
|
|
30
|
-
script: props.script,
|
|
31
30
|
content: OperatorCreateConfigContent,
|
|
32
31
|
open: props.open,
|
|
33
32
|
onCancel: props.onCancel,
|
|
34
|
-
onConfirm: props.onConfirm
|
|
33
|
+
onConfirm: props.onConfirm,
|
|
34
|
+
scriptKey: props.scriptKey,
|
|
35
|
+
script: props.script
|
|
35
36
|
});
|
|
36
37
|
export { OperatorCreateConfigModal };
|
|
@@ -31,6 +31,7 @@ const OperatorLoadConfigModal = (props)=>/*#__PURE__*/ jsx(GroovyScriptModal, {
|
|
|
31
31
|
content: OperatorLoadConfigContent,
|
|
32
32
|
open: props.open,
|
|
33
33
|
onCancel: props.onCancel,
|
|
34
|
-
onConfirm: props.onConfirm
|
|
34
|
+
onConfirm: props.onConfirm,
|
|
35
|
+
scriptKey: props.scriptKey
|
|
35
36
|
});
|
|
36
37
|
export { OperatorLoadConfigModal };
|
|
@@ -3,8 +3,10 @@ import { GroovyVariableMapping } from "../typings";
|
|
|
3
3
|
export interface RouterConfigModalProps {
|
|
4
4
|
/** 是否展示 **/
|
|
5
5
|
open: boolean;
|
|
6
|
-
/**
|
|
6
|
+
/** 脚本内容 */
|
|
7
7
|
script: string;
|
|
8
|
+
/** 脚本key */
|
|
9
|
+
scriptKey: string;
|
|
8
10
|
/** 表单字段(用于动态生成变量) */
|
|
9
11
|
variables?: GroovyVariableMapping[];
|
|
10
12
|
/** 取消回调 */
|
|
@@ -29,6 +29,7 @@ const RouterConfigModal = (props)=>/*#__PURE__*/ jsx(GroovyScriptModal, {
|
|
|
29
29
|
onConfirm: props.onConfirm,
|
|
30
30
|
onCancel: props.onCancel,
|
|
31
31
|
title: "路由配置",
|
|
32
|
-
content: RouterConfigContent
|
|
32
|
+
content: RouterConfigContent,
|
|
33
|
+
scriptKey: props.scriptKey
|
|
33
34
|
});
|
|
34
35
|
export { RouterConfigModal };
|