Skip to content

Commit

Permalink
fix(replay): Fix replay duration filter not including unit suffix (#8…
Browse files Browse the repository at this point in the history
…1883)

Fixes an issue in the replays index where adding a "duration" filter
creates an invalid search query due to leaving out the duration unit in
the filter value. This PR changes the `NumericDropdownFilter` to accept
a `formatter` prop to format the value when creating the query string.



https://github.com/user-attachments/assets/6c394e3c-3bea-4cb0-bfed-1468cc545aee


Closes #81424
  • Loading branch information
billyvg authored Dec 10, 2024
1 parent 91ce436 commit a7171bc
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions static/app/views/replays/replayTable/tableCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -179,13 +179,17 @@ function OSBrowserDropdownFilter({
);
}

const DEFAULT_NUMERIC_DROPDOWN_FORMATTER = (val: number) => val.toString();

function NumericDropdownFilter({
type,
val,
triggerOverlay,
formatter = DEFAULT_NUMERIC_DROPDOWN_FORMATTER,
}: {
type: string;
val: number;
formatter?: (val: number) => string;
triggerOverlay?: boolean;
}) {
const location = useLocation<ReplayListLocationQuery>();
Expand All @@ -197,7 +201,7 @@ function NumericDropdownFilter({
label: 'Add to filter',
onAction: generateAction({
key: type,
value: val.toString(),
value: formatter(val),
edit: 'set',
location,
}),
Expand All @@ -207,7 +211,7 @@ function NumericDropdownFilter({
label: 'Show values greater than',
onAction: generateAction({
key: type,
value: '>' + val.toString(),
value: '>' + formatter(val),
edit: 'set',
location,
}),
Expand All @@ -217,7 +221,7 @@ function NumericDropdownFilter({
label: 'Show values less than',
onAction: generateAction({
key: type,
value: '<' + val.toString(),
value: '<' + formatter(val),
edit: 'set',
location,
}),
Expand All @@ -227,7 +231,7 @@ function NumericDropdownFilter({
label: t('Exclude from filter'),
onAction: generateAction({
key: type,
value: val.toString(),
value: formatter(val),
edit: 'remove',
location,
}),
Expand Down Expand Up @@ -528,7 +532,11 @@ export function DurationCell({replay, showDropdownFilters}: Props) {
<Container>
<Duration duration={[replay.duration.asMilliseconds(), 'ms']} precision="sec" />
{showDropdownFilters ? (
<NumericDropdownFilter type="duration" val={replay.duration.asSeconds()} />
<NumericDropdownFilter
type="duration"
val={replay.duration.asSeconds()}
formatter={(val: number) => `${val}s`}
/>
) : null}
</Container>
</Item>
Expand Down

0 comments on commit a7171bc

Please sign in to comment.