Skip to content

Commit 5f73eed

Browse files
fix(TenantOverview): display database type in title
1 parent f009f3d commit 5f73eed

File tree

3 files changed

+52
-4
lines changed

3 files changed

+52
-4
lines changed

src/containers/Tenant/Diagnostics/TenantOverview/TenantOverview.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React from 'react';
22
import {connect} from 'react-redux';
33
import cn from 'bem-cn-lite';
44
import PropTypes from 'prop-types';
5+
import {Loader} from '@gravity-ui/uikit';
56

67
import EntityStatus from '../../../../components/EntityStatus/EntityStatus';
78
import InfoViewer from '../../../../components/InfoViewer/InfoViewer';
@@ -14,10 +15,11 @@ import {getTenantInfo} from '../../../../store/reducers/tenant';
1415
import {formatCPU} from '../../../../utils';
1516
import {bytesToGB} from '../../../../utils/utils';
1617
import {TABLET_STATES} from '../../../../utils/constants';
18+
import {AutoFetcher} from '../../../../utils/autofetcher';
19+
20+
import {mapDatabaseTypeToDBName} from '../../utils/schema';
1721

1822
import './TenantOverview.scss';
19-
import {AutoFetcher} from '../../../../utils/autofetcher';
20-
import {Loader} from '@gravity-ui/uikit';
2123

2224
const b = cn('tenant-overview');
2325

@@ -113,6 +115,7 @@ class TenantOverview extends React.Component {
113115
SystemTablets,
114116
} = tenant;
115117

118+
const tenantName = mapDatabaseTypeToDBName(Type);
116119
const memoryRaw = MemoryUsed ?? Metrics.Memory;
117120

118121
const memory = (memoryRaw && bytesToGB(memoryRaw)) || 'no data';
@@ -147,7 +150,7 @@ class TenantOverview extends React.Component {
147150
this.renderLoader()
148151
) : (
149152
<div className={b()}>
150-
<div className={b('top-label')}>Database</div>
153+
<div className={b('top-label')}>{tenantName}</div>
151154
<div className={b('top')}>
152155
{renderName(tenant)}
153156
{this.props.additionalTenantInfo &&

src/containers/Tenant/Tenant.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ function Tenant(props: TenantProps) {
9090

9191
useEffect(() => {
9292
dispatch(disableAutorefresh());
93-
}, [currentSchemaPath, tenantName]);
93+
}, [currentSchemaPath, tenantName, dispatch]);
9494

9595
useEffect(() => {
9696
if (tenantName) {

src/containers/Tenant/utils/schema.ts

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import type {NavigationTreeNodeType} from 'ydb-ui-components';
2+
23
import {EPathSubType, EPathType} from '../../../types/api/schema';
4+
import {ETenantType} from '../../../types/api/tenant';
35

46
// this file contains verbose mappings that are typed in a way that ensures
57
// correctness when a new node type or a new path type is added
@@ -41,6 +43,49 @@ export const mapPathTypeToNavigationTreeType = (
4143

4244
// ====================
4345

46+
const pathSubTypeToEntityName: Record<EPathSubType, string | undefined> = {
47+
[EPathSubType.EPathSubTypeSyncIndexImplTable]: 'Secondary Index Table',
48+
[EPathSubType.EPathSubTypeAsyncIndexImplTable]: 'Secondary Index Table',
49+
50+
[EPathSubType.EPathSubTypeStreamImpl]: undefined,
51+
[EPathSubType.EPathSubTypeEmpty]: undefined,
52+
};
53+
54+
const pathTypeToEntityName: Record<EPathType, string | undefined> = {
55+
[EPathType.EPathTypeInvalid]: undefined,
56+
57+
[EPathType.EPathTypeSubDomain]: 'Database',
58+
[EPathType.EPathTypeExtSubDomain]: 'Database',
59+
60+
[EPathType.EPathTypeDir]: 'Directory',
61+
[EPathType.EPathTypeTable]: 'Table',
62+
[EPathType.EPathTypeTableIndex]: 'Secondary Index',
63+
[EPathType.EPathTypeColumnStore]: 'Tablestore',
64+
[EPathType.EPathTypeColumnTable]: 'Columntable',
65+
[EPathType.EPathTypeCdcStream]: 'Changefeed',
66+
[EPathType.EPathTypePersQueueGroup]: 'Topic',
67+
};
68+
69+
export const mapPathTypeToEntityName = (
70+
type?: EPathType,
71+
subType?: EPathSubType,
72+
): string | undefined =>
73+
(subType && pathSubTypeToEntityName[subType]) || (type && pathTypeToEntityName[type]);
74+
75+
// ====================
76+
77+
const databaseTypeToDBName: Record<ETenantType, string | undefined> = {
78+
[ETenantType.UnknownTenantType]: 'Database',
79+
[ETenantType.Domain]: 'Cluster Root',
80+
[ETenantType.Dedicated]: 'Dedicated Database',
81+
[ETenantType.Shared]: 'Shared Database',
82+
[ETenantType.Serverless]: 'Serverless Database',
83+
};
84+
85+
export const mapDatabaseTypeToDBName = (type?: ETenantType) => type && databaseTypeToDBName[type];
86+
87+
// ====================
88+
4489
const pathTypeToIsTable: Record<EPathType, boolean> = {
4590
[EPathType.EPathTypeTable]: true,
4691
[EPathType.EPathTypeColumnTable]: true,

0 commit comments

Comments
 (0)