Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions src/containers/Tenant/Diagnostics/DiagnosticsPages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ const SERVERLESS_DATABASE_PAGES = [

const TABLE_PAGES = [overview, schema, topShards, nodes, graph, tablets, hotKeys, describe, access];
const COLUMN_TABLE_PAGES = [overview, schema, topShards, nodes, tablets, describe, access];
const SYSTEM_VIEW_PAGES = [overview, schema, nodes, describe, access];

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

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

[EPathType.EPathTypeTable]: TABLE_PAGES,
[EPathType.EPathTypeColumnTable]: COLUMN_TABLE_PAGES,
[EPathType.EPathTypeSysView]: SYSTEM_VIEW_PAGES,

[EPathType.EPathTypeDir]: DIR_PAGES,
[EPathType.EPathTypeTableIndex]: DIR_PAGES,
Expand Down
2 changes: 2 additions & 0 deletions src/containers/Tenant/Diagnostics/Overview/Overview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {EPathType} from '../../../../types/api/schema';
import {useAutoRefreshInterval} from '../../../../utils/hooks';
import {ExternalDataSourceInfo} from '../../Info/ExternalDataSource/ExternalDataSource';
import {ExternalTableInfo} from '../../Info/ExternalTable/ExternalTable';
import {SystemViewInfo} from '../../Info/SystemView/SystemView';
import {ViewInfo} from '../../Info/View/View';

import {AsyncReplicationInfo} from './AsyncReplicationInfo';
Expand Down Expand Up @@ -42,6 +43,7 @@ function Overview({type, path, database, databaseFullPath}: OverviewProps) {
[EPathType.EPathTypeDir]: undefined,
[EPathType.EPathTypeResourcePool]: undefined,
[EPathType.EPathTypeTable]: undefined,
[EPathType.EPathTypeSysView]: () => <SystemViewInfo data={data} />,
[EPathType.EPathTypeSubDomain]: undefined,
[EPathType.EPathTypeTableIndex]: () => <TableIndexInfo data={data} />,
[EPathType.EPathTypeExtSubDomain]: undefined,
Expand Down
39 changes: 39 additions & 0 deletions src/containers/Tenant/Info/SystemView/SystemView.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import {Text} from '@gravity-ui/uikit';

import type {YDBDefinitionListItem} from '../../../../components/YDBDefinitionList/YDBDefinitionList';
import {YDBDefinitionList} from '../../../../components/YDBDefinitionList/YDBDefinitionList';
import type {TEvDescribeSchemeResult} from '../../../../types/api/schema';
import {prepareSystemViewType} from '../../../../utils/schema';
import {getEntityName} from '../../utils';
import i18n from '../i18n';

const prepareSystemViewItems = (data: TEvDescribeSchemeResult): YDBDefinitionListItem[] => {
const systemViewType = data.PathDescription?.SysViewDescription?.Type;

return [
{
name: i18n('field_system-view-type'),
content: prepareSystemViewType(systemViewType),
},
];
};

interface SystemViewInfoProps {
data?: TEvDescribeSchemeResult;
}

export function SystemViewInfo({data}: SystemViewInfoProps) {
const entityName = getEntityName(data?.PathDescription);

if (!data) {
return (
<Text variant="body-2" color="danger">
{i18n('no-entity-data', {entityName})}
</Text>
);
}

const items = prepareSystemViewItems(data);

return <YDBDefinitionList title={entityName} items={items} />;
}
6 changes: 5 additions & 1 deletion src/containers/Tenant/Info/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,9 @@
"external-objects.auth-method.none": "None",
"external-objects.auth-method.service-account": "Service Account",

"view.query-text": "Query Text"
"view.query-text": "Query Text",

"field_system-view-type": "System view type",

"no-entity-data": "No {{entityName}} data"
}
7 changes: 7 additions & 0 deletions src/containers/Tenant/ObjectSummary/ObjectSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import {
formatSecondsToHours,
} from '../../../utils/dataFormatters/dataFormatters';
import {useTypedDispatch, useTypedSelector} from '../../../utils/hooks';
import {prepareSystemViewType} from '../../../utils/schema';
import {EntityTitle} from '../EntityTitle/EntityTitle';
import {SchemaViewer} from '../Schema/SchemaViewer/SchemaViewer';
import {useCurrentSchema} from '../TenantContext';
Expand Down Expand Up @@ -233,6 +234,12 @@ export function ObjectSummary({
content: PathDescription?.TablePartitions?.length,
},
],
[EPathType.EPathTypeSysView]: () => [
{
name: i18n('field_system-view-type'),
content: prepareSystemViewType(PathDescription?.SysViewDescription?.Type),
},
],
[EPathType.EPathTypeSubDomain]: getDatabaseOverview,
[EPathType.EPathTypeTableIndex]: undefined,
[EPathType.EPathTypeExtSubDomain]: getDatabaseOverview,
Expand Down
1 change: 1 addition & 0 deletions src/containers/Tenant/ObjectSummary/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"field_data-size": "Data size",
"field_row-count": "Row count",
"field_partitions": "Partitions count",
"field_system-view-type": "System view type",
"field_paths": "Paths",
"field_shards": "Shards",
"field_state": "State",
Expand Down
5 changes: 5 additions & 0 deletions src/containers/Tenant/Schema/SchemaViewer/SchemaViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
isColumnEntityType,
isExternalTableType,
isRowTableType,
isSystemViewType,
isViewType,
} from '../../utils/schema';

