Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
18 changes: 16 additions & 2 deletions src/containers/Tenants/Tenants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,21 @@ const b = cn('tenants');

const DATABASES_COLUMNS_WIDTH_LS_KEY = 'databasesTableColumnsWidth';

function formatDatabaseState(state?: string): string {
Copy link
Member

Choose a reason for hiding this comment

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

@copilot

Use State enum as type, transform STATE_UNSPECIFIED to Unspecified

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated the function to use State enum as the type parameter and added transformation for STATE_UNSPECIFIED to "Unspecified". The function now provides better type safety and handles all enum values properly. (15f3f8e)

if (!state) {
return EMPTY_DATA_PLACEHOLDER;
}

// Map specific state values to user-friendly display names
switch (state) {
case 'PENDING_RESOURCES':
return i18n('value_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 +210,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
3 changes: 2 additions & 1 deletion src/containers/Tenants/i18n/en.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"create-database": "Create database",
"remove": "Remove",
"edit": "Edit"
"edit": "Edit",
"value_pending": "Pending"
}
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