Skip to content

Commit a9aedd8

Browse files
author
Laurie T. Malau
committed
[usage] More useful notification
1 parent 5cf2cb8 commit a9aedd8

File tree

2 files changed

+31
-4
lines changed

2 files changed

+31
-4
lines changed

components/dashboard/src/AppNotifications.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import { useEffect, useState } from "react";
88
import Alert from "./components/Alert";
9-
import { getGitpodService } from "./service/service";
9+
import { getGitpodService, gitpodHostUrl } from "./service/service";
1010

1111
const KEY_APP_NOTIFICATIONS = "gitpod-app-notifications";
1212

@@ -36,6 +36,7 @@ export function AppNotifications() {
3636
};
3737

3838
const topNotification = notifications[0];
39+
3940
if (topNotification === undefined) {
4041
return null;
4142
}
@@ -54,7 +55,18 @@ export function AppNotifications() {
5455
showIcon={true}
5556
className="flex rounded mb-2 w-full"
5657
>
57-
<span>{topNotification}</span>
58+
<span>{topNotification}</span> Manage
59+
<a
60+
className="gp-link hover:text-gray-600"
61+
href={
62+
notifications.length > 1
63+
? `${gitpodHostUrl}t/${notifications[notifications.length - 1]}/billing`
64+
: `${gitpodHostUrl}billing`
65+
}
66+
>
67+
{" "}
68+
billing.
69+
</a>
5870
</Alert>
5971
</div>
6072
);

components/server/ee/src/workspace/gitpod-server-impl.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2254,10 +2254,25 @@ export class GitpodServerEEImpl extends GitpodServerImpl {
22542254
const billingMode = await this.billingModes.getBillingModeForUser(user, new Date());
22552255
if (billingMode.mode === "usage-based") {
22562256
const limit = await this.billingService.checkUsageLimitReached(user);
2257+
let teamOrUser;
2258+
switch (limit.attributionId.kind) {
2259+
case "user": {
2260+
teamOrUser = await this.userDB.findUserById(limit.attributionId.userId);
2261+
break;
2262+
}
2263+
case "team": {
2264+
teamOrUser = await this.teamDB.findTeamById(limit.attributionId.teamId);
2265+
if (teamOrUser) {
2266+
result.push(teamOrUser?.slug);
2267+
}
2268+
break;
2269+
}
2270+
}
2271+
22572272
if (limit.reached) {
2258-
result.unshift("The usage limit is reached.");
2273+
result.unshift(`The usage limit for ${teamOrUser?.name} is reached.`);
22592274
} else if (limit.almostReached) {
2260-
result.unshift("The usage limit is almost reached.");
2275+
result.unshift(`The usage limit for ${teamOrUser?.name} is almost reached.`);
22612276
}
22622277
}
22632278
} catch (error) {

0 commit comments

Comments
 (0)