Skip to content

Commit

Permalink
Merge pull request #1674 from bipuladh/udpates
Browse files Browse the repository at this point in the history
Adds progress component for storage quota utilization
  • Loading branch information
openshift-merge-bot[bot] authored Nov 12, 2024
2 parents 3499600 + 4f56532 commit 117ed21
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
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"
/>
) : (
<>-</>
);
};
12 changes: 10 additions & 2 deletions packages/odf/components/storage-consumers/client-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import {
storageConsumerNameFilter,
} from './list-filter';
import { ClientOnBoardingModal } from './onboarding-modal';
import { StorageQuotaUtilizationProgress } from './QuotaUtilizationProgress';
import { RotateKeysModal } from './rotate-keys-modal';
import './client-list.scss';

Expand Down Expand Up @@ -178,7 +179,7 @@ const ClientsList: React.FC<ClientListProps> = (props) => {
case 'storageQuotaUtilRatio':
column.title = t('Storage quota utilization ratio');
column.sort = 'status.client.storageQuotaUtilization';
column.props.info = { popover: <StorageQuotaPopoverContent /> };
column.transforms = [sortable];
break;
case 'openshiftVersion':
column.title = t('Openshift version');
Expand Down Expand Up @@ -353,7 +354,14 @@ const StorageClientRow: React.FC<
data = humanizedStorageQuota;
break;
case 'storageQuotaUtilRatio':
data = getStorageQuotaUtilizationRatio(obj) || '-';
data = (
<StorageQuotaUtilizationProgress
quotaUtilizationRatio={Number(
getStorageQuotaUtilizationRatio(obj)
)}
storageQuota={obj?.spec?.storageQuotaInGiB}
/>
);
break;
case 'openshiftVersion':
data = getOpenshiftVersion(obj) || '-';
Expand Down

0 comments on commit 117ed21

Please sign in to comment.