Skip to content

Commit ad84341

Browse files
fix(pagefilters): Respect maxPickableDays for default options (#87917)
When maxPickableDays is set to lower than 90 we restrict the `last 90 days` from appearing in the options, and so on.
1 parent a7dd09f commit ad84341

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

static/app/components/timeRangeSelector/index.spec.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,14 @@ describe('TimeRangeSelector', function () {
258258
});
259259
});
260260

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+
261269
it('respects maxPickableDays for arbitrary time ranges', async () => {
262270
renderComponent({maxPickableDays: 30});
263271

static/app/components/timeRangeSelector/index.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,8 +296,15 @@ export function TimeRangeSelector({
296296
);
297297

298298
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+
299306
const defaultRelativePeriods = {
300-
...DEFAULT_RELATIVE_PERIODS,
307+
...restrictedDefaultPeriods,
301308
...arbitraryRelativePeriods,
302309
};
303310
return (

0 commit comments

Comments
 (0)