Skip to content

Commit

Permalink
fix: ratelimit fitlers
Browse files Browse the repository at this point in the history
  • Loading branch information
chronark committed Nov 29, 2024
1 parent 8019ccd commit 1020546
Showing 1 changed file with 2 additions and 63 deletions.
65 changes: 2 additions & 63 deletions apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/filter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,7 @@
import { ArrayInput } from "@/components/array-input";
import { Button } from "@/components/ui/button";
import { cn } from "@/lib/utils";
import {
CalendarRange,
CheckCheck,
ChevronDown,
Earth,
Locate,
RefreshCw,
User,
X,
} from "lucide-react";
import { CalendarRange, CheckCheck, ChevronDown, RefreshCw, User, X } from "lucide-react";
import {
parseAsArrayOf,
parseAsBoolean,
Expand Down Expand Up @@ -50,22 +41,6 @@ export const Filters: React.FC = () => {
clearOnDefault: true,
}),
);
const [country, setCountry] = useQueryState(
"country",
parseAsArrayOf(parseAsString).withDefault([]).withOptions({
history: "push",
shallow: false, // otherwise server components won't notice the change
clearOnDefault: true,
}),
);
const [ipAddress, setIpAddress] = useQueryState(
"ipAddress",
parseAsArrayOf(parseAsString).withDefault([]).withOptions({
history: "push",
shallow: false, // otherwise server components won't notice the change
clearOnDefault: true,
}),
);
const [success, setSuccess] = useQueryState(
"success",
parseAsBoolean.withOptions({
Expand Down Expand Up @@ -97,8 +72,6 @@ export const Filters: React.FC = () => {
}, [after]);

const [identifierVisible, setIdentifierVisible] = useState(false);
const [ipAddressVisible, setIpAddressVisible] = useState(false);
const [countryVisible, setCountryVisible] = useState(false);
const [successVisible, setSuccessVisible] = useState(false);
const [timeRangeVisible, setTimeRangeVisible] = useState(false);
return (
Expand All @@ -119,14 +92,6 @@ export const Filters: React.FC = () => {
<User className="w-4 h-4 mr-2" />
Identifier
</DropdownMenuItem>
<DropdownMenuItem onClick={() => setIpAddressVisible(true)}>
<Locate className="w-4 h-4 mr-2" />
IP address
</DropdownMenuItem>
<DropdownMenuItem onClick={() => setCountryVisible(true)}>
<Earth className="w-4 h-4 mr-2" />
Country
</DropdownMenuItem>
<DropdownMenuItem onClick={() => setTimeRangeVisible(true)}>
<CalendarRange className="w-4 h-4 mr-2" />
Time
Expand All @@ -137,18 +102,14 @@ export const Filters: React.FC = () => {
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
{identifierVisible || ipAddressVisible || countryVisible ? (
{identifierVisible ? (
<Button
variant="outline"
size="sm"
className="flex items-center h-8 gap-2 bg-background-subtle"
onClick={() => {
setIdentifierVisible(false);
setIdentifier(null);
setIpAddressVisible(false);
setIpAddress(null);
setCountryVisible(false);
setCountry(null);
startTransition(() => {});
}}
>
Expand Down Expand Up @@ -178,28 +139,6 @@ export const Filters: React.FC = () => {
removeFilter={() => setIdentifierVisible(false)}
/>
) : null}
{countryVisible || country.length > 0 ? (
<FilterRow
title="Countries"
selected={country}
setSelected={(v) => {
setCountry(v);
startTransition(() => {});
}}
removeFilter={() => setCountryVisible(false)}
/>
) : null}
{ipAddressVisible || ipAddress.length > 0 ? (
<FilterRow
title="IP address"
selected={ipAddress}
setSelected={(v) => {
setIpAddress(v);
startTransition(() => {});
}}
removeFilter={() => setIpAddressVisible(false)}
/>
) : null}

{successVisible || typeof success === "boolean" ? (
<div className="flex items-center w-full gap-2">
Expand Down

0 comments on commit 1020546

Please sign in to comment.