fix(webui): explain disabled preset deletion

This commit is contained in:
Xubin Ren 2026-08-07 11:09:03 +08:00
parent 6f2512ce9a
commit 1b12fbae39
2 changed files with 32 additions and 19 deletions

View File

@ -3577,24 +3577,32 @@ function ModelsSettings({
{tx("settings.actions.cancel", "Cancel")} {tx("settings.actions.cancel", "Cancel")}
</Button> </Button>
) : selectedPreset ? ( ) : selectedPreset ? (
<Button <div className="flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1">
size="sm" <Button
variant="ghost" size="sm"
className="self-start rounded-full text-muted-foreground hover:text-destructive" variant="ghost"
disabled={selectedPresetOnlyActive || saving || orderSaving} className="rounded-full text-muted-foreground hover:text-destructive"
title={ disabled={selectedPresetOnlyActive || saving || orderSaving}
selectedPresetOnlyActive aria-describedby={
? tx( selectedPresetOnlyActive ? "model-preset-delete-hint" : undefined
"settings.models.removeBeforeDelete", }
"Remove this preset from the call order before deleting it.", onClick={() => onDeleteConfiguration(selectedPreset)}
) >
: undefined <Trash2 className="mr-1.5 h-3.5 w-3.5" aria-hidden />
} {tx("settings.actions.delete", "Delete")}
onClick={() => onDeleteConfiguration(selectedPreset)} </Button>
> {selectedPresetOnlyActive ? (
<Trash2 className="mr-1.5 h-3.5 w-3.5" aria-hidden /> <span
{tx("settings.actions.delete", "Delete")} id="model-preset-delete-hint"
</Button> className="text-[11px] leading-4 text-muted-foreground"
>
{tx(
"settings.models.removeBeforeDelete",
"Remove this preset from the call order before deleting it.",
)}
</span>
) : null}
</div>
) : null} ) : null}
<div className="flex items-center justify-end gap-3"> <div className="flex items-center justify-end gap-3">
<Button <Button

View File

@ -2169,7 +2169,12 @@ describe("SettingsView Apps catalog", () => {
expect(row.nextElementSibling).toBe(editor); expect(row.nextElementSibling).toBe(editor);
expect(editor).toHaveClass("slide-in-from-top-1", "bg-muted/10"); expect(editor).toHaveClass("slide-in-from-top-1", "bg-muted/10");
expect(within(editor).getByDisplayValue("Primary")).toBeInTheDocument(); expect(within(editor).getByDisplayValue("Primary")).toBeInTheDocument();
expect(within(editor).getByRole("button", { name: "Delete" })).toBeDisabled(); const deleteButton = within(editor).getByRole("button", { name: "Delete" });
expect(deleteButton).toBeDisabled();
expect(deleteButton).toHaveAttribute("aria-describedby", "model-preset-delete-hint");
expect(
within(editor).getByText("Remove this preset from the call order before deleting it."),
).toBeInTheDocument();
fireEvent.click(trigger); fireEvent.click(trigger);