mirror of
https://github.com/fosrl/pangolin.git
synced 2026-08-15 00:39:43 +02:00
improve budget editor component
This commit is contained in:
+5
-5
@@ -1099,7 +1099,7 @@
|
|||||||
"accessRoleErrorNewRequired": "New role is required",
|
"accessRoleErrorNewRequired": "New role is required",
|
||||||
"accessRoleErrorRemove": "Failed to remove role",
|
"accessRoleErrorRemove": "Failed to remove role",
|
||||||
"accessRoleErrorRemoveDescription": "An error occurred while removing the role.",
|
"accessRoleErrorRemoveDescription": "An error occurred while removing the role.",
|
||||||
"accessRoleInferenceBudget": "Inference Budget",
|
"accessRoleInferenceBudget": "AI Budget",
|
||||||
"accessRoleInferenceBudgetDescription": "Configure how members of this role restrict AI usage based on spending or token limits",
|
"accessRoleInferenceBudgetDescription": "Configure how members of this role restrict AI usage based on spending or token limits",
|
||||||
"accessRoleName": "Role Name",
|
"accessRoleName": "Role Name",
|
||||||
"accessRoleQuestionRemove": "You're about to delete the `{name}` role. You cannot undo this action.",
|
"accessRoleQuestionRemove": "You're about to delete the `{name}` role. You cannot undo this action.",
|
||||||
@@ -1720,7 +1720,7 @@
|
|||||||
"virtualApiKeysErrorFetchSecret": "Error loading secret",
|
"virtualApiKeysErrorFetchSecret": "Error loading secret",
|
||||||
"virtualApiKeysErrorFetchSecretDescription": "Failed to load the virtual API key secret",
|
"virtualApiKeysErrorFetchSecretDescription": "Failed to load the virtual API key secret",
|
||||||
"virtualApiKeysFilterUnassigned": "Unassigned",
|
"virtualApiKeysFilterUnassigned": "Unassigned",
|
||||||
"virtualApiKeysInferenceBudget": "Inference Budget",
|
"virtualApiKeysInferenceBudget": "Budget",
|
||||||
"virtualApiKeysInferenceBudgetDescription": "Configure how this key restricts AI usage based on spending or token limits",
|
"virtualApiKeysInferenceBudgetDescription": "Configure how this key restricts AI usage based on spending or token limits",
|
||||||
"myVirtualApiKeysTitle": "Your API Keys",
|
"myVirtualApiKeysTitle": "Your API Keys",
|
||||||
"myVirtualApiKeysDescription": "View your identity key and any virtual API keys attributed to you in this organization",
|
"myVirtualApiKeysDescription": "View your identity key and any virtual API keys attributed to you in this organization",
|
||||||
@@ -1924,10 +1924,10 @@
|
|||||||
"aiProviderModelsSourceAll": "Matches every model key",
|
"aiProviderModelsSourceAll": "Matches every model key",
|
||||||
"aiProviderModelsBudgetConfigured": "Budget configured",
|
"aiProviderModelsBudgetConfigured": "Budget configured",
|
||||||
"aiProviderModelsEditTitle": "Edit Model",
|
"aiProviderModelsEditTitle": "Edit Model",
|
||||||
"aiProviderModelsEditDescription": "Update the model key or configure its inference budget.",
|
"aiProviderModelsEditDescription": "Update the model key or configure its budget.",
|
||||||
"aiProviderModelsBudgetTab": "Inference Budget",
|
"aiProviderModelsBudgetTab": "Budget",
|
||||||
"aiProviderModelsBudgetDescription": "Configure how this model restricts usage based on spending or token limits",
|
"aiProviderModelsBudgetDescription": "Configure how this model restricts usage based on spending or token limits",
|
||||||
"aiProviderModelsBudgetUnsaved": "Save this model first to configure its inference budget.",
|
"aiProviderModelsBudgetUnsaved": "Save this model first to configure its budget.",
|
||||||
"aiProviderModelsKeyLabel": "Model Key",
|
"aiProviderModelsKeyLabel": "Model Key",
|
||||||
"aiProviderModelsKeyRequired": "Enter a model key",
|
"aiProviderModelsKeyRequired": "Enter a model key",
|
||||||
"aiProviderModelsKeyDuplicate": "This model key is already on a list",
|
"aiProviderModelsKeyDuplicate": "This model key is already on a list",
|
||||||
|
|||||||
@@ -964,8 +964,7 @@ function EditModelCredenza({
|
|||||||
rows={pendingBudgetRows}
|
rows={pendingBudgetRows}
|
||||||
onChange={setPendingBudgetRows}
|
onChange={setPendingBudgetRows}
|
||||||
disabled={
|
disabled={
|
||||||
budgetsQuery.isLoading ||
|
budgetsQuery.isLoading
|
||||||
savingBudgets
|
|
||||||
}
|
}
|
||||||
attemptedSave={
|
attemptedSave={
|
||||||
attemptedBudgetsSave
|
attemptedBudgetsSave
|
||||||
|
|||||||
+204
-155
@@ -1,6 +1,8 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
SettingsFormCell,
|
||||||
|
SettingsFormGrid,
|
||||||
SettingsSection,
|
SettingsSection,
|
||||||
SettingsSectionBody,
|
SettingsSectionBody,
|
||||||
SettingsSectionDescription,
|
SettingsSectionDescription,
|
||||||
@@ -9,7 +11,6 @@ import {
|
|||||||
SettingsSectionTitle
|
SettingsSectionTitle
|
||||||
} from "@app/components/Settings";
|
} from "@app/components/Settings";
|
||||||
import { Button } from "@app/components/ui/button";
|
import { Button } from "@app/components/ui/button";
|
||||||
import { DataTableEmptyState } from "@app/components/ui/data-table-empty-state";
|
|
||||||
import { Input } from "@app/components/ui/input";
|
import { Input } from "@app/components/ui/input";
|
||||||
import {
|
import {
|
||||||
Select,
|
Select,
|
||||||
@@ -18,14 +19,6 @@ import {
|
|||||||
SelectTrigger,
|
SelectTrigger,
|
||||||
SelectValue
|
SelectValue
|
||||||
} from "@app/components/ui/select";
|
} from "@app/components/ui/select";
|
||||||
import {
|
|
||||||
Table,
|
|
||||||
TableBody,
|
|
||||||
TableCell,
|
|
||||||
TableHead,
|
|
||||||
TableHeader,
|
|
||||||
TableRow
|
|
||||||
} from "@app/components/ui/table";
|
|
||||||
import { useEnvContext } from "@app/hooks/useEnvContext";
|
import { useEnvContext } from "@app/hooks/useEnvContext";
|
||||||
import { toast } from "@app/hooks/useToast";
|
import { toast } from "@app/hooks/useToast";
|
||||||
import { createApiClient, formatAxiosError } from "@app/lib/api";
|
import { createApiClient, formatAxiosError } from "@app/lib/api";
|
||||||
@@ -37,6 +30,7 @@ import {
|
|||||||
type AiBudgetScope,
|
type AiBudgetScope,
|
||||||
type AiBudgetUnit
|
type AiBudgetUnit
|
||||||
} from "@app/lib/aiBudgetScope";
|
} from "@app/lib/aiBudgetScope";
|
||||||
|
import { cn } from "@app/lib/cn";
|
||||||
import { aiBudgetQueries } from "@app/lib/queries";
|
import { aiBudgetQueries } from "@app/lib/queries";
|
||||||
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
||||||
import type { AiBudget } from "@server/db";
|
import type { AiBudget } from "@server/db";
|
||||||
@@ -127,6 +121,113 @@ export function getBudgetRowsErrors(rows: BudgetRow[]): {
|
|||||||
return { conflictingKeys, invalidAmountKeys };
|
return { conflictingKeys, invalidAmountKeys };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type BudgetRowFieldProps = {
|
||||||
|
row: BudgetRow;
|
||||||
|
disabled: boolean;
|
||||||
|
showInvalidAmount: boolean;
|
||||||
|
showConflict: boolean;
|
||||||
|
unitLabels: Record<AiBudgetUnit, string>;
|
||||||
|
periodLabels: Record<AiBudgetPeriod, string>;
|
||||||
|
amountPlaceholder: string;
|
||||||
|
onUpdate: (patch: Partial<BudgetRow>) => void;
|
||||||
|
};
|
||||||
|
|
||||||
|
function BudgetRowAmountInput({
|
||||||
|
row,
|
||||||
|
disabled,
|
||||||
|
showInvalidAmount,
|
||||||
|
amountPlaceholder,
|
||||||
|
onUpdate,
|
||||||
|
className
|
||||||
|
}: Pick<
|
||||||
|
BudgetRowFieldProps,
|
||||||
|
"row" | "disabled" | "showInvalidAmount" | "amountPlaceholder" | "onUpdate"
|
||||||
|
> & { className?: string }) {
|
||||||
|
return (
|
||||||
|
<Input
|
||||||
|
type="number"
|
||||||
|
min="0"
|
||||||
|
step="any"
|
||||||
|
placeholder={amountPlaceholder}
|
||||||
|
value={row.amount}
|
||||||
|
aria-invalid={showInvalidAmount}
|
||||||
|
disabled={disabled}
|
||||||
|
onChange={(e) => onUpdate({ amount: e.target.value })}
|
||||||
|
className={cn("w-full min-w-0", className)}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function BudgetRowUnitSelect({
|
||||||
|
row,
|
||||||
|
disabled,
|
||||||
|
showConflict,
|
||||||
|
unitLabels,
|
||||||
|
onUpdate,
|
||||||
|
className
|
||||||
|
}: Pick<
|
||||||
|
BudgetRowFieldProps,
|
||||||
|
"row" | "disabled" | "showConflict" | "unitLabels" | "onUpdate"
|
||||||
|
> & { className?: string }) {
|
||||||
|
return (
|
||||||
|
<Select
|
||||||
|
value={row.unit}
|
||||||
|
onValueChange={(value) => onUpdate({ unit: value as AiBudgetUnit })}
|
||||||
|
disabled={disabled}
|
||||||
|
>
|
||||||
|
<SelectTrigger
|
||||||
|
className={cn("w-full min-w-0", className)}
|
||||||
|
aria-invalid={showConflict}
|
||||||
|
>
|
||||||
|
<SelectValue />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
{AI_BUDGET_UNITS.map((unit) => (
|
||||||
|
<SelectItem key={unit} value={unit}>
|
||||||
|
{unitLabels[unit]}
|
||||||
|
</SelectItem>
|
||||||
|
))}
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function BudgetRowPeriodSelect({
|
||||||
|
row,
|
||||||
|
disabled,
|
||||||
|
showConflict,
|
||||||
|
periodLabels,
|
||||||
|
onUpdate,
|
||||||
|
className
|
||||||
|
}: Pick<
|
||||||
|
BudgetRowFieldProps,
|
||||||
|
"row" | "disabled" | "showConflict" | "periodLabels" | "onUpdate"
|
||||||
|
> & { className?: string }) {
|
||||||
|
return (
|
||||||
|
<Select
|
||||||
|
value={row.period}
|
||||||
|
onValueChange={(value) =>
|
||||||
|
onUpdate({ period: value as AiBudgetPeriod })
|
||||||
|
}
|
||||||
|
disabled={disabled}
|
||||||
|
>
|
||||||
|
<SelectTrigger
|
||||||
|
className={cn("w-full min-w-0", className)}
|
||||||
|
aria-invalid={showConflict}
|
||||||
|
>
|
||||||
|
<SelectValue />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
{AI_BUDGET_PERIODS.map((period) => (
|
||||||
|
<SelectItem key={period} value={period}>
|
||||||
|
{periodLabels[period]}
|
||||||
|
</SelectItem>
|
||||||
|
))}
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
export function BudgetRowsFields({
|
export function BudgetRowsFields({
|
||||||
rows,
|
rows,
|
||||||
onChange,
|
onChange,
|
||||||
@@ -173,6 +274,8 @@ export function BudgetRowsFields({
|
|||||||
tokens: t("aiBudgetUnitTokens")
|
tokens: t("aiBudgetUnitTokens")
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const amountPlaceholder = t("aiBudgetAmountPlaceholder");
|
||||||
|
|
||||||
const addRowButton = (
|
const addRowButton = (
|
||||||
<Button
|
<Button
|
||||||
type="button"
|
type="button"
|
||||||
@@ -185,148 +288,90 @@ export function BudgetRowsFields({
|
|||||||
</Button>
|
</Button>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const errorMessage =
|
||||||
|
conflictingKeys.size > 0 ||
|
||||||
|
(attemptedSave && invalidAmountKeys.size > 0) ? (
|
||||||
|
<p className="text-destructive text-sm">
|
||||||
|
{conflictingKeys.size > 0
|
||||||
|
? t("aiBudgetConflictError")
|
||||||
|
: t("aiBudgetInvalidAmountError")}
|
||||||
|
</p>
|
||||||
|
) : null;
|
||||||
|
|
||||||
|
function rowFieldProps(row: BudgetRow): BudgetRowFieldProps {
|
||||||
|
return {
|
||||||
|
row,
|
||||||
|
disabled,
|
||||||
|
showInvalidAmount: attemptedSave && invalidAmountKeys.has(row.key),
|
||||||
|
showConflict: conflictingKeys.has(row.key),
|
||||||
|
unitLabels,
|
||||||
|
periodLabels,
|
||||||
|
amountPlaceholder,
|
||||||
|
onUpdate: (patch) => updateRow(row.key, patch)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-4">
|
<div className="space-y-3">
|
||||||
<Table>
|
{rows.length === 0 ? (
|
||||||
<TableHeader>
|
<div className="space-y-3">
|
||||||
<TableRow>
|
<p className="text-sm text-muted-foreground">
|
||||||
<TableHead>{t("aiBudgetAmount")}</TableHead>
|
{t("aiBudgetEmpty")}
|
||||||
<TableHead>{t("aiBudgetUnit")}</TableHead>
|
</p>
|
||||||
<TableHead>{t("aiBudgetPeriod")}</TableHead>
|
{addRowButton}
|
||||||
<TableHead></TableHead>
|
</div>
|
||||||
</TableRow>
|
) : (
|
||||||
</TableHeader>
|
<div className="space-y-2">
|
||||||
<TableBody>
|
{rows.map((row) => {
|
||||||
{rows.length === 0 ? (
|
const fields = rowFieldProps(row);
|
||||||
<DataTableEmptyState
|
return (
|
||||||
colSpan={4}
|
<div
|
||||||
message={t("aiBudgetEmpty")}
|
key={row.key}
|
||||||
action={addRowButton}
|
className="flex items-center gap-2"
|
||||||
compact
|
>
|
||||||
/>
|
<div
|
||||||
) : (
|
className={cn(
|
||||||
rows.map((row) => {
|
"flex h-9 min-w-0 flex-1 overflow-hidden rounded-md border border-input",
|
||||||
const showConflict = conflictingKeys.has(row.key);
|
"focus-within:border-ring",
|
||||||
const showInvalidAmount =
|
(fields.showInvalidAmount ||
|
||||||
attemptedSave &&
|
fields.showConflict) &&
|
||||||
invalidAmountKeys.has(row.key);
|
"border-destructive"
|
||||||
return (
|
)}
|
||||||
<TableRow key={row.key}>
|
>
|
||||||
<TableCell>
|
<BudgetRowUnitSelect
|
||||||
<Input
|
{...fields}
|
||||||
type="number"
|
className="h-full w-28 min-w-28 shrink-0 rounded-none border-0 px-2 shadow-none focus-visible:ring-0"
|
||||||
min="0"
|
/>
|
||||||
step="any"
|
<div
|
||||||
placeholder={t(
|
className="w-px shrink-0 bg-border"
|
||||||
"aiBudgetAmountPlaceholder"
|
aria-hidden
|
||||||
)}
|
/>
|
||||||
value={row.amount}
|
<BudgetRowAmountInput
|
||||||
aria-invalid={showInvalidAmount}
|
{...fields}
|
||||||
disabled={disabled}
|
className="h-full min-w-0 flex-1 rounded-none border-0 text-sm shadow-none focus-visible:border-transparent focus-visible:ring-0"
|
||||||
onChange={(e) =>
|
/>
|
||||||
updateRow(row.key, {
|
</div>
|
||||||
amount: e.target.value
|
<BudgetRowPeriodSelect
|
||||||
})
|
{...fields}
|
||||||
}
|
className="h-9 w-32 min-w-32 shrink-0"
|
||||||
className="w-full min-w-0"
|
/>
|
||||||
/>
|
<Button
|
||||||
</TableCell>
|
type="button"
|
||||||
<TableCell>
|
variant="ghost"
|
||||||
<Select
|
size="icon"
|
||||||
value={row.unit}
|
className="shrink-0"
|
||||||
onValueChange={(value) =>
|
disabled={disabled}
|
||||||
updateRow(row.key, {
|
onClick={() => removeRow(row.key)}
|
||||||
unit: value as AiBudgetUnit
|
aria-label={t("delete")}
|
||||||
})
|
>
|
||||||
}
|
<Trash2 className="h-4 w-4" />
|
||||||
disabled={disabled}
|
</Button>
|
||||||
>
|
</div>
|
||||||
<SelectTrigger
|
);
|
||||||
className="w-full min-w-0"
|
})}
|
||||||
aria-invalid={showConflict}
|
</div>
|
||||||
>
|
|
||||||
<SelectValue />
|
|
||||||
</SelectTrigger>
|
|
||||||
<SelectContent>
|
|
||||||
{AI_BUDGET_UNITS.map(
|
|
||||||
(unit) => (
|
|
||||||
<SelectItem
|
|
||||||
key={unit}
|
|
||||||
value={unit}
|
|
||||||
>
|
|
||||||
{
|
|
||||||
unitLabels[
|
|
||||||
unit
|
|
||||||
]
|
|
||||||
}
|
|
||||||
</SelectItem>
|
|
||||||
)
|
|
||||||
)}
|
|
||||||
</SelectContent>
|
|
||||||
</Select>
|
|
||||||
</TableCell>
|
|
||||||
<TableCell>
|
|
||||||
<Select
|
|
||||||
value={row.period}
|
|
||||||
onValueChange={(value) =>
|
|
||||||
updateRow(row.key, {
|
|
||||||
period: value as AiBudgetPeriod
|
|
||||||
})
|
|
||||||
}
|
|
||||||
disabled={disabled}
|
|
||||||
>
|
|
||||||
<SelectTrigger
|
|
||||||
className="w-full min-w-0"
|
|
||||||
aria-invalid={showConflict}
|
|
||||||
>
|
|
||||||
<SelectValue />
|
|
||||||
</SelectTrigger>
|
|
||||||
<SelectContent>
|
|
||||||
{AI_BUDGET_PERIODS.map(
|
|
||||||
(period) => (
|
|
||||||
<SelectItem
|
|
||||||
key={period}
|
|
||||||
value={period}
|
|
||||||
>
|
|
||||||
{
|
|
||||||
periodLabels[
|
|
||||||
period
|
|
||||||
]
|
|
||||||
}
|
|
||||||
</SelectItem>
|
|
||||||
)
|
|
||||||
)}
|
|
||||||
</SelectContent>
|
|
||||||
</Select>
|
|
||||||
</TableCell>
|
|
||||||
<TableCell>
|
|
||||||
<div className="flex items-center justify-end space-x-2">
|
|
||||||
<Button
|
|
||||||
type="button"
|
|
||||||
variant="outline"
|
|
||||||
disabled={disabled}
|
|
||||||
onClick={() =>
|
|
||||||
removeRow(row.key)
|
|
||||||
}
|
|
||||||
>
|
|
||||||
Delete
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</TableCell>
|
|
||||||
</TableRow>
|
|
||||||
);
|
|
||||||
})
|
|
||||||
)}
|
|
||||||
</TableBody>
|
|
||||||
</Table>
|
|
||||||
{(conflictingKeys.size > 0 ||
|
|
||||||
(attemptedSave && invalidAmountKeys.size > 0)) && (
|
|
||||||
<p className="text-xs text-destructive">
|
|
||||||
{conflictingKeys.size > 0
|
|
||||||
? t("aiBudgetConflictError")
|
|
||||||
: t("aiBudgetInvalidAmountError")}
|
|
||||||
</p>
|
|
||||||
)}
|
)}
|
||||||
|
{errorMessage}
|
||||||
{rows.length > 0 && addRowButton}
|
{rows.length > 0 && addRowButton}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@@ -474,12 +519,16 @@ export function BudgetsEditor({
|
|||||||
const body = (
|
const body = (
|
||||||
<>
|
<>
|
||||||
<SettingsSectionBody>
|
<SettingsSectionBody>
|
||||||
<BudgetRowsFields
|
<SettingsFormGrid>
|
||||||
rows={rows}
|
<SettingsFormCell span="half">
|
||||||
onChange={setRows}
|
<BudgetRowsFields
|
||||||
disabled={saveLoading || budgetsQuery.isLoading}
|
rows={rows}
|
||||||
attemptedSave={attemptedSave}
|
onChange={setRows}
|
||||||
/>
|
disabled={budgetsQuery.isLoading}
|
||||||
|
attemptedSave={attemptedSave}
|
||||||
|
/>
|
||||||
|
</SettingsFormCell>
|
||||||
|
</SettingsFormGrid>
|
||||||
</SettingsSectionBody>
|
</SettingsSectionBody>
|
||||||
|
|
||||||
<SettingsSectionFooter>
|
<SettingsSectionFooter>
|
||||||
|
|||||||
@@ -99,9 +99,7 @@ export default function CreateVirtualApiKeyForm({
|
|||||||
const [selectedResources, setSelectedResources] = useState<
|
const [selectedResources, setSelectedResources] = useState<
|
||||||
SelectedResource[]
|
SelectedResource[]
|
||||||
>([]);
|
>([]);
|
||||||
const [pendingBudgetRows, setPendingBudgetRows] = useState<BudgetRow[]>(
|
const [pendingBudgetRows, setPendingBudgetRows] = useState<BudgetRow[]>([]);
|
||||||
[]
|
|
||||||
);
|
|
||||||
const [attemptedBudgetsSave, setAttemptedBudgetsSave] = useState(false);
|
const [attemptedBudgetsSave, setAttemptedBudgetsSave] = useState(false);
|
||||||
|
|
||||||
const formSchema = z.object({
|
const formSchema = z.object({
|
||||||
@@ -204,10 +202,7 @@ export default function CreateVirtualApiKeyForm({
|
|||||||
toast({
|
toast({
|
||||||
variant: "destructive",
|
variant: "destructive",
|
||||||
title: t("aiBudgetErrorSave"),
|
title: t("aiBudgetErrorSave"),
|
||||||
description: formatAxiosError(
|
description: formatAxiosError(e, t("aiBudgetErrorSave"))
|
||||||
e,
|
|
||||||
t("aiBudgetErrorSave")
|
|
||||||
)
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -295,120 +290,47 @@ export default function CreateVirtualApiKeyForm({
|
|||||||
}
|
}
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<div className="space-y-4 mt-4">
|
<div className="space-y-4 mt-4">
|
||||||
<FormField
|
<FormField
|
||||||
control={form.control}
|
control={form.control}
|
||||||
name="name"
|
name="name"
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<FormItem>
|
<FormItem>
|
||||||
<FormLabel>
|
<FormLabel>
|
||||||
{t("virtualApiKeysName")}
|
{t(
|
||||||
</FormLabel>
|
"virtualApiKeysName"
|
||||||
<FormControl>
|
)}
|
||||||
<Input {...field} />
|
</FormLabel>
|
||||||
</FormControl>
|
<FormControl>
|
||||||
<FormMessage />
|
<Input {...field} />
|
||||||
</FormItem>
|
</FormControl>
|
||||||
)}
|
<FormMessage />
|
||||||
/>
|
</FormItem>
|
||||||
|
)}
|
||||||
<FormField
|
/>
|
||||||
control={form.control}
|
|
||||||
name="description"
|
<FormField
|
||||||
render={({ field }) => (
|
control={form.control}
|
||||||
<FormItem>
|
name="description"
|
||||||
<FormLabel>
|
render={({ field }) => (
|
||||||
{t(
|
<FormItem>
|
||||||
"virtualApiKeysDescriptionOptional"
|
<FormLabel>
|
||||||
)}
|
{t(
|
||||||
</FormLabel>
|
"virtualApiKeysDescriptionOptional"
|
||||||
<FormControl>
|
)}
|
||||||
<Input {...field} />
|
</FormLabel>
|
||||||
</FormControl>
|
<FormControl>
|
||||||
<FormMessage />
|
<Input {...field} />
|
||||||
</FormItem>
|
</FormControl>
|
||||||
)}
|
<FormMessage />
|
||||||
/>
|
</FormItem>
|
||||||
|
)}
|
||||||
<div className="space-y-2">
|
|
||||||
<FormLabel>
|
|
||||||
{t(
|
|
||||||
"virtualApiKeysAssociateUserOptional"
|
|
||||||
)}
|
|
||||||
</FormLabel>
|
|
||||||
<Popover>
|
|
||||||
<PopoverTrigger asChild>
|
|
||||||
<Button
|
|
||||||
variant="outline"
|
|
||||||
role="combobox"
|
|
||||||
className={cn(
|
|
||||||
"w-full justify-between",
|
|
||||||
!selectedUser &&
|
|
||||||
"text-muted-foreground"
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
{selectedUser?.text
|
|
||||||
? selectedUser.text
|
|
||||||
: t("userSelect")}
|
|
||||||
<CaretSortIcon className="ml-2 h-4 w-4 shrink-0 opacity-50" />
|
|
||||||
</Button>
|
|
||||||
</PopoverTrigger>
|
|
||||||
<PopoverContent className="p-0 w-[var(--radix-popover-trigger-width)]">
|
|
||||||
<UserSelector
|
|
||||||
orgId={org.org.orgId}
|
|
||||||
selectedUser={selectedUser}
|
|
||||||
onSelectUser={
|
|
||||||
setSelectedUser
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
</PopoverContent>
|
|
||||||
</Popover>
|
|
||||||
<p className="text-sm text-muted-foreground">
|
|
||||||
{t(
|
|
||||||
"virtualApiKeysAssociateUserDescription"
|
|
||||||
)}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="space-y-3">
|
|
||||||
<div className="flex items-start space-x-2">
|
|
||||||
<Checkbox
|
|
||||||
id="all-resources"
|
|
||||||
checked={allResources}
|
|
||||||
onCheckedChange={(val) => {
|
|
||||||
setAllResources(
|
|
||||||
val as boolean
|
|
||||||
);
|
|
||||||
if (val) {
|
|
||||||
setSelectedResources(
|
|
||||||
[]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
className="mt-0.5"
|
|
||||||
/>
|
/>
|
||||||
<div className="space-y-1">
|
|
||||||
<label
|
|
||||||
htmlFor="all-resources"
|
|
||||||
className="text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
|
|
||||||
>
|
|
||||||
{t(
|
|
||||||
"virtualApiKeysAllResources"
|
|
||||||
)}
|
|
||||||
</label>
|
|
||||||
<p className="text-sm text-muted-foreground">
|
|
||||||
{t(
|
|
||||||
"virtualApiKeysAllResourcesDescription"
|
|
||||||
)}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{!allResources && (
|
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
<FormLabel>
|
<FormLabel>
|
||||||
{t(
|
{t(
|
||||||
"virtualApiKeysSelectResources"
|
"virtualApiKeysAssociateUserOptional"
|
||||||
)}
|
)}
|
||||||
</FormLabel>
|
</FormLabel>
|
||||||
<Popover>
|
<Popover>
|
||||||
@@ -418,69 +340,155 @@ export default function CreateVirtualApiKeyForm({
|
|||||||
role="combobox"
|
role="combobox"
|
||||||
className={cn(
|
className={cn(
|
||||||
"w-full justify-between",
|
"w-full justify-between",
|
||||||
selectedResources.length ===
|
!selectedUser &&
|
||||||
0 &&
|
|
||||||
"text-muted-foreground"
|
"text-muted-foreground"
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<span className="truncate text-left">
|
{selectedUser?.text
|
||||||
{formatMultiResourcesSelectorLabel(
|
? selectedUser.text
|
||||||
selectedResources,
|
: t(
|
||||||
t,
|
"userSelect"
|
||||||
"virtualApiKeysSelectResourcesPlaceholder"
|
)}
|
||||||
)}
|
|
||||||
</span>
|
|
||||||
<CaretSortIcon className="ml-2 h-4 w-4 shrink-0 opacity-50" />
|
<CaretSortIcon className="ml-2 h-4 w-4 shrink-0 opacity-50" />
|
||||||
</Button>
|
</Button>
|
||||||
</PopoverTrigger>
|
</PopoverTrigger>
|
||||||
<PopoverContent className="w-[var(--radix-popover-trigger-width)] p-0">
|
<PopoverContent className="p-0 w-[var(--radix-popover-trigger-width)]">
|
||||||
<MultiResourcesSelector
|
<UserSelector
|
||||||
orgId={
|
orgId={
|
||||||
org.org.orgId
|
org.org.orgId
|
||||||
}
|
}
|
||||||
selectedResources={
|
selectedUser={
|
||||||
selectedResources
|
selectedUser
|
||||||
}
|
}
|
||||||
onSelectionChange={
|
onSelectUser={
|
||||||
setSelectedResources
|
setSelectedUser
|
||||||
}
|
|
||||||
protocol="inference"
|
|
||||||
showClear={
|
|
||||||
selectedResources.length >
|
|
||||||
0
|
|
||||||
}
|
|
||||||
onClear={() =>
|
|
||||||
setSelectedResources(
|
|
||||||
[]
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
</PopoverContent>
|
</PopoverContent>
|
||||||
</Popover>
|
</Popover>
|
||||||
<FormDescription>
|
<p className="text-sm text-muted-foreground">
|
||||||
{t(
|
{t(
|
||||||
"virtualApiKeysSelectResourcesDescription"
|
"virtualApiKeysAssociateUserDescription"
|
||||||
)}
|
)}
|
||||||
</FormDescription>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="space-y-4 mt-4">
|
<div className="space-y-3">
|
||||||
<p className="text-sm text-muted-foreground">
|
<div className="flex items-start space-x-2">
|
||||||
{t(
|
<Checkbox
|
||||||
"virtualApiKeysInferenceBudgetDescription"
|
id="all-resources"
|
||||||
)}
|
checked={allResources}
|
||||||
</p>
|
onCheckedChange={(
|
||||||
<BudgetRowsFields
|
val
|
||||||
rows={pendingBudgetRows}
|
) => {
|
||||||
onChange={setPendingBudgetRows}
|
setAllResources(
|
||||||
attemptedSave={
|
val as boolean
|
||||||
attemptedBudgetsSave
|
);
|
||||||
}
|
if (val) {
|
||||||
/>
|
setSelectedResources(
|
||||||
</div>
|
[]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
className="mt-0.5"
|
||||||
|
/>
|
||||||
|
<div className="space-y-1">
|
||||||
|
<label
|
||||||
|
htmlFor="all-resources"
|
||||||
|
className="text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
|
||||||
|
>
|
||||||
|
{t(
|
||||||
|
"virtualApiKeysAllResources"
|
||||||
|
)}
|
||||||
|
</label>
|
||||||
|
<p className="text-sm text-muted-foreground">
|
||||||
|
{t(
|
||||||
|
"virtualApiKeysAllResourcesDescription"
|
||||||
|
)}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{!allResources && (
|
||||||
|
<div className="space-y-2">
|
||||||
|
<FormLabel>
|
||||||
|
{t(
|
||||||
|
"virtualApiKeysSelectResources"
|
||||||
|
)}
|
||||||
|
</FormLabel>
|
||||||
|
<Popover>
|
||||||
|
<PopoverTrigger
|
||||||
|
asChild
|
||||||
|
>
|
||||||
|
<Button
|
||||||
|
variant="outline"
|
||||||
|
role="combobox"
|
||||||
|
className={cn(
|
||||||
|
"w-full justify-between",
|
||||||
|
selectedResources.length ===
|
||||||
|
0 &&
|
||||||
|
"text-muted-foreground"
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<span className="truncate text-left">
|
||||||
|
{formatMultiResourcesSelectorLabel(
|
||||||
|
selectedResources,
|
||||||
|
t,
|
||||||
|
"virtualApiKeysSelectResourcesPlaceholder"
|
||||||
|
)}
|
||||||
|
</span>
|
||||||
|
<CaretSortIcon className="ml-2 h-4 w-4 shrink-0 opacity-50" />
|
||||||
|
</Button>
|
||||||
|
</PopoverTrigger>
|
||||||
|
<PopoverContent className="w-[var(--radix-popover-trigger-width)] p-0">
|
||||||
|
<MultiResourcesSelector
|
||||||
|
orgId={
|
||||||
|
org.org
|
||||||
|
.orgId
|
||||||
|
}
|
||||||
|
selectedResources={
|
||||||
|
selectedResources
|
||||||
|
}
|
||||||
|
onSelectionChange={
|
||||||
|
setSelectedResources
|
||||||
|
}
|
||||||
|
protocol="inference"
|
||||||
|
showClear={
|
||||||
|
selectedResources.length >
|
||||||
|
0
|
||||||
|
}
|
||||||
|
onClear={() =>
|
||||||
|
setSelectedResources(
|
||||||
|
[]
|
||||||
|
)
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</PopoverContent>
|
||||||
|
</Popover>
|
||||||
|
<FormDescription>
|
||||||
|
{t(
|
||||||
|
"virtualApiKeysSelectResourcesDescription"
|
||||||
|
)}
|
||||||
|
</FormDescription>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="space-y-4 mt-4">
|
||||||
|
<p className="text-sm text-muted-foreground">
|
||||||
|
{t(
|
||||||
|
"virtualApiKeysInferenceBudgetDescription"
|
||||||
|
)}
|
||||||
|
</p>
|
||||||
|
<BudgetRowsFields
|
||||||
|
rows={pendingBudgetRows}
|
||||||
|
onChange={setPendingBudgetRows}
|
||||||
|
attemptedSave={
|
||||||
|
attemptedBudgetsSave
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
</HorizontalTabs>
|
</HorizontalTabs>
|
||||||
</form>
|
</form>
|
||||||
</Form>
|
</Form>
|
||||||
|
|||||||
@@ -112,9 +112,7 @@ export default function EditVirtualApiKeyForm({
|
|||||||
>([]);
|
>([]);
|
||||||
const [credential, setCredential] = useState<string | null>(null);
|
const [credential, setCredential] = useState<string | null>(null);
|
||||||
const [credentialLoading, setCredentialLoading] = useState(false);
|
const [credentialLoading, setCredentialLoading] = useState(false);
|
||||||
const [pendingBudgetRows, setPendingBudgetRows] = useState<BudgetRow[]>(
|
const [pendingBudgetRows, setPendingBudgetRows] = useState<BudgetRow[]>([]);
|
||||||
[]
|
|
||||||
);
|
|
||||||
const [attemptedBudgetsSave, setAttemptedBudgetsSave] = useState(false);
|
const [attemptedBudgetsSave, setAttemptedBudgetsSave] = useState(false);
|
||||||
|
|
||||||
const budgetScope = {
|
const budgetScope = {
|
||||||
@@ -350,9 +348,7 @@ export default function EditVirtualApiKeyForm({
|
|||||||
<div className="flex flex-col gap-y-4 px-1">
|
<div className="flex flex-col gap-y-4 px-1">
|
||||||
<Form {...form}>
|
<Form {...form}>
|
||||||
<form
|
<form
|
||||||
onSubmit={form.handleSubmit(
|
onSubmit={form.handleSubmit(handleFormSubmit)}
|
||||||
handleFormSubmit
|
|
||||||
)}
|
|
||||||
className="space-y-4"
|
className="space-y-4"
|
||||||
id="edit-virtual-api-key-form"
|
id="edit-virtual-api-key-form"
|
||||||
>
|
>
|
||||||
@@ -369,99 +365,11 @@ export default function EditVirtualApiKeyForm({
|
|||||||
}
|
}
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<div className="space-y-4 mt-4">
|
<div className="space-y-4 mt-4">
|
||||||
<div className="space-y-2">
|
|
||||||
<Label>
|
|
||||||
{t(
|
|
||||||
"virtualApiKeysAssociateUserOptional"
|
|
||||||
)}
|
|
||||||
</Label>
|
|
||||||
<Popover>
|
|
||||||
<PopoverTrigger asChild>
|
|
||||||
<Button
|
|
||||||
variant="outline"
|
|
||||||
role="combobox"
|
|
||||||
className={cn(
|
|
||||||
"w-full justify-between",
|
|
||||||
!selectedUser &&
|
|
||||||
"text-muted-foreground"
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
{selectedUser?.text
|
|
||||||
? selectedUser.text
|
|
||||||
: t("userSelect")}
|
|
||||||
<CaretSortIcon className="ml-2 h-4 w-4 shrink-0 opacity-50" />
|
|
||||||
</Button>
|
|
||||||
</PopoverTrigger>
|
|
||||||
<PopoverContent className="p-0 w-[var(--radix-popover-trigger-width)]">
|
|
||||||
<UserSelector
|
|
||||||
orgId={org.org.orgId}
|
|
||||||
selectedUser={selectedUser}
|
|
||||||
onSelectUser={setSelectedUser}
|
|
||||||
/>
|
|
||||||
</PopoverContent>
|
|
||||||
</Popover>
|
|
||||||
<p className="text-sm text-muted-foreground">
|
|
||||||
{t(
|
|
||||||
"virtualApiKeysAssociateUserDescription"
|
|
||||||
)}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="space-y-3">
|
|
||||||
<FormField
|
|
||||||
control={form.control}
|
|
||||||
name="allResources"
|
|
||||||
render={({ field }) => (
|
|
||||||
<FormItem>
|
|
||||||
<div className="flex items-start space-x-2">
|
|
||||||
<FormControl>
|
|
||||||
<Checkbox
|
|
||||||
id="edit-all-resources"
|
|
||||||
checked={
|
|
||||||
field.value
|
|
||||||
}
|
|
||||||
onCheckedChange={(
|
|
||||||
val
|
|
||||||
) => {
|
|
||||||
field.onChange(
|
|
||||||
val as boolean
|
|
||||||
);
|
|
||||||
if (val) {
|
|
||||||
setSelectedResources(
|
|
||||||
[]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
className="mt-0.5"
|
|
||||||
/>
|
|
||||||
</FormControl>
|
|
||||||
<div className="space-y-1">
|
|
||||||
<label
|
|
||||||
htmlFor="edit-all-resources"
|
|
||||||
className="text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
|
|
||||||
>
|
|
||||||
{t(
|
|
||||||
"virtualApiKeysAllResources"
|
|
||||||
)}
|
|
||||||
</label>
|
|
||||||
<p className="text-sm text-muted-foreground">
|
|
||||||
{t(
|
|
||||||
"virtualApiKeysAllResourcesDescription"
|
|
||||||
)}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<FormMessage />
|
|
||||||
</FormItem>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
|
|
||||||
{!allResources && (
|
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
<Label>
|
<Label>
|
||||||
{t(
|
{t(
|
||||||
"virtualApiKeysSelectResources"
|
"virtualApiKeysAssociateUserOptional"
|
||||||
)}
|
)}
|
||||||
</Label>
|
</Label>
|
||||||
<Popover>
|
<Popover>
|
||||||
@@ -471,66 +379,163 @@ export default function EditVirtualApiKeyForm({
|
|||||||
role="combobox"
|
role="combobox"
|
||||||
className={cn(
|
className={cn(
|
||||||
"w-full justify-between",
|
"w-full justify-between",
|
||||||
selectedResources.length ===
|
!selectedUser &&
|
||||||
0 &&
|
|
||||||
"text-muted-foreground"
|
"text-muted-foreground"
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<span className="truncate text-left">
|
{selectedUser?.text
|
||||||
{formatMultiResourcesSelectorLabel(
|
? selectedUser.text
|
||||||
selectedResources,
|
: t("userSelect")}
|
||||||
t,
|
|
||||||
"virtualApiKeysSelectResourcesPlaceholder"
|
|
||||||
)}
|
|
||||||
</span>
|
|
||||||
<CaretSortIcon className="ml-2 h-4 w-4 shrink-0 opacity-50" />
|
<CaretSortIcon className="ml-2 h-4 w-4 shrink-0 opacity-50" />
|
||||||
</Button>
|
</Button>
|
||||||
</PopoverTrigger>
|
</PopoverTrigger>
|
||||||
<PopoverContent className="w-[var(--radix-popover-trigger-width)] p-0">
|
<PopoverContent className="p-0 w-[var(--radix-popover-trigger-width)]">
|
||||||
<MultiResourcesSelector
|
<UserSelector
|
||||||
orgId={org.org.orgId}
|
orgId={org.org.orgId}
|
||||||
selectedResources={
|
selectedUser={
|
||||||
selectedResources
|
selectedUser
|
||||||
}
|
}
|
||||||
onSelectionChange={
|
onSelectUser={
|
||||||
setSelectedResources
|
setSelectedUser
|
||||||
}
|
|
||||||
protocol="inference"
|
|
||||||
showClear={
|
|
||||||
selectedResources.length >
|
|
||||||
0
|
|
||||||
}
|
|
||||||
onClear={() =>
|
|
||||||
setSelectedResources(
|
|
||||||
[]
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
</PopoverContent>
|
</PopoverContent>
|
||||||
</Popover>
|
</Popover>
|
||||||
<FormDescription>
|
<p className="text-sm text-muted-foreground">
|
||||||
{t(
|
{t(
|
||||||
"virtualApiKeysSelectResourcesRequired"
|
"virtualApiKeysAssociateUserDescription"
|
||||||
)}
|
)}
|
||||||
</FormDescription>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="space-y-4 mt-4">
|
<div className="space-y-3">
|
||||||
<p className="text-sm text-muted-foreground">
|
<FormField
|
||||||
{t(
|
control={form.control}
|
||||||
"virtualApiKeysInferenceBudgetDescription"
|
name="allResources"
|
||||||
)}
|
render={({ field }) => (
|
||||||
</p>
|
<FormItem>
|
||||||
<BudgetRowsFields
|
<div className="flex items-start space-x-2">
|
||||||
rows={pendingBudgetRows}
|
<FormControl>
|
||||||
onChange={setPendingBudgetRows}
|
<Checkbox
|
||||||
disabled={budgetsQuery.isLoading}
|
id="edit-all-resources"
|
||||||
attemptedSave={attemptedBudgetsSave}
|
checked={
|
||||||
/>
|
field.value
|
||||||
</div>
|
}
|
||||||
|
onCheckedChange={(
|
||||||
|
val
|
||||||
|
) => {
|
||||||
|
field.onChange(
|
||||||
|
val as boolean
|
||||||
|
);
|
||||||
|
if (
|
||||||
|
val
|
||||||
|
) {
|
||||||
|
setSelectedResources(
|
||||||
|
[]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
className="mt-0.5"
|
||||||
|
/>
|
||||||
|
</FormControl>
|
||||||
|
<div className="space-y-1">
|
||||||
|
<label
|
||||||
|
htmlFor="edit-all-resources"
|
||||||
|
className="text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
|
||||||
|
>
|
||||||
|
{t(
|
||||||
|
"virtualApiKeysAllResources"
|
||||||
|
)}
|
||||||
|
</label>
|
||||||
|
<p className="text-sm text-muted-foreground">
|
||||||
|
{t(
|
||||||
|
"virtualApiKeysAllResourcesDescription"
|
||||||
|
)}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
|
||||||
|
{!allResources && (
|
||||||
|
<div className="space-y-2">
|
||||||
|
<Label>
|
||||||
|
{t(
|
||||||
|
"virtualApiKeysSelectResources"
|
||||||
|
)}
|
||||||
|
</Label>
|
||||||
|
<Popover>
|
||||||
|
<PopoverTrigger asChild>
|
||||||
|
<Button
|
||||||
|
variant="outline"
|
||||||
|
role="combobox"
|
||||||
|
className={cn(
|
||||||
|
"w-full justify-between",
|
||||||
|
selectedResources.length ===
|
||||||
|
0 &&
|
||||||
|
"text-muted-foreground"
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<span className="truncate text-left">
|
||||||
|
{formatMultiResourcesSelectorLabel(
|
||||||
|
selectedResources,
|
||||||
|
t,
|
||||||
|
"virtualApiKeysSelectResourcesPlaceholder"
|
||||||
|
)}
|
||||||
|
</span>
|
||||||
|
<CaretSortIcon className="ml-2 h-4 w-4 shrink-0 opacity-50" />
|
||||||
|
</Button>
|
||||||
|
</PopoverTrigger>
|
||||||
|
<PopoverContent className="w-[var(--radix-popover-trigger-width)] p-0">
|
||||||
|
<MultiResourcesSelector
|
||||||
|
orgId={
|
||||||
|
org.org
|
||||||
|
.orgId
|
||||||
|
}
|
||||||
|
selectedResources={
|
||||||
|
selectedResources
|
||||||
|
}
|
||||||
|
onSelectionChange={
|
||||||
|
setSelectedResources
|
||||||
|
}
|
||||||
|
protocol="inference"
|
||||||
|
showClear={
|
||||||
|
selectedResources.length >
|
||||||
|
0
|
||||||
|
}
|
||||||
|
onClear={() =>
|
||||||
|
setSelectedResources(
|
||||||
|
[]
|
||||||
|
)
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</PopoverContent>
|
||||||
|
</Popover>
|
||||||
|
<FormDescription>
|
||||||
|
{t(
|
||||||
|
"virtualApiKeysSelectResourcesRequired"
|
||||||
|
)}
|
||||||
|
</FormDescription>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="space-y-4 mt-4">
|
||||||
|
<p className="text-sm text-muted-foreground">
|
||||||
|
{t(
|
||||||
|
"virtualApiKeysInferenceBudgetDescription"
|
||||||
|
)}
|
||||||
|
</p>
|
||||||
|
<BudgetRowsFields
|
||||||
|
rows={pendingBudgetRows}
|
||||||
|
onChange={setPendingBudgetRows}
|
||||||
|
disabled={budgetsQuery.isLoading}
|
||||||
|
attemptedSave={attemptedBudgetsSave}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
</HorizontalTabs>
|
</HorizontalTabs>
|
||||||
</form>
|
</form>
|
||||||
</Form>
|
</Form>
|
||||||
|
|||||||
@@ -219,9 +219,7 @@ export function RoleForm({
|
|||||||
useState<PendingTextImport | null>(null);
|
useState<PendingTextImport | null>(null);
|
||||||
const [dragOverField, setDragOverField] =
|
const [dragOverField, setDragOverField] =
|
||||||
useState<RoleTextImportField | null>(null);
|
useState<RoleTextImportField | null>(null);
|
||||||
const [pendingBudgetRows, setPendingBudgetRows] = useState<BudgetRow[]>(
|
const [pendingBudgetRows, setPendingBudgetRows] = useState<BudgetRow[]>([]);
|
||||||
[]
|
|
||||||
);
|
|
||||||
const [attemptedBudgetsSave, setAttemptedBudgetsSave] = useState(false);
|
const [attemptedBudgetsSave, setAttemptedBudgetsSave] = useState(false);
|
||||||
|
|
||||||
const budgetsQuery = useQuery({
|
const budgetsQuery = useQuery({
|
||||||
@@ -702,7 +700,6 @@ export function RoleForm({
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* Inference Budget tab */}
|
|
||||||
<div className="space-y-4 mt-4">
|
<div className="space-y-4 mt-4">
|
||||||
<p className="text-sm text-muted-foreground">
|
<p className="text-sm text-muted-foreground">
|
||||||
{t("accessRoleInferenceBudgetDescription")}
|
{t("accessRoleInferenceBudgetDescription")}
|
||||||
@@ -711,8 +708,7 @@ export function RoleForm({
|
|||||||
rows={pendingBudgetRows}
|
rows={pendingBudgetRows}
|
||||||
onChange={setPendingBudgetRows}
|
onChange={setPendingBudgetRows}
|
||||||
disabled={
|
disabled={
|
||||||
variant === "edit" &&
|
variant === "edit" && budgetsQuery.isLoading
|
||||||
budgetsQuery.isLoading
|
|
||||||
}
|
}
|
||||||
attemptedSave={attemptedBudgetsSave}
|
attemptedSave={attemptedBudgetsSave}
|
||||||
/>
|
/>
|
||||||
|
|||||||
Reference in New Issue
Block a user