Skip to content

Commit 88fa55e

Browse files
geroplroboquat
authored andcommitted
[dashboard] Show BillingMode.teamNames on billing and admin pages
1 parent 242e510 commit 88fa55e

File tree

3 files changed

+42
-4
lines changed

3 files changed

+42
-4
lines changed

components/dashboard/src/admin/Property.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ function Property(p: {
1212
actions?: { label: string; onClick: () => void }[];
1313
}) {
1414
return (
15-
<div className="flex flex-col w-4/12 truncate">
16-
<div className="text-base text-gray-500 truncate">{p.name}</div>
17-
<div className="mr-3 text-lg text-gray-600 font-semibold truncate">{p.children}</div>
15+
<div className="flex flex-col w-4/12">
16+
<div className="text-base text-gray-500">{p.name}</div>
17+
<div className="mr-3 text-lg text-gray-600 font-semibold">{p.children}</div>
1818
{(p.actions || []).map((a) => (
1919
<div
2020
className="cursor-pointer text-sm text-blue-400 dark:text-blue-600 hover:text-blue-600 dark:hover:text-blue-400 truncate"

components/dashboard/src/admin/UserDetail.tsx

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ import Property from "./Property";
2424
import { PageWithAdminSubMenu } from "./PageWithAdminSubMenu";
2525
import { BillingMode } from "@gitpod/gitpod-protocol/lib/billing-mode";
2626
import { AttributionId } from "@gitpod/gitpod-protocol/lib/attribution";
27+
import CaretDown from "../icons/CaretDown.svg";
28+
import ContextMenu from "../components/ContextMenu";
2729

2830
export default function UserDetail(p: { user: User }) {
2931
const [activity, setActivity] = useState(false);
@@ -147,7 +149,7 @@ export default function UserDetail(p: { user: User }) {
147149
>
148150
{isStudent === undefined ? "---" : isStudent ? "Enabled" : "Disabled"}
149151
</Property>,
150-
<Property name="BillingMode">{billingMode?.mode || "---"}</Property>,
152+
renderBillingModeProperty(billingMode),
151153
];
152154

153155
switch (billingMode?.mode) {
@@ -328,6 +330,36 @@ export default function UserDetail(p: { user: User }) {
328330
);
329331
}
330332

333+
function renderBillingModeProperty(billingMode?: BillingMode): JSX.Element {
334+
const text = billingMode?.mode || "---";
335+
336+
let blockingTeamNames = [];
337+
if (billingMode?.mode === "chargebee" && !!billingMode.teamNames && !billingMode.canUpgradeToUBB) {
338+
const itemStyle = "text-gray-400 dark:text-gray-500 text-left font-normal";
339+
for (const teamName of billingMode.teamNames) {
340+
blockingTeamNames.push({ title: teamName, customFontStyle: itemStyle });
341+
}
342+
}
343+
return (
344+
<Property name="BillingMode">
345+
<>
346+
{text}
347+
{blockingTeamNames.length > 0 && (
348+
<ContextMenu
349+
menuEntries={blockingTeamNames}
350+
customClasses="w-64 max-h-48 overflow-scroll mx-auto left-0 right-0"
351+
>
352+
<p className="flex justify-left text-gitpod-red">
353+
<span>UBP blocked by:</span>
354+
<img className="m-2" src={CaretDown} />
355+
</p>
356+
</ContextMenu>
357+
)}
358+
</>
359+
</Property>
360+
);
361+
}
362+
331363
function Label(p: { text: string; color: string }) {
332364
return (
333365
<div className={`ml-3 text-sm text-${p.color}-600 truncate bg-${p.color}-100 px-1.5 py-0.5 rounded-md my-auto`}>

components/dashboard/src/settings/Plans.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -711,6 +711,12 @@ export default function () {
711711
</div>
712712
)}
713713
<div className="mt-4 flex justify-center space-x-3 2xl:space-x-7">{planCards}</div>
714+
{assignedTs && userBillingMode?.mode === "chargebee" && !!userBillingMode.teamNames && (
715+
<Alert type="info" className="mt-10 mx-auto">
716+
<p>Assigned Team Seats</p>
717+
<ul>{userBillingMode.teamNames.join(", ")}</ul>
718+
</Alert>
719+
)}
714720
<InfoBox className="w-2/3 mt-14 mx-auto">
715721
If you are interested in purchasing a plan for a team, purchase a Team plan with one centralized
716722
billing.{" "}

0 commit comments

Comments
 (0)