@@ -17,15 +17,27 @@ import MessageUI, { MsgUIType } from '../../../../common/message.ui'
17
17
import { AppType , ManifestActionPropsType , NodeType } from '../../../appDetails.type'
18
18
import YAML from 'yaml'
19
19
import { toast } from 'react-toastify'
20
- import { Checkbox , CHECKBOX_VALUE , DeploymentAppTypes , showError , ToastBody } from '@devtron-labs/devtron-fe-common-lib'
20
+ import {
21
+ Checkbox ,
22
+ CHECKBOX_VALUE ,
23
+ ConditionalWrap ,
24
+ DeploymentAppTypes ,
25
+ noop ,
26
+ showError ,
27
+ ToastBody ,
28
+ } from '@devtron-labs/devtron-fe-common-lib'
21
29
import { appendRefetchDataToUrl } from '../../../../../util/URLUtil'
22
30
import {
23
31
EA_MANIFEST_SECRET_EDIT_MODE_INFO_TEXT ,
24
32
EA_MANIFEST_SECRET_INFO_TEXT ,
25
33
} from '../../../../../../config/constantMessaging'
26
34
import { MODES } from '../../../../../../config'
27
- import { EMPTY_YAML_ERROR , SAVE_DATA_VALIDATION_ERROR_MSG } from '../../../../values/chartValuesDiff/ChartValuesView.constants'
35
+ import {
36
+ EMPTY_YAML_ERROR ,
37
+ SAVE_DATA_VALIDATION_ERROR_MSG ,
38
+ } from '../../../../values/chartValuesDiff/ChartValuesView.constants'
28
39
import { getDecodedEncodedSecretManifestData , getTrimmedManifestData } from '../nodeDetail.util'
40
+ import Tippy from '@tippyjs/react'
29
41
30
42
function ManifestComponent ( {
31
43
selectedTab,
@@ -39,7 +51,14 @@ function ManifestComponent({
39
51
const history = useHistory ( )
40
52
const [ { tabs, activeTab } , dispatch ] = useTab ( ManifestTabJSON )
41
53
const { url } = useRouteMatch ( )
42
- const params = useParams < { actionName : string ; podName : string ; nodeType : string ; node : string ; group : string , namespace : string } > ( )
54
+ const params = useParams < {
55
+ actionName : string
56
+ podName : string
57
+ nodeType : string
58
+ node : string
59
+ group : string
60
+ namespace : string
61
+ } > ( )
43
62
const [ manifest , setManifest ] = useState ( '' )
44
63
const [ modifiedManifest , setModifiedManifest ] = useState ( '' )
45
64
const [ activeManifestEditorData , setActiveManifestEditorData ] = useState ( '' )
@@ -86,8 +105,7 @@ function ManifestComponent({
86
105
if (
87
106
isResourceBrowserView ||
88
107
appDetails . appType === AppType . EXTERNAL_HELM_CHART ||
89
- ( appDetails . deploymentAppType === DeploymentAppTypes . GITOPS &&
90
- appDetails . deploymentAppDeleteRequest )
108
+ ( appDetails . deploymentAppType === DeploymentAppTypes . GITOPS && appDetails . deploymentAppDeleteRequest )
91
109
) {
92
110
markActiveTab ( 'Live manifest' )
93
111
}
@@ -166,7 +184,7 @@ function ManifestComponent({
166
184
167
185
const handleEditorValueChange = ( codeEditorData : string ) => {
168
186
if ( activeTab === 'Live manifest' && isEditmode ) {
169
- setModifiedManifest ( codeEditorData )
187
+ setModifiedManifest ( codeEditorData )
170
188
}
171
189
}
172
190
@@ -186,7 +204,7 @@ function ManifestComponent({
186
204
if ( ! modifiedManifest ) {
187
205
setErrorText ( `${ SAVE_DATA_VALIDATION_ERROR_MSG } "${ EMPTY_YAML_ERROR } "` )
188
206
// Handled for blocking API call
189
- manifestString = ""
207
+ manifestString = ''
190
208
} else {
191
209
manifestString = JSON . stringify ( YAML . parse ( modifiedManifest ) )
192
210
}
@@ -227,7 +245,7 @@ function ManifestComponent({
227
245
className : 'devtron-toast unauthorized' ,
228
246
} ,
229
247
)
230
- } else if ( err . code === 400 || err . code === 409 || err . code === 422 ) {
248
+ } else if ( err . code === 400 || err . code === 409 || err . code === 422 ) {
231
249
const error = err [ 'errors' ] && err [ 'errors' ] [ 0 ]
232
250
if ( error && error . code && error . userMessage ) {
233
251
setErrorText ( `ERROR ${ err . code } > Message: “${ error . userMessage } ”` )
@@ -303,29 +321,54 @@ function ManifestComponent({
303
321
updateEditor ( _tab . name )
304
322
}
305
323
306
- const onChangeToggleShowDecodedValue = ( ) => {
324
+ const onChangeToggleShowDecodedValue = ( jsonManifestData ) => {
325
+ if ( ! jsonManifestData ?. data ) return
307
326
setShowDecodedData ( ! showDecodedData )
308
- const jsonManifestData = YAML . parse ( trimedManifestEditorData )
309
- if ( ! showDecodedData ) {
310
- setTrimedManifestEditorData ( getDecodedEncodedSecretManifestData ( jsonManifestData , true , showDecodedData ) as string )
327
+ if ( ! showDecodedData ) {
328
+ setTrimedManifestEditorData (
329
+ getDecodedEncodedSecretManifestData ( jsonManifestData , true , showDecodedData ) as string ,
330
+ )
311
331
} else {
312
332
setTrimedManifestEditorData ( getDecodedEncodedSecretManifestData ( jsonManifestData , true , true ) as string )
313
333
}
314
334
}
315
335
316
336
const renderShowDecodedValueCheckbox = ( ) => {
317
- return (
318
- < div className = "flex left ml-8" >
319
- < Checkbox
320
- rootClassName = "mb-0-imp h-18"
321
- id = "showDecodedValue"
322
- isChecked = { showDecodedData }
323
- onChange = { onChangeToggleShowDecodedValue }
324
- value = { CHECKBOX_VALUE . CHECKED }
325
- />
326
- Show decoded Value
327
- </ div >
328
- )
337
+ const jsonManifestData = YAML . parse ( trimedManifestEditorData )
338
+ if ( jsonManifestData ?. kind === 'Secret' && ! isEditmode && secretViewAccess ) {
339
+ return (
340
+ < ConditionalWrap
341
+ condition = { ! jsonManifestData ?. data }
342
+ wrap = { ( children ) => (
343
+ < Tippy
344
+ className = "default-tt w-200"
345
+ arrow = { false }
346
+ placement = "top-start"
347
+ content = "Nothing to decode, data field not found."
348
+ >
349
+ { children }
350
+ </ Tippy >
351
+ ) }
352
+ >
353
+ < div
354
+ className = { `${
355
+ ! jsonManifestData ?. data ? 'dc__opacity-0_5 cursor-not-allowed' : ''
356
+ } flex left ml-8`}
357
+ >
358
+ < Checkbox
359
+ rootClassName = { `${
360
+ ! jsonManifestData ?. data ? 'dc__opacity-0_5 cursor-not-allowed' : 'cursor'
361
+ } mb-0-imp h-18`}
362
+ id = "showDecodedValue"
363
+ isChecked = { showDecodedData }
364
+ onChange = { ( ) => onChangeToggleShowDecodedValue ( jsonManifestData ) }
365
+ value = { CHECKBOX_VALUE . CHECKED }
366
+ />
367
+ Show decoded Value
368
+ </ div >
369
+ </ ConditionalWrap >
370
+ )
371
+ }
329
372
}
330
373
331
374
return isDeleted ? (
@@ -446,7 +489,7 @@ function ManifestComponent({
446
489
}
447
490
className = "flex left"
448
491
>
449
- { ! isEditmode && secretViewAccess && renderShowDecodedValueCheckbox ( ) }
492
+ { renderShowDecodedValueCheckbox ( ) }
450
493
</ CodeEditor . Information >
451
494
) }
452
495
{ activeTab === 'Compare' && (
0 commit comments