Skip to content

Commit 67da780

Browse files
authored
fix: avoid error when AI usage is zero (#19388)
Fixes a bug that prevents the managed AI agent usage from showing in the licenses page of the dashboard when the usage is zero. Adds a story with this case as well.
1 parent c310a32 commit 67da780

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,23 @@ type Story = StoryObj<typeof ManagedAgentsConsumption>;
2626

2727
export const Default: Story = {};
2828

29+
export const ZeroUsage: Story = {
30+
args: {
31+
managedAgentFeature: {
32+
enabled: true,
33+
actual: 0,
34+
soft_limit: 60000,
35+
limit: 120000,
36+
usage_period: {
37+
start: "February 27, 2025",
38+
end: "February 27, 2026",
39+
issued_at: "February 27, 2025",
40+
},
41+
entitlement: "entitled",
42+
},
43+
},
44+
};
45+
2946
export const NearLimit: Story = {
3047
args: {
3148
managedAgentFeature: {

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,16 @@ export const ManagedAgentsConsumption: FC<ManagedAgentsConsumptionProps> = ({
4444
const startDate = managedAgentFeature.usage_period?.start;
4545
const endDate = managedAgentFeature.usage_period?.end;
4646

47-
if (!usage || usage < 0) {
47+
if (usage === undefined || usage < 0) {
4848
return <ErrorAlert error="Invalid usage data" />;
4949
}
5050

51-
if (!included || included < 0 || !limit || limit < 0) {
51+
if (
52+
included === undefined ||
53+
included < 0 ||
54+
limit === undefined ||
55+
limit < 0
56+
) {
5257
return <ErrorAlert error="Invalid license usage limits" />;
5358
}
5459

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