Skip to content

Commit b4e749a

Browse files
feat: support system view (#2899)
1 parent dc7e723 commit b4e749a

File tree

14 files changed

+175
-21
lines changed

14 files changed

+175
-21
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: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import {Text} from '@gravity-ui/uikit';
2+
3+
import type {YDBDefinitionListItem} from '../../../../components/YDBDefinitionList/YDBDefinitionList';
4+
import {YDBDefinitionList} from '../../../../components/YDBDefinitionList/YDBDefinitionList';
5+
import type {TEvDescribeSchemeResult} from '../../../../types/api/schema';
6+
import {prepareSystemViewType} from '../../../../utils/schema';
7+
import {getEntityName} from '../../utils';
8+
import i18n from '../i18n';
9+
10+
const prepareSystemViewItems = (data: TEvDescribeSchemeResult): YDBDefinitionListItem[] => {
11+
const systemViewType = data.PathDescription?.SysViewDescription?.Type;
12+
13+
return [
14+
{
15+
name: i18n('field_system-view-type'),
16+
content: prepareSystemViewType(systemViewType),
17+
},
18+
];
19+
};
20+
21+
interface SystemViewInfoProps {
22+
data?: TEvDescribeSchemeResult;
23+
}
24+
25+
export function SystemViewInfo({data}: SystemViewInfoProps) {
26+
const entityName = getEntityName(data?.PathDescription);
27+
28+
if (!data) {
29+
return (
30+
<Text variant="body-2" color="danger">
31+
{i18n('no-entity-data', {entityName})}
32+
</Text>
33+
);
34+
}
35+
36+
const items = prepareSystemViewItems(data);
37+
38+
return <YDBDefinitionList title={entityName} items={items} />;
39+
}

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+
"field_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/i18n/en.json

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,5 +68,22 @@
6868
"label_download": "Download healthcheck data",
6969

7070
"label_grant-access": "Grant access",
71-
"context_grant-access": "Please note that granular rights can be combined into groups"
71+
"context_grant-access": "Please note that granular rights can be combined into groups",
72+
73+
"entity-name_database": "Database",
74+
"entity-name_directory": "Directory",
75+
"entity-name_table": "Table",
76+
"entity-name_system-view": "System view",
77+
"entity-name_secondary-index": "Secondary Index",
78+
"entity-name_tablestore": "Tablestore",
79+
"entity-name_column-oriented-table": "Column-oriented table",
80+
"entity-name_changefeed": "Changefeed",
81+
"entity-name_topic": "Topic",
82+
"entity-name_external-data-source": "External Data Source",
83+
"entity-name_external-table": "External Table",
84+
"entity-name_view": "View",
85+
"entity-name_async-replication": "Async Replication",
86+
"entity-name_transfer": "Transfer",
87+
"entity-name_resource-pool": "Resource Pool",
88+
"entity-name_secondary-index-table": "Secondary Index Table"
7289
}

0 commit comments

Comments
 (0)