fix(ui): surface the config-endpoint hint as visible menu text

This commit is contained in:
mubashir1osmani 2026-09-08 17:43:23 -04:00
parent d72eb4491a
commit 093b473710
2 changed files with 19 additions and 5 deletions

View file

@ -115,6 +115,9 @@ describe("PassThroughEndpointsTable", () => {
expect(editItem).toHaveAttribute("data-disabled");
expect(deleteItem).toHaveAttribute("data-disabled");
expect(screen.getByTestId("endpoint-config-hint")).toHaveTextContent(
"This endpoint is defined in the config file and cannot be edited or deleted on the dashboard.",
);
await user.click(editItem);
await user.click(deleteItem);
@ -123,6 +126,15 @@ describe("PassThroughEndpointsTable", () => {
expect(onDeleteClick).not.toHaveBeenCalled();
});
it("should not show the config hint for DB endpoints", async () => {
const user = userEvent.setup();
render(<PassThroughEndpointsTable {...defaultProps} />);
await user.click(screen.getByTestId("endpoint-actions-ep-1"));
await screen.findByTestId("endpoint-action-delete");
expect(screen.queryByTestId("endpoint-config-hint")).not.toBeInTheDocument();
});
it("should label endpoint source as Config or DB", () => {
const configEndpoint: passThroughItem = {
id: "ep-config",

View file

@ -18,9 +18,8 @@ import { cn } from "@/lib/cva.config";
import type { passThroughItem } from "./PassThroughSettings";
const CONFIG_EDIT_HINT = "Config pass-through endpoints cannot be edited on the dashboard. Please edit the config file.";
const CONFIG_DELETE_HINT =
"Config pass-through endpoints cannot be deleted on the dashboard. Please edit the config file.";
const CONFIG_ENDPOINT_HINT =
"This endpoint is defined in the config file and cannot be edited or deleted on the dashboard.";
function HeaderWithTooltip({ title, tooltip }: { title: string; tooltip: string }) {
return (
@ -91,7 +90,6 @@ function EndpointRowActions({ endpoint, onEndpointClick, onDeleteClick }: Endpoi
<DropdownMenuItem
data-testid="endpoint-action-edit"
disabled={isFromConfig || !endpointId}
title={isFromConfig ? CONFIG_EDIT_HINT : undefined}
onClick={() => !isFromConfig && endpointId && onEndpointClick(endpointId)}
>
<Pencil />
@ -102,12 +100,16 @@ function EndpointRowActions({ endpoint, onEndpointClick, onDeleteClick }: Endpoi
variant="destructive"
data-testid="endpoint-action-delete"
disabled={isFromConfig || !endpointId}
title={isFromConfig ? CONFIG_DELETE_HINT : undefined}
onClick={() => !isFromConfig && endpointId && onDeleteClick(endpointId)}
>
<Trash2 />
Delete
</DropdownMenuItem>
{isFromConfig && (
<div data-testid="endpoint-config-hint" className="px-2 py-1.5 text-xs text-muted-foreground">
{CONFIG_ENDPOINT_HINT}
</div>
)}
</DropdownMenuContent>
</DropdownMenu>
);