Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,23 @@ type Story = StoryObj<typeof ManagedAgentsConsumption>;

export const Default: Story = {};

export const ZeroUsage: Story = {
args: {
managedAgentFeature: {
enabled: true,
actual: 0,
soft_limit: 60000,
limit: 120000,
usage_period: {
start: "February 27, 2025",
end: "February 27, 2026",
issued_at: "February 27, 2025",
},
entitlement: "entitled",
},
},
};

export const NearLimit: Story = {
args: {
managedAgentFeature: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,17 @@ export const ManagedAgentsConsumption: FC<ManagedAgentsConsumptionProps> = ({
);
}

const usage = managedAgentFeature.actual;
const included = managedAgentFeature.soft_limit;
const limit = managedAgentFeature.limit;
const usage = managedAgentFeature.actual ?? 0;
const included = managedAgentFeature.soft_limit ?? 0;
const limit = managedAgentFeature.limit ?? 0;
Copy link
Member

@aslilac aslilac Aug 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not coercing these to 0 was intentional. if we get past the enabled check then these need to be some positive integer. (except usage, which can also be 0)

const startDate = managedAgentFeature.usage_period?.start;
const endDate = managedAgentFeature.usage_period?.end;

if (!usage || usage < 0) {
if (usage < 0) {
return <ErrorAlert error="Invalid usage data" />;
}

if (!included || included < 0 || !limit || limit < 0) {
if (included < 0 || limit < 0) {
return <ErrorAlert error="Invalid license usage limits" />;
}

Expand Down
Loading