Skip to content

Commit f6d09f4

Browse files
authored
fix: fix old action form error (#1132)
1 parent a3df82c commit f6d09f4

File tree

2 files changed

+25
-22
lines changed

2 files changed

+25
-22
lines changed

shell/app/yml-chart/common/pipeline-node-drawer.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ const PurePipelineNodeForm = (props: IEditStageProps & FormComponentProps) => {
495495
</div>
496496
);
497497
return (
498-
<Panel key={`${parentKey}.${item.key}-${String(index)}`} header={header}>
498+
<Panel key={`${parentKey}.${item.key}-${String(index)}`} header={header} forceRender>
499499
{renderResource({ data: property.struct }, `${parentKey}.[${index}]`, item)}
500500
</Panel>
501501
);
@@ -632,6 +632,7 @@ const PurePipelineNodeForm = (props: IEditStageProps & FormComponentProps) => {
632632
{type ? taskName : null}
633633
{actionVersion}
634634
{executionCondition}
635+
635636
{renderTaskTypeStructure()}
636637
{editing ? (
637638
<Button type="primary" ghost onClick={onSubmit}>

shell/app/yml-chart/pipeline-editor.tsx

+23-21
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import React from 'react';
1515
import i18n from 'i18n';
1616
// @ts-ignore
1717
import yaml from 'js-yaml';
18-
import { get, omit, isEmpty } from 'lodash';
18+
import { get, omit, isEmpty, cloneDeep } from 'lodash';
1919
import { notify, isPromise } from 'common/utils';
2020
import { Spin, Button, message, Radio, Modal } from 'core/nusi';
2121
import { useUpdate, FileEditor, ErdaCustomIcon } from 'common';
@@ -118,12 +118,13 @@ const PipelineEditor = React.forwardRef((props: IPipelineEditorProps, ref: any)
118118
const onDeleteData = (nodeData: any) => {
119119
const { [externalKey]: externalData } = nodeData;
120120
const { xIndex, yIndex } = externalData || {};
121-
const newYmlObj = produce(ymlObj, (draft: PIPELINE.IPipelineYmlStructure) => {
122-
draft.stages[xIndex].splice(yIndex, 1);
123-
if (draft.stages[xIndex].length === 0) {
124-
draft.stages.splice(xIndex, 1);
125-
}
126-
});
121+
122+
const newYmlObj = cloneDeep(ymlObj);
123+
newYmlObj.stages[xIndex].splice(yIndex, 1);
124+
if (newYmlObj.stages[xIndex].length === 0) {
125+
newYmlObj.stages.splice(xIndex, 1);
126+
}
127+
127128
updater.ymlObj(newYmlObj);
128129
message.success(i18n.t('application:please click save to submit the configuration'));
129130
};
@@ -189,20 +190,21 @@ const PipelineEditor = React.forwardRef((props: IPipelineEditorProps, ref: any)
189190
}
190191

191192
const { nodeType, xIndex, yIndex, insertPos } = curChosenExternal;
192-
const newYmlObj = produce(ymlObj, (draft: PIPELINE.IPipelineYmlStructure) => {
193-
if (!draft.stages) {
194-
draft.stages = [];
195-
}
196-
if (nodeType === NodeType.addRow) {
197-
draft.stages.splice(insertPos, 0, [newData]);
198-
} else if (nodeType === NodeType.addNode) {
199-
// 添加节点
200-
draft.stages[xIndex] = [...draft.stages[xIndex], newData];
201-
} else {
202-
// 修改节点
203-
draft.stages[xIndex][yIndex] = newData;
204-
}
205-
});
193+
const newYmlObj = cloneDeep(ymlObj);
194+
if (!newYmlObj.stages) {
195+
newYmlObj.stages = [];
196+
}
197+
198+
if (nodeType === NodeType.addRow) {
199+
newYmlObj.stages.splice(insertPos, 0, [newData]);
200+
} else if (nodeType === NodeType.addNode) {
201+
// 添加节点
202+
newYmlObj.stages[xIndex] = [...newYmlObj.stages[xIndex], newData];
203+
} else {
204+
// 修改节点
205+
newYmlObj.stages[xIndex][yIndex] = newData;
206+
}
207+
206208
updater.ymlObj(newYmlObj);
207209
message.success(i18n.t('application:please click save to submit the configuration'));
208210
}

0 commit comments

Comments
 (0)