Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(webview): add Sourcegraph Workspaces upgrade CTA #6605

Merged
merged 6 commits into from
Jan 15, 2025
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
3 changes: 2 additions & 1 deletion vscode/src/chat/protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,6 @@ export const SG_CHANGELOG_URL = new URL('https://sourcegraph.com/changelog')
export const VSCODE_CHANGELOG_URL = new URL(
'https://github.com/sourcegraph/cody/blob/main/vscode/CHANGELOG.md'
)

// Community and support
export const DISCORD_URL = new URL('https://discord.gg/s2qDtYGnAE')
export const CODY_FEEDBACK_URL = new URL('https://github.com/sourcegraph/cody/issues/new/choose')
Expand All @@ -273,6 +272,8 @@ export const CODY_OLLAMA_DOCS_URL = new URL(
'https://sourcegraph.com/docs/cody/clients/install-vscode#supported-local-ollama-models-with-cody'
)
// Account
export const ENTERPRISE_PRICING_URL = new URL('https://sourcegraph.com/pricing')
export const CODY_PRO_SUBSCRIPTION_URL = new URL('https://accounts.sourcegraph.com/cody/subscription')
export const ACCOUNT_UPGRADE_URL = new URL('https://sourcegraph.com/cody/subscription')
export const ACCOUNT_USAGE_URL = new URL('https://sourcegraph.com/cody/manage')
export const ACCOUNT_LIMITS_INFO_URL = new URL(
Expand Down
1 change: 1 addition & 0 deletions vscode/webviews/CodyPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ export const CodyPanel: FunctionComponent<CodyPanelProps> = ({
currentView={view}
setView={setView}
endpointHistory={config.endpointHistory ?? []}
isTeamsUpgradeCtaEnabled={isTeamsUpgradeCtaEnabled}
/>
)}
{errorMessages && <ErrorBanner errors={errorMessages} setErrors={setErrorMessages} />}
Expand Down
114 changes: 112 additions & 2 deletions vscode/webviews/components/UserMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,17 @@ import {
PlusIcon,
Settings2Icon,
UserCircleIcon,
ZapIcon,
} from 'lucide-react'
import { useCallback, useState } from 'react'
import { URI } from 'vscode-uri'
import { ACCOUNT_USAGE_URL, isSourcegraphToken } from '../../src/chat/protocol'
import {
ACCOUNT_USAGE_URL,
CODY_PRO_SUBSCRIPTION_URL,
ENTERPRISE_PRICING_URL,
isSourcegraphToken,
} from '../../src/chat/protocol'
import { SourcegraphLogo } from '../icons/SourcegraphLogo'
import { getVSCodeAPI } from '../utils/VSCodeApi'
import { useTelemetryRecorder } from '../utils/telemetry'
import { UserAvatar } from './UserAvatar'
Expand All @@ -34,6 +41,8 @@ interface UserMenuProps {
onCloseByEscape?: () => void
allowEndpointChange: boolean
__storybook__open?: boolean
// Whether to show the Sourcegraph Teams upgrade CTA or not.
isTeamsUpgradeCtaEnabled?: boolean
}

type MenuView = 'main' | 'switch' | 'add' | 'remove'
Expand All @@ -46,6 +55,7 @@ export const UserMenu: React.FunctionComponent<UserMenuProps> = ({
onCloseByEscape,
allowEndpointChange,
__storybook__open,
isTeamsUpgradeCtaEnabled,
}) => {
const telemetryRecorder = useTelemetryRecorder()
const { displayName, username, primaryEmail, endpoint } = authStatus
Expand Down Expand Up @@ -306,6 +316,49 @@ export const UserMenu: React.FunctionComponent<UserMenuProps> = ({
<span className="tw-flex-grow">Add another account</span>
</CommandItem>
</CommandGroup>

{isTeamsUpgradeCtaEnabled && (
<CommandGroup>
<CommandLink
href="https://workspaces.sourcegraph.com"
target="_blank"
rel="noreferrer"
className="tw-flex tw-w-full tw-justify-start tw-gap-8 tw-align-center tw-flex-col tw-font-left !tw-bg-transparent hover:!tw-bg-transparent [&[aria-selected]]:!tw-bg-transparent tw-pt-[15px]"
>
<div className="tw-flex tw-w-full tw-justify-start tw-gap-4 tw-align-center">
{/* TODO: Replace with new logo */}
<SourcegraphLogo
width={16}
height={16}
className="tw-mr-2"
/>
<Badge
variant="secondary"
className="tw-opacity-85 tw-text-xs tw-h-fit tw-self-center"
>
Enterprise Starter
</Badge>
</div>
<div>
<div className="tw-w-full tw-text-[14px] tw-font-semibold tw-text-left tw-mb-5">
Unlock the Sourcegraph platform
</div>
<div className="tw-text-[12px] tw-text-muted-foreground">
Create a workspace and connect GitHub repositories to
unlock Code Search, AI chat, autocompletes, inline edits
and more for your team.
</div>
</div>
<Button
key="workspace-create-button"
variant="secondary"
className="tw-flex-grow tw-rounded-md tw-text-center tw-w-full tw-text-foreground tw-my-2 tw-text-[12px]"
>
Create a workspace
</Button>
</CommandLink>
</CommandGroup>
)}
</CommandList>
) : (
<CommandList>
Expand Down Expand Up @@ -344,6 +397,44 @@ export const UserMenu: React.FunctionComponent<UserMenuProps> = ({
</CommandGroup>

<CommandGroup>
{isDotComUser && !isProUser && (
<CommandLink
href={CODY_PRO_SUBSCRIPTION_URL.toString()}
target="_blank"
rel="noreferrer"
onSelect={() => {
telemetryRecorder.recordEvent(
'cody.userMenu.upgradeToProLink',
'open',
{}
)
close()
}}
>
<svg className="tw-w-8 tw-h-8 tw-mr-2">
<title>zapIconGradient</title>
<defs>
<linearGradient
id="zapIconGradient"
x1="100%"
y1="100%"
x2="0%"
y2="0%"
>
<stop offset="0%" stopColor="#00cbec" />
<stop offset="50%" stopColor="#a112ff" />
<stop offset="100%" stopColor="#ff5543" />
</linearGradient>
</defs>
<ZapIcon
size={16}
strokeWidth={1.25}
style={{ stroke: 'url(#zapIconGradient)' }}
/>
</svg>
<span className="tw-flex-grow">Upgrade to Pro</span>
</CommandLink>
)}
{isDotComUser && (
<CommandItem
onSelect={() => {
Expand Down Expand Up @@ -384,6 +475,25 @@ export const UserMenu: React.FunctionComponent<UserMenuProps> = ({
<Settings2Icon size={16} strokeWidth={1.25} className="tw-mr-2" />
<span className="tw-flex-grow">Extension Settings</span>
</CommandItem>
{isDotComUser && (
<CommandLink
href={ENTERPRISE_PRICING_URL.toString()}
target="_blank"
rel="noreferrer"
onSelect={() => {
telemetryRecorder.recordEvent(
'cody.userMenu.exploreEnterprisePlanLink',
'open',
{}
)
close()
}}
>
<SourcegraphLogo width={16} height={16} className="tw-mr-2" />
<span className="tw-flex-grow">Explore Enterprise Plans</span>
<ExternalLinkIcon size={16} strokeWidth={1.25} />
</CommandLink>
)}
</CommandGroup>

<CommandGroup>
Expand Down Expand Up @@ -429,7 +539,7 @@ export const UserMenu: React.FunctionComponent<UserMenuProps> = ({
)}
popoverRootProps={{ onOpenChange }}
popoverContentProps={{
className: '!tw-p-2',
className: '!tw-p-2 tw-mr-6',
onKeyDown: onKeyDown,
onCloseAutoFocus: event => {
event.preventDefault()
Expand Down
3 changes: 3 additions & 0 deletions vscode/webviews/tabs/TabsBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ interface TabsBarProps {
currentView: View
setView: (view: View) => void
endpointHistory: string[]
// Whether to show the Sourcegraph Teams upgrade CTA or not.
isTeamsUpgradeCtaEnabled?: boolean
}

type IconComponent = React.ForwardRefExoticComponent<
Expand Down Expand Up @@ -157,6 +159,7 @@ export const TabsBar = memo<TabsBarProps>(props => {
endpointHistory={endpointHistory}
allowEndpointChange={allowEndpointChange}
className="!tw-opacity-100 tw-h-full"
isTeamsUpgradeCtaEnabled={props.isTeamsUpgradeCtaEnabled}
/>
)}
</div>
Expand Down
Loading