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 Upgrade to Pro & Enterprise plan to user menu #6606

Open
wants to merge 3 commits into
base: bee/workspace-welcome
Choose a base branch
from
Open
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
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
47 changes: 46 additions & 1 deletion vscode/webviews/components/UserMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
import { useCallback, useState } from 'react'
import { URI } from 'vscode-uri'
import { ACCOUNT_USAGE_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 +35,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 +49,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 +310,47 @@ 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-4 tw-align-center tw-flex-col tw-bg-inherit tw-font-left"
>
<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 className="tw-w-full tw-text-lg tw-font-semibold tw-text-left tw-mt-2">
Unlock the Sourcegraph platform
</div>
<div className="tw-text-md 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>
<Button
key="workspace-create-button"
variant="outline"
className="tw-flex-grow tw-rounded-md tw-text-center tw-w-full tw-text-foreground tw-my-2"
>
Create a workspace
</Button>
</CommandLink>
</CommandGroup>
)}
</CommandList>
) : (
<CommandList>
Expand Down Expand Up @@ -429,7 +474,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