Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ interface MetricsTabsProps {
blobStorageStats?: TenantStorageStats[];
tabletStorageStats?: TenantStorageStats[];
networkStats?: TenantMetricStats[];
storageGroupsCount?: number;
}

export function MetricsTabs({
Expand All @@ -40,6 +41,7 @@ export function MetricsTabs({
blobStorageStats,
tabletStorageStats,
networkStats,
storageGroupsCount,
}: MetricsTabsProps) {
const location = useLocation();
const {metricsTab} = useTypedSelector((state) => state.tenant);
Expand Down Expand Up @@ -73,7 +75,6 @@ export function MetricsTabs({
// Calculate storage metrics using utility
const storageStats = tabletStorageStats || blobStorageStats || [];
const storageMetrics = calculateMetricAggregates(storageStats);
const storageGroupCount = storageStats.length;

// Calculate memory metrics using utility
const memoryMetrics = calculateMetricAggregates(memoryStats);
Expand All @@ -91,8 +92,7 @@ export function MetricsTabs({
>
<Link to={tabLinks.cpu} className={b('link')}>
<TabCard
label={i18n('cards.cpu-label')}
sublabel={i18n('context_cpu-load')}
text={i18n('context_cpu-load')}
value={cpuMetrics.totalUsed}
limit={cpuMetrics.totalLimit}
legendFormatter={formatCoresLegend}
Expand All @@ -108,8 +108,11 @@ export function MetricsTabs({
>
<Link to={tabLinks.storage} className={b('link')}>
<TabCard
label={i18n('cards.storage-label')}
sublabel={i18n('context_storage-groups', {count: storageGroupCount})}
text={
storageGroupsCount === undefined
? i18n('cards.storage-label')
: i18n('context_storage-groups', {count: storageGroupsCount})
}
value={storageMetrics.totalUsed}
limit={storageMetrics.totalLimit}
legendFormatter={formatStorageLegend}
Expand All @@ -125,8 +128,7 @@ export function MetricsTabs({
>
<Link to={tabLinks.memory} className={b('link')}>
<TabCard
label={i18n('cards.memory-label')}
sublabel={i18n('context_memory-used')}
text={i18n('context_memory-used')}
value={memoryMetrics.totalUsed}
limit={memoryMetrics.totalLimit}
legendFormatter={formatStorageLegend}
Expand All @@ -143,8 +145,7 @@ export function MetricsTabs({
>
<Link to={tabLinks.network} className={b('link')}>
<TabCard
label={i18n('cards.network-label')}
sublabel={i18n('context_network-usage')}
text={i18n('context_network-usage')}
value={networkMetrics.totalUsed}
limit={networkMetrics.totalLimit}
legendFormatter={formatSpeedLegend}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,15 @@ import './TabCard.scss';
const b = cn('tenant-tab-card');

interface TabCardProps {
label: string;
sublabel?: string;
text: string;
value: number;
limit: number;
active?: boolean;
helpText?: string;
legendFormatter: (params: {value: number; capacity: number}) => string;
}

export function TabCard({
label,
sublabel,
value,
limit,
active,
helpText,
legendFormatter,
}: TabCardProps) {
export function TabCard({text, value, limit, active, helpText, legendFormatter}: TabCardProps) {
const {status, percents, legend, fill} = getDiagramValues({
value,
capacity: limit,
Expand Down Expand Up @@ -61,7 +52,7 @@ export function TabCard({
note={helpText}
noteIconSize="s"
>
{sublabel || label}
{text}
</DoughnutMetrics.Legend>
</div>
</Flex>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,11 @@ export function TenantOverview({
blobStorageStats={blobStorageStats}
tabletStorageStats={tabletStorageStats}
networkStats={networkStats}
storageGroupsCount={
tenantData.StorageGroups
Copy link

Copilot AI Aug 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using Number() constructor without validation could cause issues if tenantData.StorageGroups contains non-numeric values. Consider using parseInt() with explicit base or adding validation to ensure the value is numeric before conversion.

Suggested change
tenantData.StorageGroups
tenantData.StorageGroups &&
!isNaN(Number(tenantData.StorageGroups))

Copilot uses AI. Check for mistakes.

? Number(tenantData.StorageGroups)
: undefined
}
/>
</Flex>
</div>
Expand Down
Loading