Skip to content

Commit d3d0967

Browse files
authored
Show cloud switcher and option to add a team when logged in (#8291)
1 parent 25f6194 commit d3d0967

File tree

22 files changed

+84
-22
lines changed

22 files changed

+84
-22
lines changed

webview-ui/src/components/chat/ChatTextArea.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ export const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
8989
clineMessages,
9090
commands,
9191
cloudUserInfo,
92-
cloudOrganizations,
9392
} = useExtensionState()
9493

9594
// Find the ID and display text for the currently selected API configuration.
@@ -1238,9 +1237,7 @@ export const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
12381237
<div
12391238
className={cn(
12401239
"flex flex-shrink-0 items-center gap-0.5",
1241-
!isEditMode && cloudOrganizations && cloudOrganizations.length > 0 && cloudUserInfo
1242-
? ""
1243-
: "pr-2",
1240+
!isEditMode && cloudUserInfo ? "" : "pr-2",
12441241
)}>
12451242
{isTtsPlaying && (
12461243
<StandardTooltip content={t("chat:stopTts")}>
@@ -1263,9 +1260,7 @@ export const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
12631260
</StandardTooltip>
12641261
)}
12651262
{!isEditMode ? <IndexingStatusBadge /> : null}
1266-
{!isEditMode && cloudOrganizations && cloudOrganizations.length > 0 && cloudUserInfo && (
1267-
<CloudAccountSwitcher />
1268-
)}
1263+
{!isEditMode && cloudUserInfo && <CloudAccountSwitcher />}
12691264
</div>
12701265
</div>
12711266
</div>

webview-ui/src/components/cloud/CloudAccountSwitcher.tsx

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useState, useEffect } from "react"
2-
import { Building2 } from "lucide-react"
2+
import { Building2, Plus } from "lucide-react"
33
import { Select, SelectContent, SelectItem, SelectTrigger, SelectSeparator } from "@/components/ui/select"
44
import { useAppTranslation } from "@src/i18n/TranslationContext"
55
import { vscode } from "@src/utils/vscode"
@@ -8,7 +8,7 @@ import { cn } from "@src/lib/utils"
88

99
export const CloudAccountSwitcher = () => {
1010
const { t } = useAppTranslation()
11-
const { cloudUserInfo, cloudOrganizations = [] } = useExtensionState()
11+
const { cloudUserInfo, cloudOrganizations = [], cloudApiUrl } = useExtensionState()
1212
const [selectedOrgId, setSelectedOrgId] = useState<string | null>(cloudUserInfo?.organizationId || null)
1313
const [isLoading, setIsLoading] = useState(false)
1414

@@ -17,12 +17,21 @@ export const CloudAccountSwitcher = () => {
1717
setSelectedOrgId(cloudUserInfo?.organizationId || null)
1818
}, [cloudUserInfo?.organizationId])
1919

20-
// Don't show the switcher if user has no organizations
21-
if (!cloudOrganizations || cloudOrganizations.length === 0 || !cloudUserInfo) {
20+
// Show the switcher whenever user is authenticated
21+
if (!cloudUserInfo) {
2222
return null
2323
}
2424

2525
const handleOrganizationChange = async (value: string) => {
26+
// Handle "Create Team Account" option
27+
if (value === "create-team") {
28+
if (cloudApiUrl) {
29+
const billingUrl = `${cloudApiUrl}/billing`
30+
vscode.postMessage({ type: "openExternal", url: billingUrl })
31+
}
32+
return
33+
}
34+
2635
const newOrgId = value === "personal" ? null : value
2736

2837
// Don't do anything if selecting the same organization
@@ -139,6 +148,19 @@ export const CloudAccountSwitcher = () => {
139148
</div>
140149
</SelectItem>
141150
))}
151+
152+
{/* Only show Create Team Account if user has no organizations */}
153+
{cloudOrganizations.length === 0 && (
154+
<>
155+
<SelectSeparator />
156+
<SelectItem value="create-team">
157+
<div className="flex items-center gap-2">
158+
<Plus className="w-4.5 h-4.5" />
159+
<span>{t("cloud:createTeamAccount")}</span>
160+
</div>
161+
</SelectItem>
162+
</>
163+
)}
142164
</SelectContent>
143165
</Select>
144166
</div>

webview-ui/src/components/cloud/CloudView.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -190,11 +190,13 @@ export const CloudView = ({ userInfo, isAuthenticated, cloudApiUrl, onDone, orga
190190
)}
191191

