Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

feat(api-keys): show the Admin role as Full access on API keys (#18981)

Mark Salpetere3a2bee2a2c0
diff --git a/web/src/features/public-api/components/ApiKeyCreateDialogContent.tsx b/web/src/features/public-api/components/ApiKeyCreateDialogContent.tsx
index 9435f341b5..a2958c372d 100644
--- a/web/src/features/public-api/components/ApiKeyCreateDialogContent.tsx
+++ b/web/src/features/public-api/components/ApiKeyCreateDialogContent.tsx
@@ -39,6 +39,11 @@ type ApiKeyScope = "project" | "organization";
const DEFAULT_ROLE: SystemRole = "ADMIN";
+/** apiKeyRoleNames renames user roles to be more api-key friendly. */
+const apiKeyRoleNames: Record<string, string> = {
+ Admin: "Full access",
+};
+
/** ApiKeyCreateValues is the resolved create-form payload the button forwards to the create mutation. */
export type ApiKeyCreateValues = {
name: string;
@@ -174,7 +179,9 @@ function ApiKeyCreateForm({
<div className="flex items-start gap-2 text-left">
<SelectedRoleIcon className="icon-base mt-0.5 shrink-0" />
<div className="flex flex-col">
- <span className="font-bold">{selectedRoleDef.name}</span>
+ <span className="font-bold">
+ {transformApiKeyRoleName(selectedRoleDef.name)}
+ </span>
<span className="text-muted-foreground text-xs">
{selectedRoleDef.description}
</span>
@@ -186,6 +193,7 @@ function ApiKeyCreateForm({
<RoleSelectItem
key={r}
role={r}
+ transformName={transformApiKeyRoleName}
onViewPermissions={openPermissions}
/>
))}
@@ -214,6 +222,7 @@ function ApiKeyCreateForm({
open={permissionsOpen}
onOpenChange={setPermissionsOpen}
role={permissionsRole}
+ transformName={transformApiKeyRoleName}
/>
)}
</DialogBody>
@@ -225,3 +234,8 @@ function ApiKeyCreateForm({
</DialogContent>
);
}
+
+/** transformApiKeyRoleName maps a role name to its api key display name. */
+function transformApiKeyRoleName(name: string): string {
+ return apiKeyRoleNames[name] ?? name;
+}
diff --git a/web/src/features/rbac/components/RolePermissionPopup.tsx b/web/src/features/rbac/components/RolePermissionPopup.tsx
index d1fbd8f3b5..b379be4dcb 100644
--- a/web/src/features/rbac/components/RolePermissionPopup.tsx
+++ b/web/src/features/rbac/components/RolePermissionPopup.tsx
@@ -21,11 +21,14 @@ export function RolePermissionPopup({
open,
onOpenChange,
role,
+ transformName = (name) => name,
emptyStateComment,
}: {
open: boolean;
onOpenChange: (open: boolean) => void;
role: SystemRole | null;
+ /** transformName rewrites the role name before it is shown. */
+ transformName?: (name: string) => string;
emptyStateComment?: string;
}) {
const def = role ? systemRoleAccessRights[role] : undefined;
@@ -46,7 +49,7 @@ export function RolePermissionPopup({
<DialogHeader>
<DialogTitle className="flex items-center gap-2">
<Icon className="icon-base shrink-0" />
- <span>{def.name}</span>
+ <span>{transformName(def.name)}</span>
<Badge
variant="tertiary"
className="ml-1 shrink-0 text-[0.7rem] tabular-nums"
diff --git a/web/src/features/rbac/components/RoleSelectItem.tsx b/web/src/features/rbac/components/RoleSelectItem.tsx
index cf75874a14..9cdbee3033 100644
--- a/web/src/features/rbac/components/RoleSelectItem.tsx
+++ b/web/src/features/rbac/components/RoleSelectItem.tsx
@@ -9,14 +9,18 @@ import { roleIcons } from "@/src/features/rbac/components/roleIcons";
/** RoleSelectItem adds a permission preview to a role option. */
export const RoleSelectItem = ({
role,
+ transformName = (name) => name,
isProjectRole,
onViewPermissions,
}: {
role: SystemRole;
+ /** transformName rewrites the role name before it is shown. */
+ transformName?: (name: string) => string;
isProjectRole?: boolean;
onViewPermissions: (role: SystemRole) => void;
}) => {
const def = systemRoleAccessRights[role];
+ const label = transformName(def.name);
const Icon = roleIcons[role];
const keepDefaultNote = role === "NONE" && isProjectRole;
@@ -29,7 +33,7 @@ export const RoleSelectItem = ({
<Icon className="icon-base mt-0.5 shrink-0" />
<div className="flex flex-col">
<span className="font-bold">
- {def.name}
+ {label}
{keepDefaultNote ? " (keep default role)" : ""}
</span>
<span className="text-muted-foreground text-xs">
@@ -48,7 +52,7 @@ export const RoleSelectItem = ({
e.stopPropagation();
onViewPermissions(role);
}}
- aria-label={`View ${def.name} permissions`}
+ aria-label={`View ${label} permissions`}
className="text-muted-foreground hover:bg-background hover:text-foreground ml-auto flex h-6 w-6 shrink-0 items-center justify-center self-center rounded-full opacity-0 group-hover:opacity-100 group-data-highlighted:opacity-100 focus-visible:opacity-100"
>
<SquareArrowOutUpRight className="icon-base" />