Skip to content

Commit 7eb1f2f

Browse files
Copilotadameatartemmufazalov
authored
fix(Tenants): format state from Pending_resources to Pending (#2825)
Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: adameat <[email protected]> Co-authored-by: Alexey Efimov <[email protected]> Co-authored-by: artemmufazalov <[email protected]>
1 parent 4146f85 commit 7eb1f2f

File tree

2 files changed

+23
-9
lines changed

2 files changed

+23
-9
lines changed

src/containers/Tenants/Tenants.tsx

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import {
3535
import {setSearchValue, tenantsApi} from '../../store/reducers/tenants/tenants';
3636
import type {PreparedTenant} from '../../store/reducers/tenants/types';
3737
import type {AdditionalTenantsProps} from '../../types/additionalProps';
38+
import {State} from '../../types/api/tenant';
3839
import {uiFactory} from '../../uiFactory/uiFactory';
3940
import {formatBytes} from '../../utils/bytesParsers';
4041
import {cn} from '../../utils/cn';
@@ -65,6 +66,23 @@ const b = cn('tenants');
6566

6667
const DATABASES_COLUMNS_WIDTH_LS_KEY = 'databasesTableColumnsWidth';
6768

69+
function formatDatabaseState(state?: State): string {
70+
if (!state) {
71+
return EMPTY_DATA_PLACEHOLDER;
72+
}
73+
74+
// Map specific state values to user-friendly display names
75+
switch (state) {
76+
case State.STATE_UNSPECIFIED:
77+
return 'Unspecified';
78+
case State.PENDING_RESOURCES:
79+
return 'Pending';
80+
default:
81+
// For other states, use capitalized version (first letter uppercase, rest lowercase)
82+
return state.charAt(0).toUpperCase() + state.slice(1).toLowerCase();
83+
}
84+
}
85+
6886
interface TenantsProps {
6987
scrollContainerRef: React.RefObject<HTMLElement>;
7088
additionalTenantsProps?: AdditionalTenantsProps;
@@ -195,8 +213,7 @@ export const Tenants = ({additionalTenantsProps, scrollContainerRef}: TenantsPro
195213
{
196214
name: 'State',
197215
width: 150,
198-
render: ({row}) => (row.State ? row.State.toLowerCase() : EMPTY_DATA_PLACEHOLDER),
199-
customStyle: () => ({textTransform: 'capitalize'}),
216+
render: ({row}) => formatDatabaseState(row.State),
200217
},
201218
{
202219
name: 'cpu',

src/utils/yaMetrica.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@ import {uiFactory} from '../uiFactory/uiFactory';
22

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

0 commit comments

Comments
 (0)