Skip to content

Commit f0b8ec9

Browse files
committed
fix: review fixes
1 parent 5947cad commit f0b8ec9

File tree

4 files changed

+54
-47
lines changed

4 files changed

+54
-47
lines changed

src/containers/Tenant/Diagnostics/TenantOverview/MetricsTabs/MetricsTabs.scss

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -224,15 +224,3 @@
224224
padding-right: 0;
225225
}
226226
}
227-
228-
// Serverless variant: exactly two tabs (CPU, Storage) at 50% width each
229-
230-
.tenant-metrics-tabs_serverless {
231-
.tenant-metrics-tabs__link-container_placeholder {
232-
pointer-events: none;
233-
234-
.tenant-tab-card__card-container {
235-
opacity: 0;
236-
}
237-
}
238-
}

src/containers/Tenant/Diagnostics/TenantOverview/MetricsTabs/MetricsTabs.tsx

Lines changed: 4 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import type {
1212
TenantStorageStats,
1313
} from '../../../../../store/reducers/tenants/utils';
1414
import {cn} from '../../../../../utils/cn';
15-
import {NON_BREAKING_SPACE, SHOW_NETWORK_UTILIZATION} from '../../../../../utils/constants';
15+
import {SHOW_NETWORK_UTILIZATION} from '../../../../../utils/constants';
1616
import {useSetting, useTypedSelector} from '../../../../../utils/hooks';
1717
import {calculateMetricAggregates} from '../../../../../utils/metrics';
1818
import {
@@ -24,14 +24,12 @@ import {TenantTabsGroups, getTenantPath} from '../../../TenantPages';
2424
import {TabCard} from '../TabCard/TabCard';
2525
import i18n from '../i18n';
2626

27+
import {ServerlessPlaceholderTabs} from './ServerlessPlaceholderTabs';
28+
2729
import './MetricsTabs.scss';
2830

2931
const b = cn('tenant-metrics-tabs');
3032

31-
// Placeholder values used for serverless layout filler cards
32-
const PLACEHOLDER_VALUE = 0;
33-
const PLACEHOLDER_LIMIT = 1;
34-
3533
interface MetricsTabsProps {
3634
poolsCpuStats?: TenantPoolsStats[];
3735
memoryStats?: TenantMetricStats[];
@@ -190,36 +188,7 @@ export function MetricsTabs({
190188
</>
191189
)}
192190

193-
{isServerless && (
194-
<>
195-
<div className={b('link-container', {placeholder: true})}>
196-
<div className={b('link')}>
197-
<TabCard
198-
text={NON_BREAKING_SPACE}
199-
value={PLACEHOLDER_VALUE}
200-
limit={PLACEHOLDER_LIMIT}
201-
legendFormatter={formatCoresLegend}
202-
active={false}
203-
variant={isServerless ? 'serverless' : 'default'}
204-
subtitle={NON_BREAKING_SPACE}
205-
/>
206-
</div>
207-
</div>
208-
<div className={b('link-container', {placeholder: true})}>
209-
<div className={b('link')}>
210-
<TabCard
211-
text={NON_BREAKING_SPACE}
212-
value={PLACEHOLDER_VALUE}
213-
limit={PLACEHOLDER_LIMIT}
214-
legendFormatter={formatCoresLegend}
215-
active={false}
216-
variant={isServerless ? 'serverless' : 'default'}
217-
subtitle={NON_BREAKING_SPACE}
218-
/>
219-
</div>
220-
</div>
221-
</>
222-
)}
191+
{isServerless && <ServerlessPlaceholderTabs />}
223192
</Flex>
224193
);
225194
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.tenant-metrics-tabs_serverless {
2+
pointer-events: none;
3+
4+
.tenant-tab-card__card-container {
5+
opacity: 0;
6+
}
7+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import React from 'react';
2+
3+
import {cn} from '../../../../../utils/cn';
4+
import {NON_BREAKING_SPACE} from '../../../../../utils/constants';
5+
import {formatCoresLegend} from '../../../../../utils/metrics/formatMetricLegend';
6+
import {TabCard} from '../TabCard/TabCard';
7+
8+
import './ServerlessPlaceholderTabs.scss';
9+
10+
const b = cn('tenant-metrics-tabs');
11+
12+
const PLACEHOLDER_VALUE = 0;
13+
const PLACEHOLDER_LIMIT = 1;
14+
15+
interface ServerlessPlaceholderTabsProps {
16+
count?: number;
17+
}
18+
19+
export const ServerlessPlaceholderTabs: React.FC<ServerlessPlaceholderTabsProps> = React.memo(
20+
({count = 2}) => {
21+
const items = React.useMemo(() => Array.from({length: count}, (_, i) => i), [count]);
22+
23+
return (
24+
<>
25+
{items.map((idx) => (
26+
<div key={idx} className={b('link-container', {placeholder: true})}>
27+
<div className={b('link')}>
28+
<TabCard
29+
text={NON_BREAKING_SPACE}
30+
value={PLACEHOLDER_VALUE}
31+
limit={PLACEHOLDER_LIMIT}
32+
legendFormatter={formatCoresLegend}
33+
active={false}
34+
variant="serverless"
35+
subtitle={NON_BREAKING_SPACE}
36+
/>
37+
</div>
38+
</div>
39+
))}
40+
</>
41+
);
42+
},
43+
);

0 commit comments

Comments
 (0)