-
Notifications
You must be signed in to change notification settings - Fork 875
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
592657a
Show license utilization in general settings
SasSwart 4f077c0
Show license utilization in general settings
SasSwart 2e2bfb7
allow license utilization to render gracefully when a user exceeds th…
SasSwart 46f19c6
make fmt
SasSwart 8d98a97
Update site/src/pages/DeploymentSettingsPage/GeneralSettingsPage/Gene…
SasSwart File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
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: const licenseInfo =
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={(licenseUtilizationPercentage % 1) * 100} | ||
SasSwart marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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> | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
undefined
is JavaScript's equivalent to a zero value, this doesn't do anything