-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1674 from bipuladh/udpates
Adds progress component for storage quota utilization
- Loading branch information
Showing
2 changed files
with
42 additions
and
2 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
packages/odf/components/storage-consumers/QuotaUtilizationProgress.tsx
This file contains 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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import * as React from 'react'; | ||
import * as _ from 'lodash-es'; | ||
import { | ||
Progress, | ||
ProgressMeasureLocation, | ||
ProgressVariant, | ||
} from '@patternfly/react-core'; | ||
|
||
type StorageQuotaUtilizationProps = { | ||
storageQuota: number; | ||
quotaUtilizationRatio: number; | ||
}; | ||
|
||
export const StorageQuotaUtilizationProgress: React.FC<StorageQuotaUtilizationProps> = | ||
({ storageQuota, quotaUtilizationRatio }) => { | ||
const usagePercentage = quotaUtilizationRatio * 100; | ||
const usedAmount = storageQuota * quotaUtilizationRatio; | ||
const variant = usagePercentage > 80 ? ProgressVariant.warning : undefined; | ||
const isValid = | ||
_.isNumber(storageQuota) && _.isNumber(quotaUtilizationRatio); | ||
return isValid ? ( | ||
<Progress | ||
value={usedAmount} | ||
measureLocation={ProgressMeasureLocation.inside} | ||
variant={variant} | ||
max={storageQuota} | ||
size="sm" | ||
/> | ||
) : ( | ||
<>-</> | ||
); | ||
}; |
This file contains 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