- Notifications
You must be signed in to change notification settings - Fork1k
feat(site): show license utilization in general settings#15683
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
592657a
4f077c0
2e2bfb7
46f19c6
8d98a97
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
@@ -42,6 +42,7 @@ const meta: Meta<typeof GeneralSettingsPageView> = { | ||||
deploymentDAUs: MockDeploymentDAUResponse, | ||||
invalidExperiments: [], | ||||
safeExperiments: [], | ||||
entitlements: undefined, | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Suggested change
| ||||
}, | ||||
}; | ||||
@@ -136,3 +137,74 @@ export const invalidExperimentsEnabled: Story = { | ||||
invalidExperiments: ["invalid"], | ||||
}, | ||||
}; | ||||
export const WithLicenseUtilization: Story = { | ||||
args: { | ||||
entitlements: { | ||||
...MockEntitlementsWithUserLimit, | ||||
features: { | ||||
...MockEntitlementsWithUserLimit.features, | ||||
user_limit: { | ||||
...MockEntitlementsWithUserLimit.features.user_limit, | ||||
enabled: true, | ||||
actual: 75, | ||||
limit: 100, | ||||
entitlement: "entitled", | ||||
}, | ||||
}, | ||||
}, | ||||
}, | ||||
}; | ||||
export const HighLicenseUtilization: Story = { | ||||
args: { | ||||
entitlements: { | ||||
...MockEntitlementsWithUserLimit, | ||||
features: { | ||||
...MockEntitlementsWithUserLimit.features, | ||||
user_limit: { | ||||
...MockEntitlementsWithUserLimit.features.user_limit, | ||||
enabled: true, | ||||
actual: 95, | ||||
limit: 100, | ||||
entitlement: "entitled", | ||||
}, | ||||
}, | ||||
}, | ||||
}, | ||||
}; | ||||
SasSwart marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||||
export const ExceedsLicenseUtilization: Story = { | ||||
args: { | ||||
entitlements: { | ||||
...MockEntitlementsWithUserLimit, | ||||
features: { | ||||
...MockEntitlementsWithUserLimit.features, | ||||
user_limit: { | ||||
...MockEntitlementsWithUserLimit.features.user_limit, | ||||
enabled: true, | ||||
actual: 100, | ||||
limit: 95, | ||||
entitlement: "entitled", | ||||
}, | ||||
}, | ||||
}, | ||||
}, | ||||
}; | ||||
export const NoLicenseLimit: Story = { | ||||
args: { | ||||
entitlements: { | ||||
...MockEntitlementsWithUserLimit, | ||||
features: { | ||||
...MockEntitlementsWithUserLimit.features, | ||||
user_limit: { | ||||
...MockEntitlementsWithUserLimit.features.user_limit, | ||||
enabled: false, | ||||
actual: 0, | ||||
limit: 0, | ||||
entitlement: "entitled", | ||||
}, | ||||
}, | ||||
}, | ||||
}, | ||||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import AlertTitle from "@mui/material/AlertTitle"; | ||
import LinearProgress from "@mui/material/LinearProgress"; | ||
import type { | ||
DAUsResponse, | ||
Entitlements, | ||
@@ -36,6 +37,12 @@ export const GeneralSettingsPageView: FC<GeneralSettingsPageViewProps> = ({ | ||
safeExperiments, | ||
invalidExperiments, | ||
}) => { | ||
const licenseUtilizationPercentage = | ||
entitlements?.features?.user_limit?.actual && | ||
entitlements?.features?.user_limit?.limit | ||
? entitlements.features.user_limit.actual / | ||
entitlements.features.user_limit.limit | ||
: undefined; | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Suggestion: Instead of just doing the percentage here, we could prepare the data format in a more convenient way to use in the template: constlicenseInfo=entitlements?.features?.user_limit?.actual&&entitlements?.features?.user_limit?.limit?{valid:true,actual:entitlements.features.user_limit.actual,limit:entitlements.features.user_limit.limit} :{valid:false,actual:0,limit:0,}; Might not need to even init the actual/limit for the zero case but added it just in case. | ||
return ( | ||
<> | ||
<SettingsHeader | ||
@@ -54,6 +61,37 @@ export const GeneralSettingsPageView: FC<GeneralSettingsPageViewProps> = ({ | ||
</ChartSection> | ||
</div> | ||
)} | ||
{licenseUtilizationPercentage && ( | ||
<ChartSection title="License Utilization"> | ||
<LinearProgress | ||
variant="determinate" | ||
value={Math.min(licenseUtilizationPercentage * 100, 100)} | ||
color={ | ||
licenseUtilizationPercentage < 0.9 | ||
? "primary" | ||
: licenseUtilizationPercentage < 1 | ||
? "warning" | ||
: "error" | ||
} | ||
css={{ | ||
height: 24, | ||
borderRadius: 4, | ||
marginBottom: 8, | ||
}} | ||
/> | ||
<span | ||
css={{ | ||
fontSize: "0.75rem", | ||
display: "block", | ||
textAlign: "right", | ||
}} | ||
> | ||
{Math.round(licenseUtilizationPercentage * 100)}% used ( | ||
{entitlements!.features.user_limit.actual}/ | ||
{entitlements!.features.user_limit.limit} users) | ||
</span> | ||
</ChartSection> | ||
)} | ||
{invalidExperiments.length > 0 && ( | ||
<Alert severity="warning"> | ||
<AlertTitle>Invalid experiments in use:</AlertTitle> | ||
Uh oh!
There was an error while loading.Please reload this page.