Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/plugins-ui/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ export { PluginConnectPanel } from "./plugin-connect-panel";
export { McpServersSection } from "./mcp-servers-section";
export { McpPresetCardsSection } from "./mcp-preset-cards";

export { PLUGINS_STRINGS } from "./strings";

export {
McpServersApiError,
listMcpServers,
Expand Down
6 changes: 3 additions & 3 deletions packages/plugins-ui/src/mcp-preset-cards.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
type McpPreset,
} from "./mcp-servers-api";
import { PluginLogo } from "./plugin-logo";
import { PLUGINS_STRINGS } from "./strings";

function messageOf(cause: unknown): string {
return cause instanceof Error ? cause.message : String(cause);
Expand All @@ -27,8 +28,7 @@ const MCP_OAUTH_ERROR_COPY: Readonly<Record<string, string>> = {
state_expired:
"The connection took too long or was already used. Try connecting again.",
state_mismatch: "The connection was interrupted. Try connecting again.",
exchange_failed:
"That app didn't hand back a token. Try connecting again.",
exchange_failed: "That app didn't hand back a token. Try connecting again.",
connect_failed: "Couldn't finish connecting. Try connecting again.",
setup_failed:
"The sign-in worked, but storing the connection failed. Try connecting again.",
Expand Down Expand Up @@ -101,7 +101,7 @@ function McpPresetCard({
toast(`${preset.displayName} disconnected.`);
onChanged();
})
.catch(() => setError("Couldn't disconnect — try again."))
.catch(() => setError(PLUGINS_STRINGS.disconnectError))
.finally(() => setBusy(false));
}

Expand Down
3 changes: 2 additions & 1 deletion packages/plugins-ui/src/mcp-servers-section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
listMcpServers,
type McpServer,
} from "./mcp-servers-api";
import { PLUGINS_STRINGS } from "./strings";

function messageOf(cause: unknown): string {
return cause instanceof Error ? cause.message : String(cause);
Expand All @@ -43,7 +44,7 @@ function ConnectedMcpServerRow({
toast(`${server.name} disconnected.`);
onChanged();
})
.catch(() => setError("Couldn't disconnect — try again."))
.catch(() => setError(PLUGINS_STRINGS.disconnectError))
.finally(() => setBusy(false));
}

Expand Down
3 changes: 2 additions & 1 deletion packages/plugins-ui/src/plugin-connect-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import type { ResolvedPlugin } from "@workbench/connections/plugins";
import { useEffect, useState } from "react";

import { pluginOutcome } from "./plugin-meta";
import { PLUGINS_STRINGS } from "./strings";

const PLUGINS_RETURN_PATH = "/plugins";

Expand Down Expand Up @@ -142,7 +143,7 @@ function ConnectedSummary({
toast(`${plugin.descriptor.displayName} disconnected.`);
onChanged();
})
.catch(() => setError("Couldn't disconnect — try again."))
.catch(() => setError(PLUGINS_STRINGS.disconnectError))
.finally(() => setBusy(false));
}

Expand Down
6 changes: 6 additions & 0 deletions packages/plugins-ui/src/strings.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Every user-facing word the plugins surface prints, in one place. Nothing
// in the plugins-ui/* components inlines its own copy; it imports from here.

export const PLUGINS_STRINGS = {
disconnectError: "Couldn't disconnect — try again.",
} as const;
5 changes: 4 additions & 1 deletion packages/plugins-ui/test/mcp-preset-cards.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,10 @@ describe("McpPresetCardsSection", () => {
Object.defineProperty(window.location, "href", {
configurable: true,
get() {
return hrefDescriptor?.get?.call(window.location) ?? "https://workbench.test/";
return (
hrefDescriptor?.get?.call(window.location) ??
"https://workbench.test/"
);
},
set(value: string) {
assigned.push(value);
Expand Down
3 changes: 2 additions & 1 deletion packages/plugins-ui/test/plugin-connect-panel.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import type { ConnectorDescriptor } from "@workbench/connections/registry";
import type { ResolvedPlugin } from "@workbench/connections/plugins";

import { PluginConnectPanel } from "../src/plugin-connect-panel";
import { PLUGINS_STRINGS } from "../src/strings";

const realFetch = globalThis.fetch;
let mountedRoots: Root[] = [];
Expand Down Expand Up @@ -169,7 +170,7 @@ describe("PluginConnectPanel", () => {
});
await settle();

expect(container.textContent).toContain("Couldn't disconnect");
expect(container.textContent).toContain(PLUGINS_STRINGS.disconnectError);
});

function githubDescriptor(): ConnectorDescriptor {
Expand Down
Loading