15
15
*/
16
16
17
17
import { Fragment } from 'react'
18
+ import ReactGA from 'react-ga4'
18
19
import {
19
20
Button ,
20
21
ButtonStyleType ,
@@ -26,6 +27,7 @@ import {
26
27
ComponentSizeType ,
27
28
InvalidYAMLTippyWrapper ,
28
29
ToggleResolveScopedVariables ,
30
+ Icon ,
29
31
} from '@devtron-labs/devtron-fe-common-lib'
30
32
import { useParams } from 'react-router-dom'
31
33
import { importComponentFromFELibrary } from '@Components/common'
@@ -40,6 +42,7 @@ import SelectMergeStrategy from './SelectMergeStrategy'
40
42
const ProtectionViewTabGroup = importComponentFromFELibrary ( 'ProtectionViewTabGroup' , null , 'function' )
41
43
const MergePatchWithTemplateCheckbox = importComponentFromFELibrary ( 'MergePatchWithTemplateCheckbox' , null , 'function' )
42
44
const ConfigApproversInfoTippy = importComponentFromFELibrary ( 'ConfigApproversInfoTippy' , null , 'function' )
45
+ const ExpressEditButton = importComponentFromFELibrary ( 'ExpressEditButton' , null , 'function' )
43
46
const ProtectConfigShowCommentsButton = importComponentFromFELibrary (
44
47
'ProtectConfigShowCommentsButton' ,
45
48
null ,
@@ -114,6 +117,7 @@ const ConfigToolbar = ({
114
117
isApprovalPolicyConfigured = false ,
115
118
isApprovalPending,
116
119
isDraftPresent,
120
+ isUnpublished = false ,
117
121
draftId,
118
122
draftVersionId,
119
123
requestedUserId,
@@ -125,6 +129,10 @@ const ConfigToolbar = ({
125
129
isPublishedConfigPresent = true ,
126
130
headerMessage,
127
131
showDeleteOverrideDraftEmptyState,
132
+
133
+ isExceptionUser,
134
+ isExpressEditView,
135
+ expressEditButtonConfig,
128
136
} : ConfigToolbarProps ) => {
129
137
const { envId } = useParams < BaseURLParams > ( )
130
138
const isDisabled = disableAllActions || ! ! parsingError
@@ -148,9 +156,9 @@ const ConfigToolbar = ({
148
156
149
157
const isEditView = ! ! (
150
158
configHeaderTab === ConfigHeaderTabType . VALUES &&
151
- ( isApprovalPolicyConfigured && isDraftPresent
152
- ? selectedProtectionViewTab === ProtectConfigTabsType . EDIT_DRAFT
153
- : true )
159
+ ( ! isApprovalPolicyConfigured ||
160
+ ! isDraftPresent ||
161
+ selectedProtectionViewTab === ProtectConfigTabsType . EDIT_DRAFT )
154
162
)
155
163
156
164
const showProtectedTabs =
@@ -159,7 +167,28 @@ const ConfigToolbar = ({
159
167
configHeaderTab === ConfigHeaderTabType . VALUES &&
160
168
! ! ProtectionViewTabGroup
161
169
170
+ const hideMergeStrategy =
171
+ ! mergeStrategy ||
172
+ ! envId ||
173
+ showDeleteOverrideDraftEmptyState ||
174
+ ( ! isEditView && ! ( isPublishedValuesView && ! ! isPublishedConfigPresent ) )
175
+
176
+ const showExpressEditButton =
177
+ ! ! ExpressEditButton && isExceptionUser && ! isExpressEditView && isEditView && ! showDeleteOverrideDraftEmptyState
178
+
162
179
const getLHSActionNodes = ( ) : JSX . Element => {
180
+ if ( isExpressEditView ) {
181
+ return (
182
+ < >
183
+ < div className = "flex dc__gap-6" >
184
+ < Icon name = "ic-pencil" color = "N700" />
185
+ < p className = "m-0 fs-12 lh-18 cn-9" > Editing Published</ p >
186
+ </ div >
187
+ { ( children || ! hideMergeStrategy ) && < div className = "divider__secondary" /> }
188
+ </ >
189
+ )
190
+ }
191
+
163
192
if ( configHeaderTab === ConfigHeaderTabType . INHERITED ) {
164
193
return (
165
194
< div className = "flexbox dc__align-items-center dc__gap-6" >
@@ -186,6 +215,7 @@ const ConfigToolbar = ({
186
215
selectedTab = { selectedProtectionViewTab }
187
216
handleProtectionViewTabChange = { handleProtectionViewTabChange }
188
217
isApprovalPending = { isApprovalPending }
218
+ hasPublishedConfig = { isPublishedConfigPresent }
189
219
isDisabled = { isDisabled }
190
220
parsingError = { parsingError }
191
221
restoreLastSavedYAML = { restoreLastSavedYAML }
@@ -224,7 +254,7 @@ const ConfigToolbar = ({
224
254
const shouldRenderCommentsView = ! ! isDraftPresent
225
255
const hasNothingToRender = ! shouldRenderApproverInfoTippy && ! shouldRenderCommentsView
226
256
227
- if ( ! isApprovalPolicyConfigured || hasNothingToRender ) {
257
+ if ( ! isApprovalPolicyConfigured || hasNothingToRender || isExpressEditView ) {
228
258
return null
229
259
}
230
260
@@ -293,12 +323,7 @@ const ConfigToolbar = ({
293
323
}
294
324
295
325
const renderSelectMergeStrategy = ( ) => {
296
- if (
297
- ! mergeStrategy ||
298
- ! envId ||
299
- showDeleteOverrideDraftEmptyState ||
300
- ( ! isEditView && ! ( isPublishedValuesView && ! ! isPublishedConfigPresent ) )
301
- ) {
326
+ if ( hideMergeStrategy ) {
302
327
return null
303
328
}
304
329
@@ -391,11 +416,28 @@ const ConfigToolbar = ({
391
416
{ renderSelectMergeStrategy ( ) }
392
417
</ div >
393
418
394
- { isPublishedValuesView && ! isPublishedConfigPresent ? null : (
419
+ { ( showExpressEditButton || ! isPublishedValuesView || isPublishedConfigPresent ) && (
395
420
< div className = "flexbox dc__align-items-center dc__gap-8" >
396
- { renderProtectedConfigActions ( ) }
397
- { renderReadmeAndScopedVariablesBlock ( ) }
398
- { renderPopupMenu ( ) }
421
+ { showExpressEditButton && (
422
+ < ExpressEditButton
423
+ disabled = { isUnpublished }
424
+ { ...( expressEditButtonConfig ?? { } ) }
425
+ onClick = { ( ) => {
426
+ ReactGA . event ( {
427
+ category : 'APP_EXPRESS_EDIT_ACCESSED' ,
428
+ action : 'APP_EXPRESS_EDIT_ACCESSED' ,
429
+ } )
430
+ expressEditButtonConfig ?. onClick ?.( )
431
+ } }
432
+ />
433
+ ) }
434
+ { isPublishedValuesView && ! isPublishedConfigPresent ? null : (
435
+ < >
436
+ { renderProtectedConfigActions ( ) }
437
+ { renderReadmeAndScopedVariablesBlock ( ) }
438
+ { renderPopupMenu ( ) }
439
+ </ >
440
+ ) }
399
441
</ div >
400
442
) }
401
443
</ div >
0 commit comments