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
16 changes: 9 additions & 7 deletions apps/dashboard/app/(app)/settings/root-keys/new/client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ import { Label } from "@/components/ui/label";
import { toast } from "@/components/ui/toaster";
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
import { trpc } from "@/lib/trpc/client";
import { unkeyPermissionValidation, type UnkeyPermission } from "@unkey/rbac";
import { type UnkeyPermission, unkeyPermissionValidation } from "@unkey/rbac";
import { ChevronRight } from "lucide-react";
import { useRouter } from "next/navigation";
import { createParser, parseAsArrayOf, useQueryState } from "nuqs";
import { useEffect, useState } from "react";
import { apiPermissions, workspacePermissions } from "../[keyId]/permissions/permissions";
import { createParser, parseAsArrayOf, useQueryState } from "nuqs";

type Props = {
apis: {
Expand All @@ -54,7 +54,7 @@ export const Client: React.FC<Props> = ({ apis }) => {
history: "push",
shallow: false, // otherwise server components won't notice the change
clearOnDefault: true,
})
}),
);

const key = trpc.rootKey.create.useMutation({
Expand Down Expand Up @@ -94,13 +94,15 @@ export const Client: React.FC<Props> = ({ apis }) => {
}));
};

useEffect(() => {
useEffect(() => {
const initialSelectedApiSet = new Set<string>();
selectedPermissions.forEach((permission) => {
const apiId = permission.split('.')[1] ?? ''; // Extract API ID
if (apiId.length) initialSelectedApiSet.add(apiId);
const apiId = permission.split(".")[1] ?? ""; // Extract API ID
if (apiId.length) {
initialSelectedApiSet.add(apiId);
}
});

const initialCardStates: Record<string, boolean> = {};
apis.forEach((api) => {
initialCardStates[api.id] = initialSelectedApiSet.has(api.id); // O(1) check
Expand Down
11 changes: 11 additions & 0 deletions apps/www/app/templates/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,17 @@ export type Template = {
};

export const templates: Record<string, Template> = {
"cost-ratelimit": {
title: "Cost based Ratelimiting",
description: "Ratelimit your AI application based on estimated cost",
authors: ["unrenamed"],
repository: "https://github.com/harshsbhat/ordox",
image: "/images/templates/cost-ratelimit.png",
readmeUrl: "https://raw.githubusercontent.com/harshsbhat/ordox/refs/heads/main/README.md",
url: "https://ordox.vercel.app",
language: "Typescript",
framework: "Next.js",
},
"pdf-view": {
title: "Protecting Digital Content Access",
description:
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions oss.gg/7_create_a_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,6 @@ Your turn 👇

» 04-October-2024 by Nazar Poshtarenko [Time-Sensitive API Keys for Digital Content Access](https://github.com/unrenamed/unkey-pdf-view.git)

» 06-October-2024 by Harsh Bhat [Cost Based ratelimiting](https://github.com/harshsbhat/ordox) [Live](https://ordox.vercel.app/)

---