Skip to content

feat(Tenants): add network column #2478

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
merged 1 commit into from
Jun 30, 2025
Merged
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
47 changes: 44 additions & 3 deletions src/containers/Tenants/Tenants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,26 @@ import {setSearchValue, tenantsApi} from '../../store/reducers/tenants/tenants';
import type {PreparedTenant} from '../../store/reducers/tenants/types';
import type {AdditionalTenantsProps} from '../../types/additionalProps';
import {uiFactory} from '../../uiFactory/uiFactory';
import {formatBytes} from '../../utils/bytesParsers';
import {cn} from '../../utils/cn';
import {DEFAULT_TABLE_SETTINGS} from '../../utils/constants';
import {
DEFAULT_TABLE_SETTINGS,
EMPTY_DATA_PLACEHOLDER,
SHOW_NETWORK_UTILIZATION,
} from '../../utils/constants';
import {
formatCPU,
formatNumber,
formatStorageValuesToGb,
} from '../../utils/dataFormatters/dataFormatters';
import {useAutoRefreshInterval, useTypedDispatch, useTypedSelector} from '../../utils/hooks';
import {
useAutoRefreshInterval,
useSetting,
useTypedDispatch,
useTypedSelector,
} from '../../utils/hooks';
import {useClusterNameFromQuery} from '../../utils/hooks/useDatabaseFromQuery';
import {isNumeric} from '../../utils/utils';

import i18n from './i18n';

Expand Down Expand Up @@ -84,6 +95,8 @@ export const Tenants = ({additionalTenantsProps, scrollContainerRef}: TenantsPro
const filteredTenants = useTypedSelector((state) => selectFilteredTenants(state, clusterName));
const problemFilter = useTypedSelector(selectProblemFilter);

const [showNetworkUtilization] = useSetting<boolean>(SHOW_NETWORK_UTILIZATION);

const handleProblemFilterChange = (value: ProblemFilterValue) => {
dispatch(changeFilter(value));
};
Expand Down Expand Up @@ -214,6 +227,34 @@ export const Tenants = ({additionalTenantsProps, scrollContainerRef}: TenantsPro
align: DataTable.RIGHT,
defaultOrder: DataTable.DESCENDING,
},
];

if (showNetworkUtilization) {
columns.push({
name: 'Network',
header: 'Network',
width: 120,
align: DataTable.RIGHT,
defaultOrder: DataTable.DESCENDING,
Copy link
Preview

Copilot AI Jun 30, 2025

Choose a reason for hiding this comment

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

[nitpick] Consider adding a brief comment here to clarify why NetworkWriteThroughput defaults to 0 to improve code readability.

Suggested change
defaultOrder: DataTable.DESCENDING,
defaultOrder: DataTable.DESCENDING,
// Defaulting NetworkWriteThroughput to 0 to represent missing data or no network activity.

Copilot uses AI. Check for mistakes.

sortAccessor: ({NetworkWriteThroughput = 0}) => Number(NetworkWriteThroughput),
render: ({row}) => {
const {NetworkWriteThroughput} = row;

if (!isNumeric(NetworkWriteThroughput)) {
return EMPTY_DATA_PLACEHOLDER;
}

return formatBytes({
value: NetworkWriteThroughput,
size: 'mb',
withSpeedLabel: true,
precision: 2,
});
},
});
}

columns.push(
{
name: 'nodesCount',
header: 'Nodes',
Expand Down Expand Up @@ -241,7 +282,7 @@ export const Tenants = ({additionalTenantsProps, scrollContainerRef}: TenantsPro
align: DataTable.LEFT,
render: ({row}) => <PoolsGraph pools={row.PoolStats} />,
},
];
);

if (clusterName && (isDeleteDBAvailable || isEditDBAvailable)) {
const actionsColumn = getDBActionsColumn({
Expand Down
Loading