Skip to content

Commit 1ca2e2b

Browse files
feat: support system view
1 parent 0544125 commit 1ca2e2b

File tree

13 files changed

+130
-3
lines changed

13 files changed

+130
-3
lines changed

src/containers/Tenant/Diagnostics/DiagnosticsPages.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ const SERVERLESS_DATABASE_PAGES = [
141141

142142
const TABLE_PAGES = [overview, schema, topShards, nodes, graph, tablets, hotKeys, describe, access];
143143
const COLUMN_TABLE_PAGES = [overview, schema, topShards, nodes, tablets, describe, access];
144+
const SYSTEM_VIEW_PAGES = [overview, schema, nodes, describe, access];
144145

145146
const DIR_PAGES = [overview, topShards, nodes, describe, access];
146147

@@ -164,6 +165,7 @@ const pathTypeToPages: Record<EPathType, Page[] | undefined> = {
164165

165166
[EPathType.EPathTypeTable]: TABLE_PAGES,
166167
[EPathType.EPathTypeColumnTable]: COLUMN_TABLE_PAGES,
168+
[EPathType.EPathTypeSysView]: SYSTEM_VIEW_PAGES,
167169

168170
[EPathType.EPathTypeDir]: DIR_PAGES,
169171
[EPathType.EPathTypeTableIndex]: DIR_PAGES,

src/containers/Tenant/Diagnostics/Overview/Overview.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {EPathType} from '../../../../types/api/schema';
88
import {useAutoRefreshInterval} from '../../../../utils/hooks';
99
import {ExternalDataSourceInfo} from '../../Info/ExternalDataSource/ExternalDataSource';
1010
import {ExternalTableInfo} from '../../Info/ExternalTable/ExternalTable';
11+
import {SystemViewInfo} from '../../Info/SystemView/SystemView';
1112
import {ViewInfo} from '../../Info/View/View';
1213

1314
import {AsyncReplicationInfo} from './AsyncReplicationInfo';
@@ -42,6 +43,7 @@ function Overview({type, path, database, databaseFullPath}: OverviewProps) {
4243
[EPathType.EPathTypeDir]: undefined,
4344
[EPathType.EPathTypeResourcePool]: undefined,
4445
[EPathType.EPathTypeTable]: undefined,
46+
[EPathType.EPathTypeSysView]: () => <SystemViewInfo data={data} />,
4547
[EPathType.EPathTypeSubDomain]: undefined,
4648
[EPathType.EPathTypeTableIndex]: () => <TableIndexInfo data={data} />,
4749
[EPathType.EPathTypeExtSubDomain]: undefined,
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import type {YDBDefinitionListItem} from '../../../../components/YDBDefinitionList/YDBDefinitionList';
2+
import {YDBDefinitionList} from '../../../../components/YDBDefinitionList/YDBDefinitionList';
3+
import type {TEvDescribeSchemeResult} from '../../../../types/api/schema';
4+
import {prepareSystemViewType} from '../../../../utils/schema';
5+
import {getEntityName} from '../../utils';
6+
import i18n from '../i18n';
7+
8+
const prepareSystemViewItems = (data: TEvDescribeSchemeResult): YDBDefinitionListItem[] => {
9+
const systemViewType = data.PathDescription?.SysViewDescription?.Type;
10+
11+
return [
12+
{
13+
name: i18n('system-view_type'),
14+
content: prepareSystemViewType(systemViewType),
15+
},
16+
];
17+
};
18+
19+
interface SystemViewInfoProps {
20+
data?: TEvDescribeSchemeResult;
21+
}
22+
23+
export function SystemViewInfo({data}: SystemViewInfoProps) {
24+
const entityName = getEntityName(data?.PathDescription);
25+
26+
if (!data) {
27+
return <div className="error">{i18n('no-entity-data', {entityName})}</div>;
28+
}
29+
30+
const items = prepareSystemViewItems(data);
31+
32+
return <YDBDefinitionList title={entityName} items={items} />;
33+
}

src/containers/Tenant/Info/i18n/en.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,9 @@
66
"external-objects.auth-method.none": "None",
77
"external-objects.auth-method.service-account": "Service Account",
88

9-
"view.query-text": "Query Text"
9+
"view.query-text": "Query Text",
10+
11+
"system-view_type": "System view type",
12+
13+
"no-entity-data": "No {{entityName}} data"
1014
}

src/containers/Tenant/ObjectSummary/ObjectSummary.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import {
3232
formatSecondsToHours,
3333
} from '../../../utils/dataFormatters/dataFormatters';
3434
import {useTypedDispatch, useTypedSelector} from '../../../utils/hooks';
35+
import {prepareSystemViewType} from '../../../utils/schema';
3536
import {EntityTitle} from '../EntityTitle/EntityTitle';
3637
import {SchemaViewer} from '../Schema/SchemaViewer/SchemaViewer';
3738
import {useCurrentSchema} from '../TenantContext';
@@ -233,6 +234,12 @@ export function ObjectSummary({
233234
content: PathDescription?.TablePartitions?.length,
234235
},
235236
],
237+
[EPathType.EPathTypeSysView]: () => [
238+
{
239+
name: i18n('field_system-view-type'),
240+
content: prepareSystemViewType(PathDescription?.SysViewDescription?.Type),
241+
},
242+
],
236243
[EPathType.EPathTypeSubDomain]: getDatabaseOverview,
237244
[EPathType.EPathTypeTableIndex]: undefined,
238245
[EPathType.EPathTypeExtSubDomain]: getDatabaseOverview,

src/containers/Tenant/ObjectSummary/i18n/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"field_data-size": "Data size",
1313
"field_row-count": "Row count",
1414
"field_partitions": "Partitions count",
15+
"field_system-view-type": "System view type",
1516
"field_paths": "Paths",
1617
"field_shards": "Shards",
1718
"field_state": "State",

src/containers/Tenant/Schema/SchemaViewer/SchemaViewer.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
isColumnEntityType,
1212
isExternalTableType,
1313
isRowTableType,
14+
isSystemViewType,
1415
isViewType,
1516
} from '../../utils/schema';
1617

@@ -20,6 +21,7 @@ import {
2021
getColumnTableColumns,
2122
getExternalTableColumns,
2223
getRowTableColumns,
24+
getSystemViewColumns,
2325
getViewColumns,
2426
} from './columns';
2527
import {prepareSchemaData, prepareViewSchema} from './prepareData';
@@ -82,6 +84,9 @@ export const SchemaViewer = ({
8284
if (isViewType(type)) {
8385
return getViewColumns(tableData);
8486
}
87+
if (isSystemViewType(type)) {
88+
return getSystemViewColumns(tableData);
89+
}
8590
if (isExternalTableType(type)) {
8691
return getExternalTableColumns(tableData);
8792
}

src/containers/Tenant/Schema/SchemaViewer/columns.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,9 @@ function normalizeColumns(columns: SchemaColumn[], data?: SchemaData[]) {
146146
export function getViewColumns(data?: SchemaData[]): SchemaColumn[] {
147147
return normalizeColumns([nameColumn, typeColumn], data);
148148
}
149+
export function getSystemViewColumns(data?: SchemaData[]): SchemaColumn[] {
150+
return normalizeColumns([idColumn, nameColumn, typeColumn, notNullColumn], data);
151+
}
149152
export function getExternalTableColumns(data?: SchemaData[]): SchemaColumn[] {
150153
return normalizeColumns([idColumn, nameColumn, typeColumn, notNullColumn], data);
151154
}

src/containers/Tenant/Schema/SchemaViewer/prepareData.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@ import type {
99
} from '../../../../types/api/schema';
1010
import {EColumnCodec} from '../../../../types/api/schema';
1111
import type {Nullable} from '../../../../utils/typecheckers';
12-
import {isColumnEntityType, isExternalTableType, isRowTableType} from '../../utils/schema';
12+
import {
13+
isColumnEntityType,
14+
isExternalTableType,
15+
isRowTableType,
16+
isSystemViewType,
17+
} from '../../utils/schema';
1318

1419
import type {SchemaData} from './types';
1520

@@ -126,7 +131,7 @@ export function prepareSchemaData(
126131
): SchemaData[] {
127132
const {Table, ColumnTableDescription, ExternalTableDescription} = schema?.PathDescription || {};
128133

129-
if (isRowTableType(type)) {
134+
if (isRowTableType(type) || isSystemViewType(type)) {
130135
return prepareRowTableSchema(Table);
131136
} else if (isColumnEntityType(type)) {
132137
return prepareColumnTableSchema(ColumnTableDescription);

src/containers/Tenant/utils/schema.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ const pathTypeToNodeType: Record<EPathType, NavigationTreeNodeType | undefined>
2525
[EPathType.EPathTypeColumnStore]: 'directory',
2626

2727
[EPathType.EPathTypeTable]: 'table',
28+
[EPathType.EPathTypeSysView]: 'system_table',
2829

2930
[EPathType.EPathTypeTableIndex]: 'index',
3031

@@ -76,6 +77,7 @@ const pathTypeToEntityName: Record<EPathType, string | undefined> = {
7677

7778
[EPathType.EPathTypeDir]: 'Directory',
7879
[EPathType.EPathTypeTable]: 'Table',
80+
[EPathType.EPathTypeSysView]: 'System view',
7981
[EPathType.EPathTypeTableIndex]: 'Secondary Index',
8082
[EPathType.EPathTypeColumnStore]: 'Tablestore',
8183
[EPathType.EPathTypeColumnTable]: 'Column-oriented table',
@@ -115,6 +117,7 @@ export const mapDatabaseTypeToDBName = (type?: ETenantType) => type && databaseT
115117
const pathTypeToIsTable: Record<EPathType, boolean> = {
116118
[EPathType.EPathTypeTable]: true,
117119
[EPathType.EPathTypeColumnTable]: true,
120+
[EPathType.EPathTypeSysView]: true,
118121

119122
[EPathType.EPathTypeExternalTable]: true,
120123

@@ -160,6 +163,7 @@ const pathTypeToIsColumn: Record<EPathType, boolean> = {
160163
[EPathType.EPathTypeInvalid]: false,
161164
[EPathType.EPathTypeDir]: false,
162165
[EPathType.EPathTypeTable]: false,
166+
[EPathType.EPathTypeSysView]: false,
163167
[EPathType.EPathTypeSubDomain]: false,
164168
[EPathType.EPathTypeTableIndex]: false,
165169
[EPathType.EPathTypeExtSubDomain]: false,
@@ -189,6 +193,7 @@ const pathTypeToIsDatabase: Record<EPathType, boolean> = {
189193
[EPathType.EPathTypeColumnStore]: false,
190194
[EPathType.EPathTypeColumnTable]: false,
191195
[EPathType.EPathTypeTable]: false,
196+
[EPathType.EPathTypeSysView]: false,
192197
[EPathType.EPathTypeTableIndex]: false,
193198
[EPathType.EPathTypeCdcStream]: false,
194199
[EPathType.EPathTypePersQueueGroup]: false,
@@ -240,6 +245,7 @@ const pathTypeToChildless: Record<EPathType, boolean> = {
240245
[EPathType.EPathTypeColumnTable]: false,
241246
[EPathType.EPathTypeDir]: false,
242247
[EPathType.EPathTypeTable]: false,
248+
[EPathType.EPathTypeSysView]: false,
243249
[EPathType.EPathTypeSubDomain]: false,
244250
[EPathType.EPathTypeTableIndex]: false,
245251
[EPathType.EPathTypeExtSubDomain]: false,
@@ -253,3 +259,4 @@ export const isChildlessPathType = (type?: EPathType, subType?: EPathSubType) =>
253259
export const isExternalTableType = (type?: EPathType) => type === EPathType.EPathTypeExternalTable;
254260
export const isRowTableType = (type?: EPathType) => type === EPathType.EPathTypeTable;
255261
export const isViewType = (type?: EPathType) => type === EPathType.EPathTypeView;
262+
export const isSystemViewType = (type?: EPathType) => type === EPathType.EPathTypeSysView;

0 commit comments

Comments
 (0)