@@ -23,6 +23,7 @@ import moment, { Moment } from 'moment'
23
23
import { isInclusivelyBeforeDay , DayPickerRangeController } from 'react-dates'
24
24
import './calendar.css'
25
25
import { ReactComponent as ArrowDown } from '../../../assets/icons/ic-chevron-down.svg'
26
+ import { DA_APP_DETAILS_GA_EVENTS } from '@Components/app/details/appDetails/constants'
26
27
27
28
interface DatePickerType2Props {
28
29
calendar
@@ -126,12 +127,16 @@ export class DatePickerType2 extends Component<DatePickerType2Props, any> {
126
127
this . renderDatePresets = this . renderDatePresets . bind ( this )
127
128
}
128
129
129
- getInitialVisibleMonth = ( ) => {
130
- return this . props . calendar . endDate
130
+ onClickApplyTimeChange = ( ) => {
131
+ this . setState ( { showCalendar : false } )
132
+ this . props . handleApply ( )
133
+ ReactGA . event ( DA_APP_DETAILS_GA_EVENTS . MetricsApplyTimeChange )
131
134
}
132
135
133
- handleIsDayBlocked ( day ) {
134
- return false
136
+ onClickPredefinedTimeRange = ( startDate , endDate , endStr ) => ( ) => {
137
+ ReactGA . event ( DA_APP_DETAILS_GA_EVENTS . MetricsPresetTimeRange )
138
+ this . props . handlePredefinedRange ( startDate , endDate , endStr )
139
+ this . setState ( { showCalendar : false } )
135
140
}
136
141
137
142
renderDatePresets ( ) {
@@ -179,10 +184,7 @@ export class DatePickerType2 extends Component<DatePickerType2Props, any> {
179
184
< button
180
185
type = "button"
181
186
className = "cta small"
182
- onClick = { ( ) => {
183
- this . setState ( { showCalendar : false } )
184
- this . props . handleApply ( )
185
- } }
187
+ onClick = { this . onClickApplyTimeChange }
186
188
>
187
189
Apply Time Range
188
190
</ button >
@@ -209,15 +211,7 @@ export class DatePickerType2 extends Component<DatePickerType2Props, any> {
209
211
type = "button"
210
212
key = { text }
211
213
style = { { ...buttonStyles , textAlign : 'left' } }
212
- onClick = { ( ) => {
213
- ReactGA . event ( {
214
- category : 'Deployment Metrics' ,
215
- action : 'Date Range Changed' ,
216
- label : 'Predefined' ,
217
- } )
218
- this . props . handlePredefinedRange ( startDate , endDate , endStr )
219
- this . setState ( { showCalendar : false } )
220
- } }
214
+ onClick = { this . onClickPredefinedTimeRange ( startDate , endDate , endStr ) }
221
215
>
222
216
{ text }
223
217
</ button >
0 commit comments