Skip to content

Commit e002afc

Browse files
committed
fix(webapp): reset webhook detail pagination when the time range changes
TimeFilter clears the generic cursor/direction on apply, but the webhook detail page paginates under deliveriesCursor/deliveriesDirection and runsCursor/ runsDirection, so changing the range left a stale page and the list came back empty or misaligned. TimeFilter gains an optional clearParams, and the page passes its namespaced pagination params so a range change returns to the first page.
1 parent c636605 commit e002afc

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

  • apps/webapp/app
    • components/runs/v3
    • routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.webhooks.$webhookParam

apps/webapp/app/components/runs/v3/SharedFilters.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,8 @@ export interface TimeFilterProps {
358358
maxPeriodDays?: number;
359359
/** Optional className override for the value text in the filter pill */
360360
valueClassName?: string;
361+
/** Extra URL params to clear when the range changes, in addition to the default cursor/direction (e.g. a page's namespaced pagination params). */
362+
clearParams?: string[];
361363
}
362364

363365
export function TimeFilter({
@@ -372,6 +374,7 @@ export function TimeFilter({
372374
onValueChange,
373375
maxPeriodDays,
374376
valueClassName,
377+
clearParams,
375378
}: TimeFilterProps = {}) {
376379
const { value } = useSearchParams();
377380
// In controlled mode (onValueChange provided) the caller owns all three values via local
@@ -441,6 +444,7 @@ export function TimeFilter({
441444
applyShortcut={applyShortcut}
442445
onValueChange={onValueChange}
443446
maxPeriodDays={maxPeriodDays}
447+
clearParams={clearParams}
444448
/>
445449
)}
446450
</FilterMenuProvider>
@@ -471,6 +475,7 @@ export function TimeDropdown({
471475
onApply,
472476
onValueChange,
473477
maxPeriodDays,
478+
clearParams,
474479
}: {
475480
trigger: ReactNode;
476481
period?: string;
@@ -484,10 +489,13 @@ export function TimeDropdown({
484489
onValueChange?: (values: TimeFilterApplyValues) => void;
485490
/** When set an upgrade message will be shown if you select a period further back than this number of days */
486491
maxPeriodDays?: number;
492+
/** Extra URL params to clear on apply, alongside the default cursor/direction. */
493+
clearParams?: string[];
487494
}) {
488495
const organization = useOptionalOrganization();
489496
const [open, setOpen] = useState<boolean | undefined>();
490497
const { replace } = useSearchParams();
498+
const extraCleared = Object.fromEntries((clearParams ?? []).map((key) => [key, undefined]));
491499
const [fromValue, setFromValue] = useState(from);
492500
const [toValue, setToValue] = useState(to);
493501

@@ -561,6 +569,7 @@ export function TimeDropdown({
561569
onValueChange(values);
562570
} else {
563571
replace({
572+
...extraCleared,
564573
period: periodToApply,
565574
cursor: undefined,
566575
direction: undefined,
@@ -620,6 +629,7 @@ export function TimeDropdown({
620629
} else {
621630
// URL mode - navigate
622631
replace({
632+
...extraCleared,
623633
period: undefined,
624634
cursor: undefined,
625635
direction: undefined,

apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.webhooks.$webhookParam/route.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,16 @@ export default function Page() {
302302
</TabContainer>
303303
{tab !== "endpoints" && tab !== "console" && (
304304
<div className="ml-auto flex items-center gap-2 self-center">
305-
<TimeFilter defaultPeriod="7d" labelName={tabLabel} />
305+
<TimeFilter
306+
defaultPeriod="7d"
307+
labelName={tabLabel}
308+
clearParams={[
309+
"deliveriesCursor",
310+
"deliveriesDirection",
311+
"runsCursor",
312+
"runsDirection",
313+
]}
314+
/>
306315
{tab === "deliveries" ? (
307316
<Suspense fallback={null}>
308317
<TypedAwait resolve={deliveriesList} errorElement={null}>

0 commit comments

Comments
 (0)