Skip to content

Commit fbeea1a

Browse files
feat: add view to schema (#834)
1 parent efccf2e commit fbeea1a

File tree

16 files changed

+91
-47
lines changed

16 files changed

+91
-47
lines changed

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"url": "^0.11.3",
4949
"use-query-params": "^2.2.1",
5050
"web-vitals": "^1.1.2",
51-
"ydb-ui-components": "^4.0.0"
51+
"ydb-ui-components": "^4.1.0"
5252
},
5353
"scripts": {
5454
"analyze": "source-map-explorer 'build/static/js/*.js'",

src/containers/Tenant/Diagnostics/DiagnosticsPages.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ export const TOPIC_PAGES = [overview, consumers, partitions, nodes, describe];
9292
export const EXTERNAL_DATA_SOURCE_PAGES = [overview, describe];
9393
export const EXTERNAL_TABLE_PAGES = [overview, describe];
9494

95+
export const VIEW_PAGES = [overview, describe];
96+
9597
// verbose mapping to guarantee correct tabs for new path types
9698
// TS will error when a new type is added but not mapped here
9799
const pathTypeToPages: Record<EPathType, Page[] | undefined> = {
@@ -113,6 +115,8 @@ const pathTypeToPages: Record<EPathType, Page[] | undefined> = {
113115

114116
[EPathType.EPathTypeExternalDataSource]: EXTERNAL_DATA_SOURCE_PAGES,
115117
[EPathType.EPathTypeExternalTable]: EXTERNAL_TABLE_PAGES,
118+
119+
[EPathType.EPathTypeView]: VIEW_PAGES,
116120
};
117121

118122
export const getPagesByType = (type?: EPathType) => (type && pathTypeToPages[type]) || DIR_PAGES;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ function Overview({type, tenantName}: OverviewProps) {
9090
[EPathType.EPathTypePersQueueGroup]: () => <TopicInfo data={data} />,
9191
[EPathType.EPathTypeExternalTable]: () => <ExternalTableInfo data={data} />,
9292
[EPathType.EPathTypeExternalDataSource]: () => <ExternalDataSourceInfo data={data} />,
93+
[EPathType.EPathTypeView]: undefined,
9394
};
9495

9596
return (

src/containers/Tenant/ObjectSummary/ObjectSummary.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ import {
4444
PaneVisibilityToggleButtons,
4545
paneVisibilityToggleReducerCreator,
4646
} from '../utils/paneVisibilityToggleHelpers';
47-
import {isIndexTable, isTableType} from '../utils/schema';
47+
import {isIndexTableType, isTableType, isViewType} from '../utils/schema';
4848

4949
import './ObjectSummary.scss';
5050

@@ -103,15 +103,17 @@ export function ObjectSummary({
103103
const currentSchemaData = currentObjectData?.PathDescription?.Self;
104104

105105
React.useEffect(() => {
106-
const isTable = isTableType(type);
106+
// TODO: enable schema tab for view when supported
107+
const isTable = isTableType(type) && !isViewType(type);
107108

108109
if (type && !isTable && !TENANT_INFO_TABS.find((el) => el.id === summaryTab)) {
109110
dispatch(setSummaryTab(TENANT_SUMMARY_TABS_IDS.overview));
110111
}
111112
}, [dispatch, type, summaryTab]);
112113

113114
const renderTabs = () => {
114-
const isTable = isTableType(type);
115+
// TODO: enable schema tab for view when supported
116+
const isTable = isTableType(type) && !isViewType(type);
115117
const tabsItems = isTable ? [...TENANT_INFO_TABS, ...TENANT_SCHEMA_TAB] : TENANT_INFO_TABS;
116118

117119
return (
@@ -160,6 +162,7 @@ export function ObjectSummary({
160162
[EPathType.EPathTypeExternalDataSource]: () => (
161163
<ExternalDataSourceSummary data={currentObjectData} />
162164
),
165+
[EPathType.EPathTypeView]: undefined,
163166
};
164167

165168
let component =
@@ -239,7 +242,7 @@ export function ObjectSummary({
239242
};
240243

241244
const renderCommonInfoControls = () => {
242-
const showPreview = isTableType(type) && !isIndexTable(subType);
245+
const showPreview = isTableType(type) && !isIndexTableType(subType);
243246
return (
244247
<React.Fragment>
245248
{showPreview && (

src/containers/Tenant/Query/Preview/Preview.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import type {EPathType} from '../../../../types/api/schema';
1010
import {cn} from '../../../../utils/cn';
1111
import {useTypedDispatch, useTypedSelector} from '../../../../utils/hooks';
1212
import {prepareQueryError} from '../../../../utils/query';
13-
import {isExternalTable, isTableType} from '../../utils/schema';
13+
import {isExternalTableType, isTableType} from '../../utils/schema';
1414
import i18n from '../i18n';
1515

1616
import './Preview.scss';
@@ -32,7 +32,7 @@ export const Preview = ({database, type}: PreviewProps) => {
3232

3333
const query = `--!syntax_v1\nselect * from \`${currentSchemaPath}\` limit 32`;
3434
const {currentData, isFetching, error} = previewApi.useSendQueryQuery(
35-
{database, query, action: isExternalTable(type) ? 'execute-query' : 'execute-scan'},
35+
{database, query, action: isExternalTableType(type) ? 'execute-query' : 'execute-scan'},
3636
{pollingInterval: autorefresh, skip: !isPreviewAvailable},
3737
);
3838
const loading = isFetching && currentData === undefined;

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@ import type {
1111
TFamilyDescription,
1212
} from '../../../../types/api/schema';
1313
import {EColumnCodec} from '../../../../types/api/schema';
14-
import {isColumnEntityType, isExternalTable, isRowTable, isTableType} from '../../utils/schema';
14+
import {
15+
isColumnEntityType,
16+
isExternalTableType,
17+
isRowTableType,
18+
isTableType,
19+
} from '../../utils/schema';
1520

1621
export const SchemaViewerColumns = {
1722
id: 'Id',
@@ -69,7 +74,7 @@ export function prepareColumnDescriptions(
6974
const columnTableSchema = prepareOlapTableSchema(description);
7075
keyColumnIds = columnTableSchema.KeyColumnIds ?? [];
7176
columns = columnTableSchema.Columns ?? [];
72-
} else if (isExternalTable(type)) {
77+
} else if (isExternalTableType(type)) {
7378
columns = scheme?.PathDescription?.ExternalTableDescription?.Columns ?? [];
7479
} else {
7580
keyColumnIds = scheme?.PathDescription?.Table?.KeyColumnIds ?? [];
@@ -120,7 +125,7 @@ export function prepareSchemaTableColumns(options: {
120125
},
121126
];
122127

123-
if (!isExternalTable(options.type)) {
128+
if (!isExternalTableType(options.type)) {
124129
// External tables don't have key columns
125130
columns.push({
126131
name: SchemaViewerColumns.key,
@@ -164,7 +169,7 @@ export function prepareSchemaTableColumns(options: {
164169
},
165170
);
166171

167-
if (options.withFamilies && isRowTable(options.type)) {
172+
if (options.withFamilies && isRowTableType(options.type)) {
168173
columns.push(
169174
{
170175
name: SchemaViewerColumns.familyName,

src/containers/Tenant/i18n/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,16 @@
1010

1111
"actions.copied": "The path is copied to the clipboard",
1212
"actions.notCopied": "Couldn’t copy the path",
13-
"actions.externalTableSelectUnavailable": "Select query for external tables available only with 'YQL - QueryService' query mode. You need to turn in additional query modes in settings to enable it",
1413

1514
"actions.copyPath": "Copy path",
1615
"actions.openPreview": "Open preview",
1716
"actions.createTable": "Create table...",
1817
"actions.createExternalTable": "Create external table...",
1918
"actions.createTopic": "Create topic...",
19+
"actions.createView": "Create view...",
2020
"actions.dropTable": "Drop table...",
2121
"actions.dropTopic": "Drop topic...",
22+
"actions.dropView": "Drop view...",
2223
"actions.alterTable": "Alter table...",
2324
"actions.alterTopic": "Alter topic...",
2425
"actions.selectQuery": "Select query...",
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import {registerKeysets} from '../../../utils/i18n';
22

33
import en from './en.json';
4-
import ru from './ru.json';
54

65
const COMPONENT = 'ydb-tenant';
76

8-
export default registerKeysets(COMPONENT, {en, ru});
7+
export default registerKeysets(COMPONENT, {en});

src/containers/Tenant/i18n/ru.json

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)