Skip to content

Commit bb2438d

Browse files
thetruecpaulCharles Paul
andauthored
fix(teamStats): Fix "Invalid Period" showing on custom date range (#95293)
The Team Stats page allows users to query custom time ranges. Currently, _actually_ doing so makes the selector UI show "Invalid Period". (This is purely a visual bug with the selector — the actual data / graphs rendered are correct to the user-selected time range.) Fix the selector to treat custom time ranges the same way it treats default ranges. --------- Co-authored-by: Charles Paul <charlespaul@R4KCFH7MHY.local>
1 parent 9049efb commit bb2438d

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

static/app/views/organizationStats/teamInsights/controls.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {Select} from 'sentry/components/core/select';
88
import TeamSelector from 'sentry/components/teamSelector';
99
import type {ChangeData} from 'sentry/components/timeRangeSelector';
1010
import {TimeRangeSelector} from 'sentry/components/timeRangeSelector';
11+
import {getArbitraryRelativePeriod} from 'sentry/components/timeRangeSelector/utils';
1112
import {t} from 'sentry/locale';
1213
import {space} from 'sentry/styles/space';
1314
import type {DateString} from 'sentry/types/core';
@@ -24,7 +25,7 @@ import {dataDatetime} from './utils';
2425
const INSIGHTS_DEFAULT_STATS_PERIOD = '8w';
2526

2627
const relativeOptions = {
27-
'14d': t('Last 2 weeks'),
28+
'2w': t('Last 2 weeks'),
2829
'4w': t('Last 4 weeks'),
2930
[INSIGHTS_DEFAULT_STATS_PERIOD]: t('Last 8 weeks'),
3031
'12w': t('Last 12 weeks'),
@@ -228,9 +229,15 @@ function TeamStatsControls({
228229
utc={utc ?? null}
229230
onChange={handleUpdateDatetime}
230231
showAbsolute={false}
231-
relativeOptions={relativeOptions}
232-
// @ts-expect-error TS(7053): Element implicitly has an 'any' type because expre... Remove this comment to see the full error message
233-
triggerLabel={period && relativeOptions[period]}
232+
relativeOptions={props => ({
233+
...relativeOptions,
234+
...props.arbitraryOptions,
235+
})}
236+
triggerLabel={
237+
period &&
238+
// @ts-expect-error TS(7053): Element implicitly has an 'any' type because expre... Remove this comment to see the full error message
239+
(relativeOptions[period] || getArbitraryRelativePeriod(period)[period])
240+
}
234241
triggerProps={{prefix: t('Date Range')}}
235242
/>
236243
</ControlsWrapper>

0 commit comments

Comments
 (0)