Skip to content

Commit 851f414

Browse files
author
qq_62395577
committed
修改前端代码,新增放开连线限制按钮
1 parent 9d7fc0f commit 851f414

16 files changed

Lines changed: 78 additions & 11 deletions

File tree

agent-flow/src/components/base/jadeNode.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ export const jadeNode = (id, x, y, width, height, parent, drawer) => {
469469
* @returns {number} 连接数。
470470
*/
471471
self.maxNumToLink = () => {
472-
return 100;
472+
return self.graph?.connectionLimitDisabled ? 100 : 1;
473473
};
474474

475475
/**

agent-flow/src/components/base/validator.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@ export class NormalNodeConnectorValidator extends Validator {
3535
validate() {
3636
const nextEvents = this.node.getNextRunnableEvents();
3737
const i18n = this.node.graph.i18n;
38-
// 连线数量只要大于一即可
39-
if (nextEvents.length < 1) {
38+
const isConnectionLimitDisabled = Boolean(this.node.graph?.connectionLimitDisabled);
39+
const isValid = isConnectionLimitDisabled ? nextEvents.length >= 1 : nextEvents.length === 1;
40+
if (!isValid) {
4041
return Promise.reject({
4142
errorFields: [{
4243
errors: [`${i18n?.t('node') ?? 'node'} ${this.node.text} ${i18n?.t('problemWithConnection') ?? 'problemWithConnection'}`],

agent-flow/src/components/code/codeNodeState.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export const codeNodeState = (id, x, y, width, height, parent, drawer) => {
9393
* @override
9494
*/
9595
self.maxNumToLink = () => {
96-
return 100;
96+
return self.graph?.connectionLimitDisabled ? 100 : 10;
9797
};
9898

9999
return self;

agent-flow/src/components/variableAggregation/variableAggregationNodeState.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export const variableAggregationNodeState = (id, x, y, width, height, parent, dr
4949
* @override
5050
*/
5151
self.maxNumToLink = () => {
52-
return 100;
52+
return self.graph?.connectionLimitDisabled ? 100 : 10;
5353
};
5454

5555
return self;

agent-flow/src/flow/jadeFlowEntry.jsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,10 @@ const jadeFlowAgent = (graph) => {
378378
graph.destroy();
379379
};
380380

381+
self.setConnectionLimitDisabled = (disabled) => {
382+
graph.connectionLimitDisabled = Boolean(disabled);
383+
};
384+
381385
return self;
382386
};
383387

@@ -432,6 +436,7 @@ export const JadeFlow = (() => {
432436
div,
433437
tenant,
434438
appId,
439+
connectionLimitDisabled = false,
435440
flowConfigData,
436441
configs,
437442
i18n,
@@ -440,7 +445,7 @@ export const JadeFlow = (() => {
440445
}) => {
441446
const graphDom = getGraphDom(div);
442447
const g = jadeFlowGraph(div, 'jadeFlow');
443-
await configGraph(g, tenant, appId, flowConfigData, configs, i18n, importStatements);
448+
await configGraph(g, tenant, appId, flowConfigData, configs, i18n, importStatements, connectionLimitDisabled);
444449
g.flowType = flowType;
445450
const pageData = g.getPageData(0);
446451
await g.editFlow(0, graphDom, pageData.id);
@@ -470,8 +475,9 @@ export const JadeFlow = (() => {
470475
return jadeFlowAgent(g);
471476
};
472477

473-
const configGraph = async (g, tenant, appId, flowConfigData, configs, i18n, importStatements) => {
478+
const configGraph = async (g, tenant, appId, flowConfigData, configs, i18n, importStatements, connectionLimitDisabled = false) => {
474479
g.collaboration.mute = true;
480+
g.connectionLimitDisabled = Boolean(connectionLimitDisabled);
475481
g.configs = configs;
476482
g.i18n = i18n;
477483
for (let i = 0; i < importStatements.length; i++) {

agent-flow/src/flow/jadeFlowGraph.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ export const jadeFlowGraph = (div, title) => {
7676
const self = defaultGraph(div, title);
7777
self.type = 'jadeFlowGraph';
7878
self.pageType = 'jadeFlowPage';
79+
self.connectionLimitDisabled = false;
7980
self.enableText = false;
8081
self.flowMeta = {
8182
exceptionFitables: ['modelengine.fit.jober.aipp.fitable.AippFlowExceptionHandler'],

agent-flow/src/flow/jadeFlowPage.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ export const jadeFlowPage = (div, graph, name, id) => {
4040
self.addEventListener('COPY_SHAPE', shapeChangeListener);
4141
self.addEventListener('DELETE_SHAPE', shapeChangeListener);
4242

43+
const isConnectionLimitDisabled = () => Boolean(self.graph?.connectionLimitDisabled);
44+
4345
/**
4446
* @override
4547
*/
@@ -305,7 +307,7 @@ export const jadeFlowPage = (div, graph, name, id) => {
305307
*/
306308
self.canDragOut = (node, connector) => {
307309
const lines = self.getEvents().filter(s => s.fromShape === node.id && s.getDefinedFromConnector() === connector);
308-
return lines.length < 10;
310+
return lines.length < (isConnectionLimitDisabled() ? 10 : 1);
309311
};
310312

311313
/**
@@ -330,7 +332,9 @@ export const jadeFlowPage = (div, graph, name, id) => {
330332
}
331333
};
332334

333-
return jadeEvent.fromShape !== jadeEvent.toShape && isConnectorAllowToLink() && isConnectorWithinLimit();
335+
return jadeEvent.fromShape !== jadeEvent.toShape
336+
&& isConnectorAllowToLink()
337+
&& (isConnectionLimitDisabled() || isConnectorWithinLimit());
334338
};
335339

336340
/**

frontend/src/locale/en_US.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,8 @@
241241
"plsEnterValidNumber": "Enter a number",
242242
"plsEnterNumber": "Enter a number",
243243
"debugRun": "Test Running",
244+
"disableConnectionLimit": "Lift Link Limits",
245+
"restoreConnectionLimit": "Restore Link Limits",
244246
"startNode": "Start Node",
245247
"run": "Run",
246248
"publish": "Release",

frontend/src/locale/zh_CN.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@
8080
"intelligentCreate": "智能生成",
8181
"createWorkflow": "创建工作流",
8282
"debugRun": "测试运行",
83+
"disableConnectionLimit": "放开连线限制",
84+
"restoreConnectionLimit": "恢复连线限制",
8385
"support": "支持",
8486
"character": "字符",
8587
"number": "数字",

frontend/src/pages/addFlow/components/addflow-header.tsx

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,15 @@ import timeImg from '@/assets/images/ai/time.png';
3737
const AddHeader = (props) => {
3838
const dispatch = useAppDispatch();
3939
const { t } = useTranslation();
40-
const { handleDebugClick, workFlow, types, saveTime, updateAippCallBack } = props;
40+
const {
41+
handleDebugClick,
42+
isConnectionLimitDisabled,
43+
workFlow,
44+
types,
45+
saveTime,
46+
toggleConnectionLimitDisabled,
47+
updateAippCallBack,
48+
} = props;
4149
const { appInfo, setFlowInfo } = useContext(FlowContext);
4250
const [open, setOpen] = useState(false);
4351
const [imgPath, setImgPath] = useState('');
@@ -127,6 +135,13 @@ const AddHeader = (props) => {
127135
<img src={timeImg} />
128136
</span>
129137
}
138+
<Button
139+
className={`header-btn test-btn ${isConnectionLimitDisabled ? 'link-limit-btn-active' : ''}`}
140+
onClick={toggleConnectionLimitDisabled}
141+
disabled={testStatus === 'Running'}
142+
>
143+
{isConnectionLimitDisabled ? t('restoreConnectionLimit') : t('disableConnectionLimit')}
144+
</Button>
130145
<Button
131146
className='header-btn test-btn'
132147
onClick={handleDebugClick}

0 commit comments

Comments
 (0)