@@ -15,7 +15,6 @@ import {
15
15
} from '@patternfly/react-core' ;
16
16
import type { ReportPathsType , ReportType } from 'api/reports/report' ;
17
17
import type { AxiosError } from 'axios' ;
18
- import { format } from 'date-fns' ;
19
18
import messages from 'locales/messages' ;
20
19
import { orderBy } from 'lodash' ;
21
20
import React from 'react' ;
@@ -35,7 +34,7 @@ export interface ExportModalOwnProps {
35
34
groupBy ?: string ;
36
35
isAllItems ?: boolean ;
37
36
isOpen : boolean ;
38
- isTimeScoped ?: boolean ;
37
+ isTimeScoped ?: boolean ; // Indicates API should use time_scope_value or start and end date parameters
39
38
items ?: ComputedReportItem [ ] ;
40
39
onClose ( isOpen : boolean ) ;
41
40
reportPathsType : ReportPathsType ;
@@ -44,7 +43,6 @@ export interface ExportModalOwnProps {
44
43
resolution ?: 'daily' | 'monthly' ; // Default resolution
45
44
showAggregateType ?: boolean ; // Monthly resolution filters are not valid with date range
46
45
showFormatType ?: boolean ; // Format type; CVS / JSON
47
- showTimeScope ?: boolean ; // timeScope filters are not valid with date range
48
46
timeScopeValue ?: number ;
49
47
}
50
48
@@ -79,31 +77,14 @@ const resolutionOptions: {
79
77
{ label : messages . exportResolution , value : 'monthly' } ,
80
78
] ;
81
79
82
- const timeScopeOptions : {
83
- label : MessageDescriptor ;
84
- value : string ;
85
- } [ ] = [
86
- { label : messages . exportTimeScope , value : 'current' } ,
87
- { label : messages . exportTimeScope , value : 'previous' } ,
88
- ] ;
89
-
90
80
export class ExportModalBase extends React . Component < ExportModalProps , ExportModalState > {
91
81
protected defaultState : ExportModalState = {
92
82
error : undefined ,
93
83
formatType : 'csv' ,
94
84
resolution : this . props . resolution || 'monthly' ,
95
- timeScope : this . props . timeScopeValue === - 2 ? 'previous' : 'current' ,
96
85
} ;
97
86
public state : ExportModalState = { ...this . defaultState } ;
98
87
99
- public componentDidUpdate ( prevProps : ExportModalProps ) {
100
- const { timeScopeValue } = this . props ;
101
-
102
- if ( timeScopeValue !== prevProps . timeScopeValue ) {
103
- this . setState ( { timeScope : timeScopeValue === - 2 ? 'previous' : 'current' } ) ;
104
- }
105
- }
106
-
107
88
// Reset default state upon close -- see https://issues.redhat.com/browse/COST-1134
108
89
private handleOnClose = ( ) => {
109
90
this . setState ( { ...this . defaultState } , ( ) => {
@@ -115,10 +96,6 @@ export class ExportModalBase extends React.Component<ExportModalProps, ExportMod
115
96
this . setState ( { error } ) ;
116
97
} ;
117
98
118
- private handleOnMonthChange = event => {
119
- this . setState ( { timeScope : event . currentTarget . value } ) ;
120
- } ;
121
-
122
99
private handleOnNameChange = event => {
123
100
this . setState ( { name : event . currentTarget . value } ) ;
124
101
} ;
@@ -148,7 +125,6 @@ export class ExportModalBase extends React.Component<ExportModalProps, ExportMod
148
125
groupBy,
149
126
intl,
150
127
isAllItems,
151
- isDetailsDateRangeToggleEnabled,
152
128
isExportsToggleEnabled,
153
129
isTimeScoped,
154
130
items,
@@ -157,9 +133,9 @@ export class ExportModalBase extends React.Component<ExportModalProps, ExportMod
157
133
reportType,
158
134
showAggregateType = true ,
159
135
showFormatType = true ,
160
- showTimeScope = isDetailsDateRangeToggleEnabled ? false : true ,
136
+ timeScopeValue ,
161
137
} = this . props ;
162
- const { error, formatType, name, resolution, timeScope } = this . state ;
138
+ const { error, formatType, name, resolution } = this . state ;
163
139
164
140
let sortedItems = [ ...items ] ;
165
141
if ( this . props . isOpen ) {
@@ -179,11 +155,6 @@ export class ExportModalBase extends React.Component<ExportModalProps, ExportMod
179
155
selectedLabel = intl . formatMessage ( messages . exportSelected , { groupBy : 'tag' , count } ) ;
180
156
}
181
157
182
- const thisMonth = new Date ( ) ;
183
- const lastMonth = new Date ( ) . setMonth ( thisMonth . getMonth ( ) - 1 ) ;
184
- const currentMonth = format ( thisMonth , 'MMMM yyyy' ) ;
185
- const previousMonth = format ( lastMonth - 1 , 'MMMM yyyy' ) ;
186
-
187
158
const defaultName =
188
159
name !== undefined
189
160
? name
@@ -211,14 +182,14 @@ export class ExportModalBase extends React.Component<ExportModalProps, ExportMod
211
182
isTimeScoped = { isTimeScoped }
212
183
items = { items }
213
184
key = "confirm"
214
- timeScope = { timeScope }
215
185
onClose = { this . handleOnClose }
216
186
onError = { this . handleOnError }
217
187
name = { defaultName }
218
188
reportPathsType = { reportPathsType }
219
189
reportQueryString = { reportQueryString }
220
190
reportType = { reportType }
221
191
resolution = { resolution }
192
+ timeScopeValue = { timeScopeValue }
222
193
/> ,
223
194
< Button ouiaId = "cancel-btn" key = "cancel" onClick = { this . handleOnClose } variant = { ButtonVariant . link } >
224
195
{ intl . formatMessage ( messages . cancel ) }
@@ -276,31 +247,6 @@ export class ExportModalBase extends React.Component<ExportModalProps, ExportMod
276
247
</ React . Fragment >
277
248
</ FormGroup >
278
249
) }
279
- { showTimeScope && (
280
- < FormGroup fieldId = "timeScope" label = { intl . formatMessage ( messages . exportTimeScopeTitle ) } isRequired >
281
- < React . Fragment >
282
- { timeScopeOptions . map ( ( option , index ) => (
283
- < Radio
284
- key = { index }
285
- id = { `timeScope-${ index } ` }
286
- isValid = { option . value !== undefined }
287
- label = { intl . formatMessage ( option . label , {
288
- date : option . value === 'previous' ? previousMonth : currentMonth ,
289
- value : option . value ,
290
- } ) }
291
- value = { option . value }
292
- isChecked = { timeScope === option . value }
293
- name = "timeScope"
294
- onChange = { this . handleOnMonthChange }
295
- aria-label = { intl . formatMessage ( option . label , {
296
- date : option . value === 'previous' ? previousMonth : currentMonth ,
297
- value : option . value ,
298
- } ) }
299
- />
300
- ) ) }
301
- </ React . Fragment >
302
- </ FormGroup >
303
- ) }
304
250
{ showFormatType && isExportsToggleEnabled && (
305
251
< GridItem span = { 12 } >
306
252
< FormGroup fieldId = "formatType" label = { intl . formatMessage ( messages . exportFormatTypeTitle ) } isRequired >
0 commit comments