Expand All @@ -20,6 +21,7 @@ import {
getColumnTableColumns,
getExternalTableColumns,
getRowTableColumns,
getSystemViewColumns,
getViewColumns,
} from './columns';
import {prepareSchemaData, prepareViewSchema} from './prepareData';
Expand Down Expand Up @@ -82,6 +84,9 @@ export const SchemaViewer = ({
if (isViewType(type)) {
return getViewColumns(tableData);
}
if (isSystemViewType(type)) {
return getSystemViewColumns(tableData);
}
if (isExternalTableType(type)) {
return getExternalTableColumns(tableData);
}
Expand Down
3 changes: 3 additions & 0 deletions src/containers/Tenant/Schema/SchemaViewer/columns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ function normalizeColumns(columns: SchemaColumn[], data?: SchemaData[]) {
export function getViewColumns(data?: SchemaData[]): SchemaColumn[] {
return normalizeColumns([nameColumn, typeColumn], data);
}
export function getSystemViewColumns(data?: SchemaData[]): SchemaColumn[] {
return normalizeColumns([idColumn, nameColumn, typeColumn, notNullColumn], data);
}
export function getExternalTableColumns(data?: SchemaData[]): SchemaColumn[] {
return normalizeColumns([idColumn, nameColumn, typeColumn, notNullColumn], data);
}
Expand Down
9 changes: 7 additions & 2 deletions src/containers/Tenant/Schema/SchemaViewer/prepareData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ import type {
} from '../../../../types/api/schema';
import {EColumnCodec} from '../../../../types/api/schema';
import type {Nullable} from '../../../../utils/typecheckers';
import {isColumnEntityType, isExternalTableType, isRowTableType} from '../../utils/schema';
import {
isColumnEntityType,
isExternalTableType,
isRowTableType,
isSystemViewType,
} from '../../utils/schema';

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

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

if (isRowTableType(type)) {
if (isRowTableType(type) || isSystemViewType(type)) {
return prepareRowTableSchema(Table);
} else if (isColumnEntityType(type)) {
return prepareColumnTableSchema(ColumnTableDescription);
Expand Down
19 changes: 18 additions & 1 deletion src/containers/Tenant/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,22 @@
"label_download": "Download healthcheck data",

"label_grant-access": "Grant access",
"context_grant-access": "Please note that granular rights can be combined into groups"
"context_grant-access": "Please note that granular rights can be combined into groups",

"entity-name_database": "Database",
"entity-name_directory": "Directory",
"entity-name_table": "Table",
"entity-name_system-view": "System view",
"entity-name_secondary-index": "Secondary Index",
"entity-name_tablestore": "Tablestore",
"entity-name_column-oriented-table": "Column-oriented table",
"entity-name_changefeed": "Changefeed",
"entity-name_topic": "Topic",
"entity-name_external-data-source": "External Data Source",
"entity-name_external-table": "External Table",
"entity-name_view": "View",
"entity-name_async-replication": "Async Replication",
"entity-name_transfer": "Transfer",
"entity-name_resource-pool": "Resource Pool",
"entity-name_secondary-index-table": "Secondary Index Table"
}
42 changes: 25 additions & 17 deletions src/containers/Tenant/utils/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type {NavigationTreeNodeType} from 'ydb-ui-components';

import {EPathSubType, EPathType} from '../../../types/api/schema';
import type {ETenantType} from '../../../types/api/tenant';
import i18n from '../i18n';

// this file contains verbose mappings that are typed in a way that ensures
// correctness when a new node type or a new path type is added
Expand All @@ -25,6 +26,7 @@ const pathTypeToNodeType: Record<EPathType, NavigationTreeNodeType | undefined>
[EPathType.EPathTypeColumnStore]: 'directory',

[EPathType.EPathTypeTable]: 'table',
[EPathType.EPathTypeSysView]: 'system_table',

[EPathType.EPathTypeTableIndex]: 'index',

Expand Down Expand Up @@ -61,8 +63,8 @@ export const mapPathTypeToNavigationTreeType = (
// ====================

const pathSubTypeToEntityName: Record<EPathSubType, string | undefined> = {
[EPathSubType.EPathSubTypeSyncIndexImplTable]: 'Secondary Index Table',
[EPathSubType.EPathSubTypeAsyncIndexImplTable]: 'Secondary Index Table',
[EPathSubType.EPathSubTypeSyncIndexImplTable]: i18n('entity-name_secondary-index-table'),
[EPathSubType.EPathSubTypeAsyncIndexImplTable]: i18n('entity-name_secondary-index-table'),

[EPathSubType.EPathSubTypeStreamImpl]: undefined,
[EPathSubType.EPathSubTypeEmpty]: undefined,
Expand All @@ -71,25 +73,26 @@ const pathSubTypeToEntityName: Record<EPathSubType, string | undefined> = {
const pathTypeToEntityName: Record<EPathType, string | undefined> = {
[EPathType.EPathTypeInvalid]: undefined,

[EPathType.EPathTypeSubDomain]: 'Database',
[EPathType.EPathTypeExtSubDomain]: 'Database',
[EPathType.EPathTypeSubDomain]: i18n('entity-name_database'),
[EPathType.EPathTypeExtSubDomain]: i18n('entity-name_database'),

[EPathType.EPathTypeDir]: 'Directory',
[EPathType.EPathTypeTable]: 'Table',
[EPathType.EPathTypeTableIndex]: 'Secondary Index',
[EPathType.EPathTypeColumnStore]: 'Tablestore',
[EPathType.EPathTypeColumnTable]: 'Column-oriented table',
[EPathType.EPathTypeCdcStream]: 'Changefeed',
[EPathType.EPathTypePersQueueGroup]: 'Topic',
[EPathType.EPathTypeDir]: i18n('entity-name_directory'),
[EPathType.EPathTypeTable]: i18n('entity-name_table'),
[EPathType.EPathTypeSysView]: i18n('entity-name_system-view'),
[EPathType.EPathTypeTableIndex]: i18n('entity-name_secondary-index'),
[EPathType.EPathTypeColumnStore]: i18n('entity-name_tablestore'),
[EPathType.EPathTypeColumnTable]: i18n('entity-name_column-oriented-table'),
[EPathType.EPathTypeCdcStream]: i18n('entity-name_changefeed'),
[EPathType.EPathTypePersQueueGroup]: i18n('entity-name_topic'),

[EPathType.EPathTypeExternalDataSource]: 'External Data Source',
[EPathType.EPathTypeExternalTable]: 'External Table',
[EPathType.EPathTypeExternalDataSource]: i18n('entity-name_external-data-source'),
[EPathType.EPathTypeExternalTable]: i18n('entity-name_external-table'),

[EPathType.EPathTypeView]: 'View',
[EPathType.EPathTypeView]: i18n('entity-name_view'),

[EPathType.EPathTypeReplication]: 'Async Replication',
[EPathType.EPathTypeTransfer]: 'Transfer',
[EPathType.EPathTypeResourcePool]: 'Resource Pool',
[EPathType.EPathTypeReplication]: i18n('entity-name_async-replication'),
[EPathType.EPathTypeTransfer]: i18n('entity-name_transfer'),
[EPathType.EPathTypeResourcePool]: i18n('entity-name_resource-pool'),
};

export const mapPathTypeToEntityName = (
Expand All @@ -115,6 +118,7 @@ export const mapDatabaseTypeToDBName = (type?: ETenantType) => type && databaseT
const pathTypeToIsTable: Record<EPathType, boolean> = {
[EPathType.EPathTypeTable]: true,
[EPathType.EPathTypeColumnTable]: true,
[EPathType.EPathTypeSysView]: true,

[EPathType.EPathTypeExternalTable]: true,

Expand Down Expand Up @@ -160,6 +164,7 @@ const pathTypeToIsColumn: Record<EPathType, boolean> = {
[EPathType.EPathTypeInvalid]: false,
[EPathType.EPathTypeDir]: false,
[EPathType.EPathTypeTable]: false,
[EPathType.EPathTypeSysView]: false,
[EPathType.EPathTypeSubDomain]: false,
[EPathType.EPathTypeTableIndex]: false,
[EPathType.EPathTypeExtSubDomain]: false,
Expand Down Expand Up @@ -189,6 +194,7 @@ const pathTypeToIsDatabase: Record<EPathType, boolean> = {
[EPathType.EPathTypeColumnStore]: false,
[EPathType.EPathTypeColumnTable]: false,
[EPathType.EPathTypeTable]: false,
[EPathType.EPathTypeSysView]: false,
[EPathType.EPathTypeTableIndex]: false,
[EPathType.EPathTypeCdcStream]: false,
[EPathType.EPathTypePersQueueGroup]: false,
Expand Down Expand Up @@ -240,6 +246,7 @@ const pathTypeToChildless: Record<EPathType, boolean> = {
[EPathType.EPathTypeColumnTable]: false,
[EPathType.EPathTypeDir]: false,
[EPathType.EPathTypeTable]: false,
[EPathType.EPathTypeSysView]: false,
[EPathType.EPathTypeSubDomain]: false,
[EPathType.EPathTypeTableIndex]: false,
[EPathType.EPathTypeExtSubDomain]: false,
Expand All @@ -253,3 +260,4 @@ export const isChildlessPathType = (type?: EPathType, subType?: EPathSubType) =>
export const isExternalTableType = (type?: EPathType) => type === EPathType.EPathTypeExternalTable;
export const isRowTableType = (type?: EPathType) => type === EPathType.EPathTypeTable;
export const isViewType = (type?: EPathType) => type === EPathType.EPathTypeView;
export const isSystemViewType = (type?: EPathType) => type === EPathType.EPathTypeSysView;
3 changes: 3 additions & 0 deletions src/types/api/schema/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type {TExternalDataSourceDescription} from './externalDataSource';
import type {TExternalTableDescription} from './externalTable';
import type {TPersQueueGroupDescription} from './persQueueGroup';
import type {TReplicationDescription} from './replication';
import type {TSysViewDescription} from './sysView';
import type {TTableDescription, TTableStats} from './table';
import type {TIndexDescription} from './tableIndex';
import type {TViewDescription} from './view';
Expand Down Expand Up @@ -86,6 +87,7 @@ export interface TPathDescription {
ExternalDataSourceDescription?: TExternalDataSourceDescription;

ViewDescription?: TViewDescription;
SysViewDescription?: TSysViewDescription;

ReplicationDescription?: TReplicationDescription;
}
Expand Down Expand Up @@ -283,6 +285,7 @@ export enum EPathType {
EPathTypeTable = 'EPathTypeTable',
EPathTypePersQueueGroup = 'EPathTypePersQueueGroup',
EPathTypeSubDomain = 'EPathTypeSubDomain',
EPathTypeSysView = 'EPathTypeSysView',

EPathTypeTableIndex = 'EPathTypeTableIndex',
EPathTypeExtSubDomain = 'EPathTypeExtSubDomain',
Expand Down
44 changes: 44 additions & 0 deletions src/types/api/schema/sysView.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import type {TPathID} from './shared';

export interface TSysViewDescription {
Name?: string;
Type?: ESysViewType;
SourceObject?: TPathID;
}

export type ESysViewType =
| 'EPartitionStats'
| 'ENodes'
| 'ETopQueriesByDurationOneMinute'
| 'ETopQueriesByDurationOneHour'
| 'ETopQueriesByReadBytesOneMinute'
| 'ETopQueriesByReadBytesOneHour'
| 'ETopQueriesByCpuTimeOneMinute'
| 'ETopQueriesByCpuTimeOneHour'
| 'ETopQueriesByRequestUnitsOneMinute'
| 'ETopQueriesByRequestUnitsOneHour'
| 'EQuerySessions'
| 'EPDisks'
| 'EVSlots'
| 'EGroups'
| 'EStoragePools'
| 'EStorageStats'
| 'ETablets'
| 'EQueryMetricsOneMinute'
| 'ETopPartitionsByCpuOneMinute'
| 'ETopPartitionsByCpuOneHour'
| 'ETopPartitionsByTliOneMinute'
| 'ETopPartitionsByTliOneHour'
| 'EResourcePoolClassifiers'
| 'EResourcePools'
| 'EAuthUsers'
| 'EAuthGroups'
| 'EAuthGroupMembers'
| 'EAuthOwners'
| 'EAuthPermissions'
| 'EAuthEffectivePermissions'
| 'EPgTables'
| 'EInformationSchemaTables'
| 'EPgClass'
| 'EShowCreate'
| 'ECompileCacheQueries';
14 changes: 14 additions & 0 deletions src/utils/schema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import type {ESysViewType} from '../types/api/schema/sysView';

export function prepareSystemViewType(type?: ESysViewType) {
if (!type) {
return undefined;
}
// System view type is enum, its format from backend is EType
// We need to display only Type, remove redundant E
// EStoragePools -> StoragePools, EStorageStats -> StorageStats
if (type.startsWith('E')) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

That looks fragile - would be great if you left some comment what and why is 'E'

Copy link
Member Author

Choose a reason for hiding this comment

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

Added comment

return type.slice(1);
}
return type;
}
Loading