Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bf74f8b

Browse files
SasSwartaslilac
authored andcommitted
feat(site): show license utilization in general settings (#15683)
This PR is the first iteration towards #15297 We cannot yet show license utilization over time, so we show current license utilization. This is because we don't track user states over time. We only track the current user state. A graph over time filtering by active users would therefore not account for day to day changes in user state and be inaccurate. DB schema migrations and related updates will follow that allow us to show license utilization over time. ![image](https://github.com/user-attachments/assets/91bd6e8c-e74c-4ef5-aa6b-271fd245da37) --------- Co-authored-by: ケイラ <[email protected]> (cherry picked from commit 7e1ac2e)
1 parent 12c4bb5 commit bf74f8b

File tree

2 files changed

+110
-0
lines changed

2 files changed

+110
-0
lines changed

site/src/pages/DeploymentSettingsPage/GeneralSettingsPage/GeneralSettingsPageView.stories.tsx

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ const meta: Meta<typeof GeneralSettingsPageView> = {
4242
deploymentDAUs: MockDeploymentDAUResponse,
4343
invalidExperiments: [],
4444
safeExperiments: [],
45+
entitlements: undefined,
4546
},
4647
};
4748

@@ -136,3 +137,74 @@ export const invalidExperimentsEnabled: Story = {
136137
invalidExperiments: ["invalid"],
137138
},
138139
};
140+
141+
export const WithLicenseUtilization: Story = {
142+
args: {
143+
entitlements: {
144+
...MockEntitlementsWithUserLimit,
145+
features: {
146+
...MockEntitlementsWithUserLimit.features,
147+
user_limit: {
148+
...MockEntitlementsWithUserLimit.features.user_limit,
149+
enabled: true,
150+
actual: 75,
151+
limit: 100,
152+
entitlement: "entitled",
153+
},
154+
},
155+
},
156+
},
157+
};
158+
159+
export const HighLicenseUtilization: Story = {
160+
args: {
161+
entitlements: {
162+
...MockEntitlementsWithUserLimit,
163+
features: {
164+
...MockEntitlementsWithUserLimit.features,
165+
user_limit: {
166+
...MockEntitlementsWithUserLimit.features.user_limit,
167+
enabled: true,
168+
actual: 95,
169+
limit: 100,
170+
entitlement: "entitled",
171+
},
172+
},
173+
},
174+
},
175+
};
176+
177+
export const ExceedsLicenseUtilization: Story = {
178+
args: {
179+
entitlements: {
180+
...MockEntitlementsWithUserLimit,
181+
features: {
182+
...MockEntitlementsWithUserLimit.features,
183+
user_limit: {
184+
...MockEntitlementsWithUserLimit.features.user_limit,
185+
enabled: true,
186+
actual: 100,
187+
limit: 95,
188+
entitlement: "entitled",
189+
},
190+
},
191+
},
192+
},
193+
};
194+
export const NoLicenseLimit: Story = {
195+
args: {
196+
entitlements: {
197+
...MockEntitlementsWithUserLimit,
198+
features: {
199+
...MockEntitlementsWithUserLimit.features,
200+
user_limit: {
201+
...MockEntitlementsWithUserLimit.features.user_limit,
202+
enabled: false,
203+
actual: 0,
204+
limit: 0,
205+
entitlement: "entitled",
206+
},
207+
},
208+
},
209+
},
210+
};

site/src/pages/DeploymentSettingsPage/GeneralSettingsPage/GeneralSettingsPageView.tsx

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import AlertTitle from "@mui/material/AlertTitle";
2+
import LinearProgress from "@mui/material/LinearProgress";
23
import type {
34
DAUsResponse,
45
Entitlements,
@@ -36,6 +37,12 @@ export const GeneralSettingsPageView: FC<GeneralSettingsPageViewProps> = ({
3637
safeExperiments,
3738
invalidExperiments,
3839
}) => {
40+
const licenseUtilizationPercentage =
41+
entitlements?.features?.user_limit?.actual &&
42+
entitlements?.features?.user_limit?.limit
43+
? entitlements.features.user_limit.actual /
44+
entitlements.features.user_limit.limit
45+
: undefined;
3946
return (
4047
<>
4148
<SettingsHeader
@@ -54,6 +61,37 @@ export const GeneralSettingsPageView: FC<GeneralSettingsPageViewProps> = ({
5461
</ChartSection>
5562
</div>
5663
)}
64+
{licenseUtilizationPercentage && (
65+
<ChartSection title="License Utilization">
66+
<LinearProgress
67+
variant="determinate"
68+
value={Math.min(licenseUtilizationPercentage * 100, 100)}
69+
color={
70+
licenseUtilizationPercentage < 0.9
71+
? "primary"
72+
: licenseUtilizationPercentage < 1
73+
? "warning"
74+
: "error"
75+
}
76+
css={{
77+
height: 24,
78+
borderRadius: 4,
79+
marginBottom: 8,
80+
}}
81+
/>
82+
<span
83+
css={{
84+
fontSize: "0.75rem",
85+
display: "block",
86+
textAlign: "right",
87+
}}
88+
>
89+
{Math.round(licenseUtilizationPercentage * 100)}% used (
90+
{entitlements!.features.user_limit.actual}/
91+
{entitlements!.features.user_limit.limit} users)
92+
</span>
93+
</ChartSection>
94+
)}
5795
{invalidExperiments.length > 0 && (
5896
<Alert severity="warning">
5997
<AlertTitle>Invalid experiments in use:</AlertTitle>

0 commit comments

Comments
 (0)