File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed
static/app/components/timeRangeSelector Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -258,6 +258,14 @@ describe('TimeRangeSelector', function () {
258
258
} ) ;
259
259
} ) ;
260
260
261
+ it ( 'respects maxPickableDays for defaults' , async ( ) => {
262
+ renderComponent ( { maxPickableDays : 30 } ) ;
263
+
264
+ await userEvent . click ( screen . getByRole ( 'button' , { expanded : false } ) ) ;
265
+
266
+ expect ( screen . queryByRole ( 'option' , { name : 'Last 90 days' } ) ) . not . toBeInTheDocument ( ) ;
267
+ } ) ;
268
+
261
269
it ( 'respects maxPickableDays for arbitrary time ranges' , async ( ) => {
262
270
renderComponent ( { maxPickableDays : 30 } ) ;
263
271
Original file line number Diff line number Diff line change @@ -296,8 +296,15 @@ export function TimeRangeSelector({
296
296
) ;
297
297
298
298
const arbitraryRelativePeriods = getArbitraryRelativePeriod ( relative ) ;
299
+
300
+ const restrictedDefaultPeriods = Object . fromEntries (
301
+ Object . entries ( DEFAULT_RELATIVE_PERIODS ) . filter (
302
+ ( [ period ] ) => parsePeriodToHours ( period ) <= maxPickableDays * 24
303
+ )
304
+ ) ;
305
+
299
306
const defaultRelativePeriods = {
300
- ...DEFAULT_RELATIVE_PERIODS ,
307
+ ...restrictedDefaultPeriods ,
301
308
...arbitraryRelativePeriods ,
302
309
} ;
303
310
return (
You can’t perform that action at this time.
0 commit comments