Skip to content

chore: add managed ai usage consumption to license view #18934

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Jul 28, 2025
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ const LicensesSettingsPage: FC = () => {
isRemovingLicense={isRemovingLicense}
removeLicense={(licenseId: number) => removeLicenseApi(licenseId)}
activeUsers={userStatusCount?.active}
managedAgentFeature={
entitlementsQuery.data?.features.managed_agent_limit
}
refreshEntitlements={async () => {
try {
await refreshEntitlementsMutation.mutateAsync();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import MuiLink from "@mui/material/Link";
import Skeleton from "@mui/material/Skeleton";
import Tooltip from "@mui/material/Tooltip";
import type { GetLicensesResponse } from "api/api";
import type { UserStatusChangeCount } from "api/typesGenerated";
import type { Feature, UserStatusChangeCount } from "api/typesGenerated";
import { Button } from "components/Button/Button";
import {
SettingsHeader,
Expand All @@ -20,6 +20,7 @@ import Confetti from "react-confetti";
import { Link } from "react-router-dom";
import { LicenseCard } from "./LicenseCard";
import { LicenseSeatConsumptionChart } from "./LicenseSeatConsumptionChart";
import { ManagedAgentsConsumption } from "./ManagedAgentsConsumption";

type Props = {
showConfetti: boolean;
Expand All @@ -32,6 +33,7 @@ type Props = {
removeLicense: (licenseId: number) => void;
refreshEntitlements: () => void;
activeUsers: UserStatusChangeCount[] | undefined;
managedAgentFeature?: Feature;
};

const LicensesSettingsPageView: FC<Props> = ({
Expand All @@ -45,6 +47,7 @@ const LicensesSettingsPageView: FC<Props> = ({
removeLicense,
refreshEntitlements,
activeUsers,
managedAgentFeature,
}) => {
const theme = useTheme();
const { width, height } = useWindowSize();
Expand Down Expand Up @@ -151,6 +154,10 @@ const LicensesSettingsPageView: FC<Props> = ({
}))}
/>
)}

{licenses && licenses.length > 0 && (
<ManagedAgentsConsumption managedAgentFeature={managedAgentFeature} />
)}
</div>
</>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
import type { Meta, StoryObj } from "@storybook/react";
import { ManagedAgentsConsumption } from "./ManagedAgentsConsumption";

const meta: Meta<typeof ManagedAgentsConsumption> = {
title:
"pages/DeploymentSettingsPage/LicensesSettingsPage/ManagedAgentsConsumption",
component: ManagedAgentsConsumption,
args: {
managedAgentFeature: {
enabled: true,
actual: 50000,
soft_limit: 60000,
limit: 120000,
usage_period: {
start: "February 27, 2025",
end: "February 27, 2026",
issued_at: "February 27, 2025",
},
entitlement: "entitled",
},
},
};

export default meta;
type Story = StoryObj<typeof ManagedAgentsConsumption>;

export const Default: Story = {};

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

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

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

export const IncludedAtLimit: Story = {
args: {
managedAgentFeature: {
enabled: true,
actual: 25000,
soft_limit: 30500,
limit: 30500,
usage_period: {
start: "February 27, 2025",
end: "February 27, 2026",
issued_at: "February 27, 2025",
},
entitlement: "entitled",
},
},
};

export const Disabled: Story = {
args: {
managedAgentFeature: {
enabled: false,
actual: undefined,
soft_limit: undefined,
limit: undefined,
usage_period: undefined,
entitlement: "not_entitled",
},
},
};

export const NoFeature: Story = {
args: {
managedAgentFeature: undefined,
},
};

// Error States for Validation
export const ErrorMissingData: Story = {
args: {
managedAgentFeature: {
enabled: true,
actual: undefined,
soft_limit: undefined,
limit: undefined,
usage_period: undefined,
entitlement: "entitled",
},
},
};

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

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

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

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