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
21 changes: 19 additions & 2 deletions src/containers/Tenants/Tenants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import {
import {setSearchValue, tenantsApi} from '../../store/reducers/tenants/tenants';
import type {PreparedTenant} from '../../store/reducers/tenants/types';
import type {AdditionalTenantsProps} from '../../types/additionalProps';
import {State} from '../../types/api/tenant';
import {uiFactory} from '../../uiFactory/uiFactory';
import {formatBytes} from '../../utils/bytesParsers';
import {cn} from '../../utils/cn';
Expand Down Expand Up @@ -65,6 +66,23 @@ const b = cn('tenants');

const DATABASES_COLUMNS_WIDTH_LS_KEY = 'databasesTableColumnsWidth';

function formatDatabaseState(state?: State): string {
if (!state) {
return EMPTY_DATA_PLACEHOLDER;
}

// Map specific state values to user-friendly display names
switch (state) {
case State.STATE_UNSPECIFIED:
return 'Unspecified';
case State.PENDING_RESOURCES:
return 'Pending';
default:
// For other states, use capitalized version (first letter uppercase, rest lowercase)
return state.charAt(0).toUpperCase() + state.slice(1).toLowerCase();
}
}

interface TenantsProps {
scrollContainerRef: React.RefObject<HTMLElement>;
additionalTenantsProps?: AdditionalTenantsProps;
Expand Down Expand Up @@ -195,8 +213,7 @@ export const Tenants = ({additionalTenantsProps, scrollContainerRef}: TenantsPro
{
name: 'State',
width: 150,
render: ({row}) => (row.State ? row.State.toLowerCase() : EMPTY_DATA_PLACEHOLDER),
customStyle: () => ({textTransform: 'capitalize'}),
render: ({row}) => formatDatabaseState(row.State),
},
{
name: 'cpu',
Expand Down
11 changes: 4 additions & 7 deletions src/utils/yaMetrica.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ import {uiFactory} from '../uiFactory/uiFactory';

/**
* Interface for a counter that provides methods for tracking metrics.
*
* @method hit - Tracks a hit event with optional arguments. https://yandex.ru/support/metrica/ru/objects/hit
* @method params - Sets parameters for the counter with optional arguments. https://yandex.ru/support/metrica/ru/objects/params-method
* @method userParams - Sets user-specific parameters for the counter with optional arguments. https://yandex.ru/support/metrica/ru/objects/user-params
* @method reachGoal - Tracks a goal achievement event with optional arguments. https://yandex.ru/support/metrica/ru/objects/reachgoal
* @function hit - Tracks a hit event with optional arguments. https://yandex.ru/support/metrica/ru/objects/hit
* @function params - Sets parameters for the counter with optional arguments. https://yandex.ru/support/metrica/ru/objects/params-method
* @function userParams - Sets user-specific parameters for the counter with optional arguments. https://yandex.ru/support/metrica/ru/objects/user-params
* @function reachGoal - Tracks a goal achievement event with optional arguments. https://yandex.ru/support/metrica/ru/objects/reachgoal
*/
export interface Counter {
hit: (...args: unknown[]) => void;
Expand All @@ -21,7 +20,6 @@ const yaMetricaMap = uiFactory.yaMetricaMap;
* A fake implementation of a counter metric for Yandex.Metrica.
* This class is used when the actual Yandex.Metrica counter is not defined,
* and it provides a warning message the first time any of its methods are called.
*
* @property name - The name of the counter.
* @property warnShown - Flag to indicate if the warning has been shown.
*/
Expand Down Expand Up @@ -61,7 +59,6 @@ class FakeMetrica implements Counter {
/**
* Retrieves a Yandex Metrica instance by name from the global window object.
* If no instance is found for the given name, returns a FakeMetrica instance instead.
*
* @param name The name of the metrica to retrieve
* @returns The Yandex Metrica instance if found, otherwise a FakeMetrica instance
*/
Expand Down
Loading