Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/dashboard/app/(app)/authorization/permissions/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
import { getTenantId } from "@/lib/auth";
import { asc, db } from "@/lib/db";
import { permissions } from "@unkey/db/src/schema";
import { ChevronRight, Scan } from "lucide-react";
import Link from "next/link";
import { redirect } from "next/navigation";
import { CreateNewPermission } from "./create-new-permission";
import { permissions } from "@unkey/db/src/schema";

export const revalidate = 0;

Expand All @@ -19,7 +19,7 @@ export default async function RolesPage() {
and(eq(table.tenantId, tenantId), isNull(table.deletedAt)),
with: {
permissions: {
orderBy:[asc(permissions.name)],
orderBy: [asc(permissions.name)],
with: {
keys: {
with: {
Expand Down
4 changes: 3 additions & 1 deletion apps/dashboard/app/(app)/desktop-sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Feedback } from "@/components/dashboard/feedback-component";
import { Badge } from "@/components/ui/badge";
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
import type { Workspace } from "@/lib/db";
import { useDelayLoader } from "@/lib/hooks/useDelayLoader";
import { cn } from "@/lib/utils";
import {
BookOpen,
Expand Down Expand Up @@ -219,6 +220,7 @@ export const DesktopSidebar: React.FC<Props> = ({ workspace, className }) => {

const NavLink: React.FC<{ item: NavItem }> = ({ item }) => {
const [isPending, startTransition] = useTransition();
const showLoader = useDelayLoader(isPending);
const router = useRouter();
const link = (
<Link
Expand All @@ -243,7 +245,7 @@ const NavLink: React.FC<{ item: NavItem }> = ({ item }) => {
>
<div className="flex items-center group gap-x-2">
<span className="flex h-5 w-5 shrink-0 items-center justify-center text-[0.625rem]">
{isPending ? (
{showLoader ? (
<Loader2 className="w-5 h-5 shrink-0 animate-spin" />
) : (
<item.icon className="w-5 h-5 shrink-0 [stroke-width:1.25px]" aria-hidden="true" />
Expand Down
22 changes: 22 additions & 0 deletions apps/dashboard/lib/hooks/useDelayLoader.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { useEffect, useState } from "react";

export const useDelayLoader = (isPending: boolean, delay = 50) => {
const [showLoader, setShowLoader] = useState(false);

useEffect(() => {
let timeout: NodeJS.Timeout;
if (isPending) {
timeout = setTimeout(() => {
setShowLoader(true);
}, delay);
} else {
setShowLoader(false);
}

return () => {
clearTimeout(timeout);
};
}, [isPending, delay]);

return showLoader;
};
2 changes: 1 addition & 1 deletion packages/ratelimit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"url": "https://github.com/unkeyed/unkey/issues"
},
"homepage": "https://github.com/unkeyed/unkey#readme",
"files": ["./dist/**","README.md"],
"files": ["./dist/**", "README.md"],
"author": "Andreas Thomas <andreas@unkey.dev>",
"scripts": {
"build": "tsup"
Expand Down