192192
{/* Organization Switcher - moved below email */}
193-
{organizations && organizations.length > 0 && (
194-
<div className="w-full max-w-60 mt-4">
195-
<OrganizationSwitcher userInfo={userInfo} organizations={organizations} />
196-
</div>
197-
)}
193+
<div className="w-full max-w-60 mt-4">
194+
<OrganizationSwitcher
195+
userInfo={userInfo}
196+
organizations={organizations}
197+
cloudApiUrl={cloudApiUrl}
198+
/>
199+
</div>
198200
</div>
199201
)}
200202

webview-ui/src/components/cloud/OrganizationSwitcher.tsx

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useState, useEffect } from "react"
2-
import { Building2, User } from "lucide-react"
2+
import { Building2, User, Plus } from "lucide-react"
33
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, SelectSeparator } from "@/components/ui/select"
44
import { type CloudUserInfo, type CloudOrganizationMembership } from "@roo-code/types"
55
import { useAppTranslation } from "@src/i18n/TranslationContext"
@@ -10,9 +10,15 @@ type OrganizationSwitcherProps = {
1010
userInfo: CloudUserInfo
1111
organizations: CloudOrganizationMembership[]
1212
onOrganizationChange?: (organizationId: string | null) => void
13+
cloudApiUrl?: string
1314
}
1415

15-
export const OrganizationSwitcher = ({ userInfo, organizations, onOrganizationChange }: OrganizationSwitcherProps) => {
16+
export const OrganizationSwitcher = ({
17+
userInfo,
18+
organizations,
19+
onOrganizationChange,
20+
cloudApiUrl,
21+
}: OrganizationSwitcherProps) => {
1622
const { t } = useAppTranslation()
1723
const [selectedOrgId, setSelectedOrgId] = useState<string | null>(userInfo.organizationId || null)
1824
const [isLoading, setIsLoading] = useState(false)
@@ -45,6 +51,15 @@ export const OrganizationSwitcher = ({ userInfo, organizations, onOrganizationCh
4551
}, [userInfo.organizationId])
4652

4753
const handleOrganizationChange = async (value: string) => {
54+
// Handle "Create Team Account" option
55+
if (value === "create-team") {
56+
if (cloudApiUrl) {
57+
const billingUrl = `${cloudApiUrl}/billing`
58+
vscode.postMessage({ type: "openExternal", url: billingUrl })
59+
}
60+
return
61+
}
62+
4863
const newOrgId = value === "personal" ? null : value
4964

5065
// Don't do anything if selecting the same organization
@@ -69,10 +84,7 @@ export const OrganizationSwitcher = ({ userInfo, organizations, onOrganizationCh
6984
}
7085
}
7186

72-
// If user has no organizations, don't show the switcher
73-
if (!organizations || organizations.length === 0) {
74-
return null
75-
}
87+
// Always show the switcher when user is authenticated
7688

7789
const currentValue = selectedOrgId || "personal"
7890

@@ -139,6 +151,19 @@ export const OrganizationSwitcher = ({ userInfo, organizations, onOrganizationCh
139151
</div>
140152
</SelectItem>
141153
))}
154+
155+
{/* Only show Create Team Account if user has no organizations */}
156+
{organizations.length === 0 && (
157+
<>
158+
<SelectSeparator />
159+
<SelectItem value="create-team">
160+
<div className="flex items-center gap-2">
161+
<Plus className="w-4.5 h-4.5" />
162+
<span>{t("cloud:createTeamAccount")}</span>
163+
</div>
164+
</SelectItem>
165+
</>
166+
)}
142167
</SelectContent>
143168
</Select>
144169
</div>

webview-ui/src/i18n/locales/ca/cloud.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webview-ui/src/i18n/locales/de/cloud.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webview-ui/src/i18n/locales/en/cloud.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"startOver": "Start over",
2626
"personalAccount": "Personal Account",
2727
"switchAccount": "Switch Roo Code Cloud Account",
28+
"createTeamAccount": "Create Team Account",
2829
"upsell": {
2930
"autoApprovePowerUser": "Giving Roo some independence? Control it from anywhere with Roo Code Cloud. <learnMoreLink>Learn more</learnMoreLink>.",
3031
"longRunningTask": "This might take a while. Continue from anywhere with Cloud.",

webview-ui/src/i18n/locales/es/cloud.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webview-ui/src/i18n/locales/fr/cloud.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webview-ui/src/i18n/locales/hi/cloud.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)