@@ -32,6 +32,7 @@ import {
32
32
ButtonVariantType ,
33
33
ButtonStyleType ,
34
34
MODES ,
35
+ Icon ,
35
36
} from '@devtron-labs/devtron-fe-common-lib'
36
37
import { SERVER_MODE , ViewType } from '../../config'
37
38
import { BulkEditsProps , BulkEditsState } from './bulkEdits.type'
@@ -49,7 +50,7 @@ import {
49
50
import { OutputDivider , OutputObjectTabs , STATUS } from './constants'
50
51
51
52
export default class BulkEdits extends Component < BulkEditsProps , BulkEditsState > {
52
- constructor ( props ) {
53
+ constructor ( props : BulkEditsProps ) {
53
54
super ( props )
54
55
55
56
this . state = {
@@ -58,13 +59,11 @@ export default class BulkEdits extends Component<BulkEditsProps, BulkEditsState>
58
59
outputResult : undefined ,
59
60
impactedObjects : undefined ,
60
61
isReadmeLoading : true ,
61
- outputName : 'output' ,
62
62
bulkConfig : [ ] ,
63
63
updatedTemplate : [ ] ,
64
64
readmeResult : [ ] ,
65
65
showExamples : true ,
66
- showOutputData : true ,
67
- showImpactedData : false ,
66
+ activeOutputTab : 'output' ,
68
67
codeEditorPayload : undefined ,
69
68
}
70
69
}
@@ -109,13 +108,9 @@ export default class BulkEdits extends Component<BulkEditsProps, BulkEditsState>
109
108
} )
110
109
}
111
110
112
- handleRunButton = ( e ) => {
113
- const outputDiv = document . querySelector ( '.code-editor-body' )
114
- outputDiv . scrollTop = outputDiv . scrollHeight
115
-
111
+ handleRunButton = ( ) => {
116
112
this . setState ( {
117
113
view : ViewType . LOADING ,
118
- outputName : 'output' ,
119
114
} )
120
115
121
116
let configJson : any = { }
@@ -141,26 +136,20 @@ export default class BulkEdits extends Component<BulkEditsProps, BulkEditsState>
141
136
this . setState ( {
142
137
statusCode : 0 ,
143
138
view : ViewType . FORM ,
144
- showOutputData : true ,
145
- outputName : 'output' ,
139
+ activeOutputTab : 'output' ,
146
140
outputResult,
147
- showImpactedData : false ,
148
141
impactedObjects : undefined ,
149
142
} )
150
143
} )
151
144
. catch ( ( error ) => {
152
145
showError ( error )
153
- this . setState ( { view : ViewType . FORM , statusCode : error . code , outputName : 'output' } )
146
+ this . setState ( { view : ViewType . FORM , statusCode : error . code } )
154
147
} )
155
148
}
156
149
157
150
handleShowImpactedObjectButton = ( ) => {
158
- const outputDiv = document . querySelector ( '.code-editor-body' )
159
- outputDiv . scrollTop = outputDiv . scrollHeight
160
-
161
151
this . setState ( {
162
152
view : ViewType . LOADING ,
163
- outputName : 'impacted' ,
164
153
} )
165
154
166
155
let configJson : any = { }
@@ -186,34 +175,35 @@ export default class BulkEdits extends Component<BulkEditsProps, BulkEditsState>
186
175
view : ViewType . FORM ,
187
176
impactedObjects,
188
177
outputResult : undefined ,
189
- outputName : 'impacted' ,
190
- showImpactedData : true ,
178
+ activeOutputTab : 'impacted' ,
191
179
} )
192
180
} )
193
181
. catch ( ( error ) => {
194
182
showError ( error )
195
- this . setState ( { view : ViewType . FORM , statusCode : error . code , outputName : 'impacted' } )
183
+ this . setState ( { view : ViewType . FORM , statusCode : error . code } )
196
184
} )
197
185
}
198
186
199
187
renderCodeEditorHeader = ( ) => {
200
188
return (
201
189
< div className = "flex bg__primary px-20 py-8 dc__border-bottom dc__content-space" >
190
+ < h1 className = 'm-0 fs-13 cn-9 fw-6 lh-20 dc__open-sans' > Script</ h1 >
191
+
202
192
< div className = "flexbox dc__gap-12" >
203
- < Button
204
- text = "Run"
205
- onClick = { this . handleRunButton }
206
- dataTestId = "run-button"
207
- startIcon = { < PlayButton /> }
208
- size = { ComponentSizeType . medium }
209
- > </ Button >
210
193
< Button
211
194
text = "Show Impacted Objects"
212
195
onClick = { this . handleShowImpactedObjectButton }
213
196
dataTestId = "show-impacted-objects-button"
214
- size = { ComponentSizeType . medium }
197
+ size = { ComponentSizeType . small }
215
198
variant = { ButtonVariantType . secondary }
216
199
> </ Button >
200
+ < Button
201
+ text = "Run"
202
+ onClick = { this . handleRunButton }
203
+ dataTestId = "run-button"
204
+ startIcon = { < Icon name = 'ic-play-outline' color = { null } /> }
205
+ size = { ComponentSizeType . small }
206
+ > </ Button >
217
207
</ div >
218
208
219
209
{ ! this . state . showExamples ? (
@@ -231,59 +221,53 @@ export default class BulkEdits extends Component<BulkEditsProps, BulkEditsState>
231
221
} )
232
222
}
233
223
234
- handleOutputTab = ( e , key : string ) => {
235
- if ( key == 'output' ) {
236
- this . setState ( {
237
- outputName : 'output' ,
238
- showOutputData : true ,
239
- showImpactedData : false ,
240
- } )
241
- }
242
- if ( key == 'impacted' ) {
243
- this . setState ( {
244
- outputName : 'impacted' ,
245
- showImpactedData : true ,
246
- showOutputData : false ,
247
- } )
248
- }
224
+ handleOutputTab = ( key : BulkEditsState [ 'activeOutputTab' ] ) => {
225
+ this . setState ( {
226
+ activeOutputTab : key ,
227
+ } )
249
228
}
250
229
251
230
renderCodeEditorBody = ( ) => {
231
+ // TODO: need to hide this if no response yet
232
+ // TODO: also need to make it resizable
233
+
252
234
return (
253
- < div className = "code-editor-body dc__grid-half flexbox-col flex-grow-1 mh-0" >
254
- < CodeEditor
255
- mode = { MODES . YAML }
256
- height = "fitToParent"
257
- value = { this . state . codeEditorPayload }
258
- onChange = { this . handleConfigChange }
259
- />
260
- < div className = "bulk-output-drawer bg__primary flexbox-col flex-grow-1 mh-0" >
235
+ < div className = "dc__grid-rows-2 flex-grow-1 dc__overflow-hidden" >
236
+ < div className = 'dc__overflow-auto' >
237
+ < CodeEditor
238
+ mode = { MODES . YAML }
239
+ height = "auto"
240
+ value = { this . state . codeEditorPayload }
241
+ onChange = { this . handleConfigChange }
242
+ />
243
+ </ div >
244
+ < div className = "bulk-output-drawer bg__primary flexbox-col dc__overflow-auto" >
261
245
< div className = "bulk-output-header flex left pl-20 pr-20 pt-6 dc__border-top dc__border-bottom bg__primary" >
262
246
< OutputTabs
263
- handleOutputTabs = { ( e ) => this . handleOutputTab ( e , 'output' ) }
264
- outputName = { this . state . outputName }
247
+ handleOutputTabs = { ( ) => this . handleOutputTab ( 'output' ) }
248
+ outputName = { this . state . activeOutputTab }
265
249
value = "output"
266
250
name = { OutputObjectTabs . OUTPUT }
267
251
/>
268
252
< OutputTabs
269
- handleOutputTabs = { ( e ) => this . handleOutputTab ( e , 'impacted' ) }
270
- outputName = { this . state . outputName }
253
+ handleOutputTabs = { ( ) => this . handleOutputTab ( 'impacted' ) }
254
+ outputName = { this . state . activeOutputTab }
271
255
value = "impacted"
272
256
name = { OutputObjectTabs . IMPACTED_OBJECTS }
273
257
/>
274
258
</ div >
275
259
< div
276
- className = "bulk-output-body cn-9 fs-13 p-20 dc__overflow-auto flexbox-col flex-grow-1 mh-0 "
260
+ className = "bulk-output-body cn-9 fs-13 p-20 dc__overflow-auto flexbox-col flex-grow-1"
277
261
data-testid = "output-message"
278
262
>
279
- { this . state . showOutputData ? (
263
+ { this . state . activeOutputTab === 'output' ? (
280
264
this . state . statusCode === 404 ? (
281
265
< > { STATUS . ERROR } </ >
282
266
) : (
283
267
this . renderOutputs ( )
284
268
)
285
269
) : null }
286
- { this . state . showImpactedData ? (
270
+ { this . state . activeOutputTab === 'impacted' ? (
287
271
this . state . statusCode === 404 ? (
288
272
< > { STATUS . ERROR } </ >
289
273
) : (
@@ -459,15 +443,15 @@ export default class BulkEdits extends Component<BulkEditsProps, BulkEditsState>
459
443
return this . state . isReadmeLoading ? (
460
444
< Progressing pageLoader />
461
445
) : (
462
- < div className = "deploy-chart__readme-column flexbox-col flex-grow-1 mh-0 dc__overflow-auto" >
463
- < MarkDown markdown = { readmeJson } className = "flexbox-col flex-grow-1 mh-0 " />
446
+ < div className = "deploy-chart__readme-column flexbox-col flex-grow-1 dc__overflow-auto" >
447
+ < MarkDown markdown = { readmeJson } className = "flexbox-col flex-grow-1" />
464
448
</ div >
465
449
)
466
450
}
467
451
468
452
renderBulkCodeEditor = ( ) => {
469
453
return (
470
- < div className = "dc__border-right flexbox-col flex-grow-1 mh-0 " >
454
+ < div className = "bulk-container flexbox-col flex-grow-1 dc__overflow-hidden " >
471
455
{ this . renderCodeEditorHeader ( ) }
472
456
{ this . renderCodeEditorBody ( ) }
473
457
</ div >
@@ -476,7 +460,7 @@ export default class BulkEdits extends Component<BulkEditsProps, BulkEditsState>
476
460
477
461
renderReadmeSection = ( ) => {
478
462
return (
479
- < div className = "flexbox-col flex-grow-1 mh-0 dc__overflow-hidden" >
463
+ < div className = "flexbox-col flex-grow-1 dc__overflow-hidden" >
480
464
{ this . renderSampleTemplateHeader ( ) }
481
465
{ this . renderSampleTemplateBody ( ) }
482
466
</ div >
@@ -485,26 +469,13 @@ export default class BulkEdits extends Component<BulkEditsProps, BulkEditsState>
485
469
486
470
renderCodeEditorAndReadme = ( ) => {
487
471
return (
488
- < div className = "bulk-container vertical-divider flex-grow-1 mh-0 dc__grid-half" >
472
+ < div className = "bulk-container vertical-divider flex-grow-1 dc__grid-half dc__overflow-hidden " >
489
473
{ this . renderBulkCodeEditor ( ) }
490
474
{ this . renderReadmeSection ( ) }
491
475
</ div >
492
476
)
493
477
}
494
478
495
- renderReadmeAndCodeEditor = ( ) => {
496
- return (
497
- < div className = { `${ this . state . showExamples ? 'code-editor-readme' : null } ` } >
498
- < div > { this . renderBulkCodeEditor ( ) } </ div >
499
- { this . state . showExamples ? (
500
- < div className = "flex end" style = { { transition : 'all .2s ease-out' } } >
501
- { this . renderReadmeSection ( ) }
502
- </ div >
503
- ) : null }
504
- </ div >
505
- )
506
- }
507
-
508
479
renderBulkEditBody = ( ) => {
509
480
return ! this . state . showExamples ? this . renderBulkCodeEditor ( ) : this . renderCodeEditorAndReadme ( )
510
481
}
0 commit comments