@@ -20,25 +20,19 @@ import { useHistory, useLocation } from 'react-router-dom'
20
20
21
21
import {
22
22
Button ,
23
- ButtonVariantType ,
24
- ComponentSizeType ,
25
23
DeploymentNodeType ,
26
- Icon ,
27
24
stopPropagation ,
28
25
useSearchString ,
29
26
VisibleModal ,
30
27
} from '@devtron-labs/devtron-fe-common-lib'
31
28
32
- import { BUTTON_TITLE } from '../../../ApplicationGroup/Constants'
33
29
import { importComponentFromFELibrary } from '../../../common'
34
30
import { URL_PARAM_MODE_TYPE } from '../../../common/helpers/types'
35
31
import { getModuleInfo } from '../../../v2/devtronStackManager/DevtronStackManager.service'
36
32
import { AppDetailsCDButtonType } from '../../types'
37
33
import CDMaterial from '../triggerView/cdMaterial'
38
34
import { TRIGGER_VIEW_PARAMS } from '../triggerView/Constants'
39
35
import { MATERIAL_TYPE } from '../triggerView/types'
40
- import { AG_APP_DETAILS_GA_EVENTS , DA_APP_DETAILS_GA_EVENTS } from './constants'
41
- import { getDeployButtonConfig } from './utils'
42
36
43
37
const ApprovalMaterialModal = importComponentFromFELibrary ( 'ApprovalMaterialModal' )
44
38
@@ -49,19 +43,19 @@ const AppDetailsCDButton = ({
49
43
cdModal,
50
44
deploymentAppType,
51
45
isVirtualEnvironment,
52
- deploymentUserActionState,
53
46
loadingDetails,
54
47
environmentName,
55
- isForEmptyState = false ,
56
48
handleSuccess,
57
- isAppView,
58
49
isForRollback = false ,
50
+ buttonProps,
51
+ gaEvent,
59
52
} : AppDetailsCDButtonType ) : JSX . Element => {
60
53
const history = useHistory ( )
61
54
const { searchParams } = useSearchString ( )
62
55
const location = useLocation ( )
63
56
const queryParams = new URLSearchParams ( location . search )
64
57
const mode = queryParams . get ( 'mode' )
58
+
65
59
// deriving from URL and not props as on app details multiple instances exist, but we are rendering only one at a time
66
60
const materialType = queryParams . get ( 'materialType' )
67
61
@@ -78,42 +72,14 @@ const AppDetailsCDButton = ({
78
72
search : new URLSearchParams ( newParams ) . toString ( ) ,
79
73
} )
80
74
81
- if ( isForRollback ) {
82
- ReactGA . event ( DA_APP_DETAILS_GA_EVENTS . RollbackButtonClicked )
83
- return
84
- }
85
- ReactGA . event (
86
- isAppView ? DA_APP_DETAILS_GA_EVENTS . DeployButtonClicked : AG_APP_DETAILS_GA_EVENTS . DeployButtonClicked ,
87
- )
75
+ ReactGA . event ( gaEvent )
88
76
}
89
77
90
78
const closeCDModal = ( e : React . MouseEvent ) : void => {
91
79
stopPropagation ( e )
92
80
history . push ( { search : '' } )
93
81
}
94
82
95
- const { buttonStyle, iconName } = getDeployButtonConfig ( deploymentUserActionState , isForEmptyState )
96
-
97
- const renderDeployButton = ( ) =>
98
- isForRollback ? (
99
- < Button
100
- dataTestId = "rollback-button"
101
- text = "Rollback"
102
- variant = { ButtonVariantType . text }
103
- onClick = { onClickDeployButton }
104
- size = { ComponentSizeType . small }
105
- />
106
- ) : (
107
- < Button
108
- dataTestId = "deploy-button"
109
- size = { isForEmptyState ? ComponentSizeType . large : ComponentSizeType . small }
110
- text = { isForEmptyState ? 'Select Image to Deploy' : BUTTON_TITLE [ DeploymentNodeType . CD ] }
111
- startIcon = { iconName && < Icon name = { iconName } color = { null } /> }
112
- onClick = { onClickDeployButton }
113
- style = { buttonStyle }
114
- />
115
- )
116
-
117
83
const node = {
118
84
environmentName,
119
85
parentEnvironmentName : cdModal . parentEnvironmentName ,
@@ -165,7 +131,7 @@ const AppDetailsCDButton = ({
165
131
166
132
return (
167
133
< >
168
- { renderDeployButton ( ) }
134
+ < Button { ... buttonProps } onClick = { onClickDeployButton } />
169
135
{ renderCDModal ( ) }
170
136
{ renderApprovalMaterial ( ) }
171
137
</ >
0 commit comments