@@ -34,6 +34,8 @@ import {
34
34
MODES ,
35
35
Icon ,
36
36
GenericSectionErrorState ,
37
+ ResponseType ,
38
+ BulkEditConfigV2Type ,
37
39
} from '@devtron-labs/devtron-fe-common-lib'
38
40
import { SERVER_MODE , ViewType } from '../../config'
39
41
import { BulkEditsProps , BulkEditsState , BulkEditVersion } from './bulkEdits.type'
@@ -53,10 +55,6 @@ import { importComponentFromFELibrary } from '@Components/common'
53
55
const getBulkEditConfig = importComponentFromFELibrary ( 'getBulkEditConfig' , null , 'function' )
54
56
55
57
const ReadmeVersionOptions = [
56
- {
57
- label : 'v1beta1/application' ,
58
- value : BulkEditVersion . v1 ,
59
- } ,
60
58
...( getBulkEditConfig
61
59
? [
62
60
{
@@ -65,6 +63,10 @@ const ReadmeVersionOptions = [
65
63
} ,
66
64
]
67
65
: [ ] ) ,
66
+ {
67
+ label : 'v1beta1/application' ,
68
+ value : BulkEditVersion . v1 ,
69
+ } ,
68
70
]
69
71
70
72
export default class BulkEdits extends Component < BulkEditsProps , BulkEditsState > {
@@ -77,7 +79,6 @@ export default class BulkEdits extends Component<BulkEditsProps, BulkEditsState>
77
79
outputResult : undefined ,
78
80
impactedObjects : undefined ,
79
81
isReadmeLoading : true ,
80
- bulkConfig : [ ] ,
81
82
readmeVersionOptions : ReadmeVersionOptions ,
82
83
selectedReadmeVersionOption : ReadmeVersionOptions [ 0 ] ,
83
84
readmeResult : {
@@ -87,6 +88,7 @@ export default class BulkEdits extends Component<BulkEditsProps, BulkEditsState>
87
88
showExamples : true ,
88
89
activeOutputTab : 'output' ,
89
90
codeEditorPayload : undefined ,
91
+ schema : null ,
90
92
}
91
93
}
92
94
@@ -101,26 +103,26 @@ export default class BulkEdits extends Component<BulkEditsProps, BulkEditsState>
101
103
102
104
getInitialized ( ) {
103
105
Promise . allSettled ( [
104
- getBulkEditConfig ?.( ) . then ( ( { result : { readme } } ) => {
105
- return readme
106
- } ) ,
106
+ ( getBulkEditConfig ?.( ) as Promise < ResponseType < BulkEditConfigV2Type > > ) . then (
107
+ ( { result : { readme, schema } } ) => {
108
+ this . setState ( { schema } )
109
+
110
+ return readme
111
+ } ,
112
+ ) ,
107
113
getSeeExample ( ) . then ( ( { result } ) => {
108
114
return result [ 0 ] . readme
109
115
} ) ,
110
- ] )
111
- . then ( ( [ v2ReadmeResult , v1ReadmeResult ] ) => {
112
- const v2Readme = v2ReadmeResult . status === 'fulfilled' ? v2ReadmeResult . value : null
113
- const v1Readme = v1ReadmeResult . status === 'fulfilled' ? v1ReadmeResult . value : null
116
+ ] ) . then ( ( [ v2ReadmeResult , v1ReadmeResult ] ) => {
117
+ const v2Readme = v2ReadmeResult . status === 'fulfilled' ? v2ReadmeResult . value : null
118
+ const v1Readme = v1ReadmeResult . status === 'fulfilled' ? v1ReadmeResult . value : null
114
119
115
- this . setState ( {
116
- isReadmeLoading : false ,
117
- readmeResult : { [ BulkEditVersion . v1 ] : v1Readme , [ BulkEditVersion . v2 ] : v2Readme } ,
118
- } )
119
- } )
120
- . catch ( ( error ) => {
121
- showError ( error )
122
- this . setState ( { isReadmeLoading : false , statusCode : error . code } )
120
+ this . setState ( {
121
+ isReadmeLoading : false ,
122
+ view : ViewType . FORM ,
123
+ readmeResult : { [ BulkEditVersion . v1 ] : v1Readme , [ BulkEditVersion . v2 ] : v2Readme } ,
123
124
} )
125
+ } )
124
126
}
125
127
126
128
handleRunButton = ( ) => {
@@ -248,12 +250,13 @@ export default class BulkEdits extends Component<BulkEditsProps, BulkEditsState>
248
250
249
251
return (
250
252
< div className = "dc__grid-rows-2 flex-grow-1 dc__overflow-hidden" >
251
- < div className = "dc__overflow-auto " >
253
+ < div className = "dc__overflow-hidden " >
252
254
< CodeEditor
253
255
mode = { MODES . YAML }
254
- height = "auto "
256
+ height = "100% "
255
257
value = { this . state . codeEditorPayload }
256
258
onChange = { this . handleConfigChange }
259
+ validatorSchema = { this . state . schema }
257
260
/>
258
261
</ div >
259
262
< div className = "bulk-output-drawer bg__primary flexbox-col dc__overflow-auto" >
@@ -449,7 +452,7 @@ export default class BulkEdits extends Component<BulkEditsProps, BulkEditsState>
449
452
}
450
453
451
454
if ( ! readmeJson ) {
452
- return < GenericSectionErrorState rootClassName = ' flex-grow-1' />
455
+ return < GenericSectionErrorState rootClassName = " flex-grow-1" />
453
456
}
454
457
455
458
return (
0 commit comments