Skip to content

Commit f31e897

Browse files
committed
Default period exposed as a prop
1 parent 23f9f81 commit f31e897

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,8 @@ function parsePeriodString(period: string): { value: number; unit: string } | nu
128128
return null;
129129
}
130130

131-
const defaultPeriod = "7d";
132-
const defaultPeriodMs = parse(defaultPeriod);
131+
const DEFAULT_PERIOD = "7d";
132+
const defaultPeriodMs = parse(DEFAULT_PERIOD);
133133
if (!defaultPeriodMs) {
134134
throw new Error("Invalid default period");
135135
}
@@ -140,10 +140,12 @@ export const timeFilters = ({
140140
period,
141141
from,
142142
to,
143+
defaultPeriod = DEFAULT_PERIOD,
143144
}: {
144145
period?: string;
145146
from?: string | number;
146147
to?: string | number;
148+
defaultPeriod?: string;
147149
}): {
148150
period?: string;
149151
from?: Date;
@@ -199,10 +201,12 @@ export function timeFilterRenderValues({
199201
from,
200202
to,
201203
period,
204+
defaultPeriod = DEFAULT_PERIOD,
202205
}: {
203206
from?: Date;
204207
to?: Date;
205208
period?: string;
209+
defaultPeriod?: string;
206210
}) {
207211
const rangeType: TimeRangeType = from && to ? "range" : from ? "from" : to ? "to" : "period";
208212

@@ -306,11 +310,13 @@ export function TimeDropdown({
306310
period,
307311
from,
308312
to,
313+
defaultPeriod = DEFAULT_PERIOD,
309314
}: {
310315
trigger: ReactNode;
311316
period?: string;
312317
from?: Date;
313318
to?: Date;
319+
defaultPeriod?: string;
314320
}) {
315321
const [open, setOpen] = useState<boolean | undefined>();
316322
const { replace } = useSearchParams();

0 commit comments

Comments
 (0)