Skip to content

Commit 873a1a3

Browse files
committed
removed Emotion styles and added different colouring based on the usage percentage
1 parent 721561b commit 873a1a3

File tree

2 files changed

+81
-32
lines changed

2 files changed

+81
-32
lines changed

site/src/pages/DeploymentSettingsPage/LicensesSettingsPage/ManagedAgentsConsumption.stories.tsx

Lines changed: 62 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,70 @@ const meta: Meta<typeof ManagedAgentsConsumption> = {
2424
export default meta;
2525
type Story = StoryObj<typeof ManagedAgentsConsumption>;
2626

27-
export const Default: Story = {};
27+
export const Default: Story = {
28+
name: "Normal Usage (42% of limit)",
29+
};
30+
31+
export const Warning: Story = {
32+
name: "Warning (80-99% of limit)",
33+
args: {
34+
managedAgentFeature: {
35+
enabled: true,
36+
actual: 96000, // 80% of limit - should show orange
37+
soft_limit: 60000,
38+
limit: 120000,
39+
usage_period: {
40+
start: "February 27, 2025",
41+
end: "February 27, 2026",
42+
issued_at: "February 27, 2025",
43+
},
44+
entitlement: "entitled",
45+
},
46+
},
47+
};
2848

2949
export const NearLimit: Story = {
50+
name: "Near Limit (95% of limit)",
51+
args: {
52+
managedAgentFeature: {
53+
enabled: true,
54+
actual: 114000, // 95% of limit - should show orange
55+
soft_limit: 60000,
56+
limit: 120000,
57+
usage_period: {
58+
start: "February 27, 2025",
59+
end: "February 27, 2026",
60+
issued_at: "February 27, 2025",
61+
},
62+
entitlement: "entitled",
63+
},
64+
},
65+
};
66+
67+
export const AtLimit: Story = {
68+
name: "At Limit (100% of limit)",
69+
args: {
70+
managedAgentFeature: {
71+
enabled: true,
72+
actual: 120000, // 100% of limit - should show red
73+
soft_limit: 60000,
74+
limit: 120000,
75+
usage_period: {
76+
start: "February 27, 2025",
77+
end: "February 27, 2026",
78+
issued_at: "February 27, 2025",
79+
},
80+
entitlement: "entitled",
81+
},
82+
},
83+
};
84+
85+
export const OverLimit: Story = {
86+
name: "Over Limit (120% of limit)",
3087
args: {
3188
managedAgentFeature: {
3289
enabled: true,
33-
actual: 115000,
90+
actual: 144000, // 120% of limit - should show red
3491
soft_limit: 60000,
3592
limit: 120000,
3693
usage_period: {
@@ -44,10 +101,11 @@ export const NearLimit: Story = {
44101
};
45102

46103
export const OverIncluded: Story = {
104+
name: "Over Included (67% of limit)",
47105
args: {
48106
managedAgentFeature: {
49107
enabled: true,
50-
actual: 80000,
108+
actual: 80000, // Over included but under 80% of total limit - should still be green
51109
soft_limit: 60000,
52110
limit: 120000,
53111
usage_period: {
@@ -61,6 +119,7 @@ export const OverIncluded: Story = {
61119
};
62120

63121
export const LowUsage: Story = {
122+
name: "Low Usage (21% of limit)",
64123
args: {
65124
managedAgentFeature: {
66125
enabled: true,

site/src/pages/DeploymentSettingsPage/LicensesSettingsPage/ManagedAgentsConsumption.tsx

Lines changed: 19 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import type { Interpolation, Theme } from "@emotion/react";
21
import MuiLink from "@mui/material/Link";
32
import type { Feature } from "api/typesGenerated";
43
import { ErrorAlert } from "components/Alert/ErrorAlert";
@@ -74,13 +73,13 @@ export const ManagedAgentsConsumption: FC<ManagedAgentsConsumptionProps> = ({
7473
// If no feature is provided or it's disabled, show disabled state
7574
if (!managedAgentFeature?.enabled) {
7675
return (
77-
<div css={styles.disabledRoot}>
76+
<div className="min-h-60 flex items-center justify-center rounded-lg border border-solid p-12">
7877
<Stack alignItems="center" spacing={1}>
7978
<Stack alignItems="center" spacing={0.5}>
80-
<span css={styles.disabledTitle}>
79+
<span className="text-base">
8180
Managed AI Agents Disabled
8281
</span>
83-
<span css={styles.disabledDescription}>
82+
<span className="text-content-secondary text-center max-w-[464px] mt-2">
8483
Managed AI agents are not included in your current license.
8584
Contact{" "}
8685
<MuiLink href="mailto:sales@coder.com">sales</MuiLink> to upgrade
@@ -102,6 +101,20 @@ export const ManagedAgentsConsumption: FC<ManagedAgentsConsumptionProps> = ({
102101
const includedPercentage = Math.min((included / limit) * 100, 100);
103102
const remainingPercentage = Math.max(100 - includedPercentage, 0);
104103

104+
// Determine usage bar color based on percentage
105+
const getUsageColor = () => {
106+
const actualUsagePercent = (usage / limit) * 100;
107+
if (actualUsagePercent >= 100) {
108+
return "bg-highlight-red"; // Critical: at or over limit
109+
}
110+
if (actualUsagePercent >= 80) {
111+
return "bg-surface-orange"; // Warning: approaching limit
112+
}
113+
return "bg-highlight-green"; // Normal: safe usage
114+
};
115+
116+
const usageBarColor = getUsageColor();
117+
105118
return (
106119
<section className="border border-solid rounded">
107120
<div className="p-4">
@@ -139,7 +152,7 @@ export const ManagedAgentsConsumption: FC<ManagedAgentsConsumptionProps> = ({
139152
<ul>
140153
<li className="flex items-center gap-2">
141154
<div
142-
className="rounded-[2px] bg-highlight-green size-3 inline-block"
155+
className={`rounded-[2px] ${usageBarColor} size-3 inline-block`}
143156
aria-label="Legend for current usage in the chart"
144157
/>
145158
Amount of started workspaces with an AI agent.
@@ -175,7 +188,7 @@ export const ManagedAgentsConsumption: FC<ManagedAgentsConsumptionProps> = ({
175188

176189
<div className="relative h-6 bg-surface-secondary rounded overflow-hidden">
177190
<div
178-
className="absolute top-0 left-0 h-full bg-highlight-green transition-all duration-300"
191+
className={`absolute top-0 left-0 h-full ${usageBarColor} transition-all duration-300`}
179192
style={{ width: `${usagePercentage}%` }}
180193
/>
181194

@@ -230,26 +243,3 @@ export const ManagedAgentsConsumption: FC<ManagedAgentsConsumptionProps> = ({
230243
</section>
231244
);
232245
};
233-
234-
const styles = {
235-
disabledTitle: {
236-
fontSize: 16,
237-
},
238-
239-
disabledRoot: (theme) => ({
240-
minHeight: 240,
241-
display: "flex",
242-
alignItems: "center",
243-
justifyContent: "center",
244-
borderRadius: 8,
245-
border: `1px solid ${theme.palette.divider}`,
246-
padding: 48,
247-
}),
248-
249-
disabledDescription: (theme) => ({
250-
color: theme.palette.text.secondary,
251-
textAlign: "center",
252-
maxWidth: 464,
253-
marginTop: 8,
254-
}),
255-
} satisfies Record<string, Interpolation<Theme>>;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy