Skip to content

Commit 67a88fe

Browse files
authored
refactor(web): share connectors explainer copy across login and upsell menus (#1280)
1 parent bd47aab commit 67a88fe

3 files changed

Lines changed: 54 additions & 20 deletions

File tree

packages/web/src/ee/features/chat/mcp/components/connectorsMenu.tsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { ErrorCode } from "@/lib/errorCodes";
2020
import type { ServiceError } from "@/lib/serviceError";
2121
import { isServiceError } from "@/lib/utils";
2222
import { useQuery, useQueryClient } from "@tanstack/react-query";
23-
import { AlertTriangleIcon, CableIcon, Loader2Icon, LogInIcon, PlusCircleIcon, PlusIcon, RefreshCwIcon, SettingsIcon } from "lucide-react";
23+
import { AlertTriangleIcon, CableIcon, Loader2Icon, PlusCircleIcon, PlusIcon, RefreshCwIcon, SettingsIcon } from "lucide-react";
2424
import Link from "next/link";
2525
import { usePathname, useRouter } from "next/navigation";
2626
import { useEffect, useRef, useState } from "react";
@@ -36,6 +36,7 @@ import {
3636
import { clearEditorHistory, resetEditor } from "@/features/chat/utils";
3737
import { useRole } from "@/features/auth/useRole";
3838
import { OrgRole } from "@sourcebot/db";
39+
import { ConnectorsExplainerText } from "@/features/chat/components/chatBox/connectorsExplainerText";
3940

4041
interface ConnectorsMenuProps {
4142
selectedSearchScopes: SearchScope[];
@@ -314,12 +315,15 @@ export const ConnectorsMenu = ({
314315
</>
315316
)}
316317
{shouldShowLoginConnectorItem ? (
317-
<DropdownMenuItem asChild className="gap-2 text-link focus:text-link">
318-
<Link href={loginHref}>
319-
<LogInIcon className="w-4 h-4" />
320-
Log in to use connectors
321-
</Link>
322-
</DropdownMenuItem>
318+
<ConnectorsExplainerText
319+
leading={
320+
<>
321+
You must{" "}
322+
<Link href={loginHref} className="text-link hover:underline">login</Link>
323+
{" "}to configure connectors.{" "}
324+
</>
325+
}
326+
/>
323327
) : (
324328
<>
325329
<DropdownMenuItem

packages/web/src/features/chat/components/chatBox/connectorsExplainerMenu.tsx

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ import {
1010
} from "@/components/ui/dropdown-menu";
1111
import { CableIcon, PlusIcon } from "lucide-react";
1212
import { UpsellDialog } from "@/features/billing/upsellDialog";
13-
14-
// TODO(ask): finalize the connectors docs URL once the page exists.
15-
const CONNECTORS_DOCS_URL = "https://docs.sourcebot.dev/docs/features/ask/connectors";
13+
import { ConnectorsExplainerText } from "@/features/chat/components/chatBox/connectorsExplainerText";
1614

1715
/**
1816
* Free-plan stand-in for the connectors menu. This is intentionally NOT in ee/:
@@ -50,16 +48,20 @@ export const ConnectorsExplainerMenu = () => {
5048
<CableIcon className="w-4 h-4 text-muted-foreground" />
5149
Connectors
5250
</DropdownMenuLabel>
53-
<p className="px-2 pb-1.5 text-xs text-muted-foreground">
54-
Connect external tools like Linear or Jira so the agent can pull in context beyond your code. Connectors are available on a{" "}
55-
<button
56-
type="button"
57-
onClick={openUpsell}
58-
className="text-link hover:underline"
59-
>
60-
paid plan
61-
</button>. <a href={CONNECTORS_DOCS_URL} target="_blank" rel="noopener noreferrer" className="text-link hover:underline">Learn more</a>
62-
</p>
51+
<ConnectorsExplainerText
52+
trailing={
53+
<>
54+
Connectors are available on a{" "}
55+
<button
56+
type="button"
57+
onClick={openUpsell}
58+
className="text-link hover:underline"
59+
>
60+
paid plan
61+
</button>.
62+
</>
63+
}
64+
/>
6365
</DropdownMenuContent>
6466
</DropdownMenu>
6567
<UpsellDialog open={isUpsellOpen} onOpenChange={setIsUpsellOpen} source="chat_connectors" />
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import type { ReactNode } from "react";
2+
import { cn } from "@/lib/utils";
3+
4+
export const CONNECTORS_DOCS_URL = "https://docs.sourcebot.dev/docs/features/ask/connectors";
5+
6+
interface ConnectorsExplainerTextProps {
7+
/** Rendered inline before the shared description sentence. */
8+
leading?: ReactNode;
9+
/** Rendered inline after the shared description sentence, before "Learn more". */
10+
trailing?: ReactNode;
11+
className?: string;
12+
}
13+
14+
/**
15+
* Shared connectors explainer copy. Intentionally NOT in ee/ so the free-plan
16+
* teaser and the licensed connectors menu can both render the same description
17+
* without the free path importing ee/ feature code.
18+
*/
19+
export const ConnectorsExplainerText = ({ leading, trailing, className }: ConnectorsExplainerTextProps) => {
20+
return (
21+
<p className={cn("px-2 pb-1.5 text-xs text-muted-foreground", className)}>
22+
{leading}
23+
Connect external tools like Linear or Jira so the agent can pull in context beyond your code.{" "}
24+
{trailing ? <>{trailing}{" "}</> : null}
25+
<a href={CONNECTORS_DOCS_URL} target="_blank" rel="noopener noreferrer" className="text-link hover:underline">Learn more</a>
26+
</p>
27+
);
28+
};

0 commit comments

Comments
 (0)