Skip to content

Commit 7dccb57

Browse files
refactor: remove permission warning and keydetails from root key success (#3741)
Co-authored-by: Andreas Thomas <[email protected]>
1 parent b3e3764 commit 7dccb57

File tree

3 files changed

+5
-115
lines changed

3 files changed

+5
-115
lines changed

apps/dashboard/app/(app)/settings/root-keys/components/table/components/critical-perm-warning.tsx

Lines changed: 0 additions & 41 deletions
This file was deleted.

apps/dashboard/app/(app)/settings/root-keys/components/table/root-keys-list.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import { cn } from "@unkey/ui/src/lib/utils";
99
import dynamic from "next/dynamic";
1010
import { useMemo, useState } from "react";
1111
import { AssignedItemsCell } from "./components/assigned-items-cell";
12-
import { CriticalPermissionIndicator } from "./components/critical-perm-warning";
1312
import { LastUpdated } from "./components/last-updated";
1413
import {
1514
ActionColumnSkeleton,
@@ -81,7 +80,6 @@ export const RootKeysList = () => {
8180
{rootKey.name ?? "Unnamed Root Key"}
8281
</div>
8382
</div>
84-
<CriticalPermissionIndicator rootKey={rootKey} isSelected={isSelected} />
8583
</div>
8684
</div>
8785
);

apps/dashboard/app/(app)/settings/root-keys/new/client.tsx

Lines changed: 5 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,10 @@ import {
1515
CardHeader,
1616
CardTitle,
1717
Checkbox,
18-
Code,
19-
CopyButton,
20-
InfoTooltip,
2118
Input,
22-
VisibleButton,
2319
toast,
2420
} from "@unkey/ui";
25-
import { ArrowRight, ChevronRight } from "lucide-react";
21+
import { ChevronRight } from "lucide-react";
2622
import { useRouter } from "next/navigation";
2723
import { createParser, parseAsArrayOf, useQueryState } from "nuqs";
2824
import { useEffect, useRef, useState } from "react";
@@ -74,13 +70,10 @@ const parseAsUnkeyPermission = createParser({
7470
serialize: String,
7571
});
7672

77-
const UNNAMED_KEY = "Unnamed Key";
78-
7973
export const Client: React.FC<Props> = ({ apis }) => {
8074
const trpcUtils = trpc.useUtils();
8175
const router = useRouter();
8276
const [name, setName] = useState<string | undefined>(undefined);
83-
const [showKeyInSnippet, setShowKeyInSnippet] = useState(false);
8477
const [isConfirmOpen, setIsConfirmOpen] = useState(false);
8578
const [pendingAction, setPendingAction] = useState<
8679
"close" | "create-another" | "go-to-details" | null
@@ -106,22 +99,6 @@ export const Client: React.FC<Props> = ({ apis }) => {
10699
},
107100
});
108101

109-
const snippet = `curl -XPOST '${
110-
process.env.NEXT_PUBLIC_UNKEY_API_URL ?? "https://api.unkey.dev"
111-
}/v1/keys.createKey' \\
112-
-H 'Authorization: Bearer ${key.data?.key}' \\
113-
-H 'Content-Type: application/json' \\
114-
-d '{
115-
"prefix": "hello",
116-
"apiId": "<API_ID>"
117-
}'`;
118-
119-
const split = key.data?.key?.split("_") ?? [];
120-
const maskedKey =
121-
split.length >= 2
122-
? `${split.at(0)}_${"*".repeat(split.at(1)?.length ?? 0)}`
123-
: "*".repeat(split.at(0)?.length ?? 0);
124-
125102
const handleSetChecked = (permission: UnkeyPermission, checked: boolean) => {
126103
setSelectedPermissions((prevPermissions) => {
127104
const permissionSet = new Set(prevPermissions);
@@ -411,39 +388,9 @@ export const Client: React.FC<Props> = ({ apis }) => {
411388
<div className="p-1 w-full my-8">
412389
<div className="h-[1px] bg-grayA-3 w-full" />
413390
</div>
391+
414392
<div className="flex flex-col gap-2 items-start w-full">
415-
<div className="text-gray-12 text-sm font-semibold">Key Details</div>
416-
<div className="bg-white dark:bg-black border rounded-xl border-grayA-5 px-6 w-full">
417-
<div className="flex gap-6 items-center">
418-
<div className="bg-grayA-5 text-gray-12 size-5 flex items-center justify-center rounded ">
419-
<Key2 size="sm-regular" />
420-
</div>
421-
<div className="flex flex-col gap-1 py-6">
422-
<div className="text-accent-12 text-xs font-mono">{key.data?.keyId}</div>
423-
<InfoTooltip
424-
content={name ?? UNNAMED_KEY}
425-
position={{ side: "bottom", align: "center" }}
426-
asChild
427-
disabled={!name}
428-
variant="inverted"
429-
>
430-
<div className="text-accent-9 text-xs max-w-[160px] truncate">
431-
{name ?? UNNAMED_KEY}
432-
</div>
433-
</InfoTooltip>
434-
</div>
435-
<Button
436-
variant="outline"
437-
className="ml-auto font-medium text-[13px] text-gray-12"
438-
onClick={() => handleCloseAttempt("go-to-details")}
439-
>
440-
See key details <ArrowRight size="sm-regular" />
441-
</Button>
442-
</div>
443-
</div>
444-
</div>
445-
<div className="flex flex-col gap-2 items-start w-full mt-6">
446-
<div className="text-gray-12 text-sm font-semibold">Key Secret</div>
393+
<div className="text-gray-12 text-sm font-semibold">Root Key</div>
447394
<SecretKey
448395
value={key.data?.key ?? ""}
449396
title="API Key"
@@ -452,7 +399,7 @@ export const Client: React.FC<Props> = ({ apis }) => {
452399
<div className="text-gray-9 text-[13px] flex items-center gap-1.5">
453400
<CircleInfo className="text-accent-9" size="sm-regular" />
454401
<span>
455-
Copy and save this key secret as it won't be shown again.{" "}
402+
Copy and save this secret as it won't be shown again.{" "}
456403
<a
457404
href="https://www.unkey.com/docs/security/recovering-keys"
458405
target="_blank"
@@ -464,23 +411,9 @@ export const Client: React.FC<Props> = ({ apis }) => {
464411
</span>
465412
</div>
466413
</div>
467-
<div className="flex flex-col gap-2 items-start w-full mt-8">
468-
<div className="text-gray-12 text-sm font-semibold">Try It Out</div>
469-
<Code
470-
visibleButton={
471-
<VisibleButton
472-
isVisible={showKeyInSnippet}
473-
setIsVisible={setShowKeyInSnippet}
474-
/>
475-
}
476-
copyButton={<CopyButton value={snippet} />}
477-
>
478-
{showKeyInSnippet ? snippet : snippet.replace(key.data?.key ?? "", maskedKey)}
479-
</Code>
480-
</div>
481414
<div className="mt-6">
482415
<div className="mt-4 text-center text-gray-10 text-xs leading-6">
483-
All set! You can now create another key or explore the docs to learn more
416+
All set! You can now create another root key or explore the docs to learn more
484417
</div>
485418
</div>
486419
</div>

0 commit comments

Comments
 (0)