Skip to content
TypeScript

feat(web): Add provider button sits with the provider list (#17152)

Theo Browne5e2225671f70
diff --git a/apps/web/src/components/settings/ProviderSettingsPanel.tsx b/apps/web/src/components/settings/ProviderSettingsPanel.tsx
index 6f46870ed76..c56e5e0b5fc 100644
--- a/apps/web/src/components/settings/ProviderSettingsPanel.tsx
+++ b/apps/web/src/components/settings/ProviderSettingsPanel.tsx
@@ -1154,6 +1154,25 @@ export function EnvironmentProviderSettings({
<SettingsSection
{...searchableSetting("providers")}
variant="plain"
+ titleAction={
+ !readOnly ? (
+ <Tooltip>
+ <TooltipTrigger
+ render={
+ <Button
+ size="icon-xs"
+ variant="ghost-muted"
+ onClick={() => setIsAddInstanceDialogOpen(true)}
+ aria-label="Add provider"
+ >
+ <PlusIcon />
+ </Button>
+ }
+ />
+ <TooltipPopup side="top">Add provider</TooltipPopup>
+ </Tooltip>
+ ) : null
+ }
headerAction={
<div className="flex min-w-0 items-center gap-2">
<ProviderUpdatesAction />
@@ -1181,23 +1200,6 @@ export function EnvironmentProviderSettings({
/>
<TooltipPopup side="top">Refresh provider status</TooltipPopup>
</Tooltip>
- {!readOnly ? (
- <Tooltip>
- <TooltipTrigger
- render={
- <Button
- size="icon-xs"
- variant="ghost-muted"
- onClick={() => setIsAddInstanceDialogOpen(true)}
- aria-label="Add provider"
- >
- <PlusIcon />
- </Button>
- }
- />
- <TooltipPopup side="top">Add provider</TooltipPopup>
- </Tooltip>
- ) : null}
</div>
}
>
@@ -1227,6 +1229,16 @@ export function EnvironmentProviderSettings({
>
<div className="divide-y divide-border/50">
{rows.map((row) => renderProviderInstance(row, "list"))}
+ {!readOnly ? (
+ <button
+ type="button"
+ className="flex w-full cursor-pointer items-center gap-3 px-3 py-3 text-left text-sm text-muted-foreground transition-colors outline-none hover:bg-muted/25 hover:text-foreground focus-visible:bg-muted/25 focus-visible:text-foreground sm:px-4"
+ onClick={() => setIsAddInstanceDialogOpen(true)}
+ >
+ <PlusIcon className="size-4 shrink-0" />
+ Add provider
+ </button>
+ ) : null}
</div>
</ScrollArea>
</div>
diff --git a/apps/web/src/components/settings/settingsLayout.tsx b/apps/web/src/components/settings/settingsLayout.tsx
index c455792eb94..99a47cb5aa6 100644
--- a/apps/web/src/components/settings/settingsLayout.tsx
+++ b/apps/web/src/components/settings/settingsLayout.tsx
@@ -176,6 +176,7 @@ export function SettingsSection({
title,
hideTitle = false,
icon,
+ titleAction,
headerAction,
variant = "grouped",
children,
@@ -185,6 +186,8 @@ export function SettingsSection({
title: string;
hideTitle?: boolean;
icon?: ReactNode;
+ /** Small control shown right after the title, such as an add button. */
+ titleAction?: ReactNode;
headerAction?: ReactNode;
variant?: "grouped" | "plain";
children: ReactNode;
@@ -205,11 +208,12 @@ export function SettingsSection({
data-settings-scroll-target
className="flex min-h-7 items-start justify-between gap-4 px-3 sm:px-4"
>
- <div className="min-w-0">
+ <div className="flex min-w-0 items-center gap-1">
<h2 className="flex min-h-7 items-center gap-2 text-sm font-normal text-foreground/70">
{icon}
{title}
</h2>
+ {titleAction}
</div>
<div className="flex min-h-7 min-w-7 items-center justify-end">{headerAction}</div>
</div>