@@ -15,7 +15,7 @@ import React from 'react';
15
15
import i18n from 'i18n' ;
16
16
// @ts -ignore
17
17
import yaml from 'js-yaml' ;
18
- import { get , omit , isEmpty } from 'lodash' ;
18
+ import { get , omit , isEmpty , cloneDeep } from 'lodash' ;
19
19
import { notify , isPromise } from 'common/utils' ;
20
20
import { Spin , Button , message , Radio , Modal } from 'core/nusi' ;
21
21
import { useUpdate , FileEditor , ErdaCustomIcon } from 'common' ;
@@ -118,12 +118,13 @@ const PipelineEditor = React.forwardRef((props: IPipelineEditorProps, ref: any)
118
118
const onDeleteData = ( nodeData : any ) => {
119
119
const { [ externalKey ] : externalData } = nodeData ;
120
120
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
+
127
128
updater . ymlObj ( newYmlObj ) ;
128
129
message . success ( i18n . t ( 'application:please click save to submit the configuration' ) ) ;
129
130
} ;
@@ -189,20 +190,21 @@ const PipelineEditor = React.forwardRef((props: IPipelineEditorProps, ref: any)
189
190
}
190
191
191
192
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
+
206
208
updater . ymlObj ( newYmlObj ) ;
207
209
message . success ( i18n . t ( 'application:please click save to submit the configuration' ) ) ;
208
210
}
0 commit comments