Skip to content

Commit 02e0cd6

Browse files
feat(Overview): add view info (#912)
1 parent d8f97f0 commit 02e0cd6

File tree

8 files changed

+86
-19
lines changed

8 files changed

+86
-19
lines changed

package-lock.json

Lines changed: 5 additions & 5 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
@@ -13,7 +13,7 @@
1313
"@bem-react/classname": "^1.6.0",
1414
"@gravity-ui/axios-wrapper": "^1.4.1",
1515
"@gravity-ui/chartkit": "^5.5.0",
16-
"@gravity-ui/components": "^3.4.1",
16+
"@gravity-ui/components": "^3.6.2",
1717
"@gravity-ui/date-utils": "^2.4.0",
1818
"@gravity-ui/i18n": "^1.5.0",
1919
"@gravity-ui/icons": "^2.9.1",

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {EPathType} from '../../../../types/api/schema';
1313
import {useTypedSelector} from '../../../../utils/hooks';
1414
import {ExternalDataSourceInfo} from '../../Info/ExternalDataSource/ExternalDataSource';
1515
import {ExternalTableInfo} from '../../Info/ExternalTable/ExternalTable';
16+
import {ViewInfo} from '../../Info/View/View';
1617
import {
1718
isColumnEntityType,
1819
isEntityWithMergedImplementation,
@@ -91,7 +92,7 @@ function Overview({type, tenantName}: OverviewProps) {
9192
[EPathType.EPathTypePersQueueGroup]: () => <TopicInfo data={data} />,
9293
[EPathType.EPathTypeExternalTable]: () => <ExternalTableInfo data={data} />,
9394
[EPathType.EPathTypeExternalDataSource]: () => <ExternalDataSourceInfo data={data} />,
94-
[EPathType.EPathTypeView]: undefined,
95+
[EPathType.EPathTypeView]: () => <ViewInfo data={data} />,
9596
[EPathType.EPathTypeReplication]: () => <AsyncReplicationInfo data={data} />,
9697
};
9798

@@ -110,7 +111,7 @@ function Overview({type, tenantName}: OverviewProps) {
110111
return <ResponseError error={overviewError} />;
111112
}
112113

113-
return <div>{renderContent()}</div>;
114+
return renderContent();
114115
}
115116

116117
export default Overview;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
@import '../../../../styles/mixins.scss';
2+
3+
.ydb-view-info {
4+
@include flex-container();
5+
6+
&__properties-list {
7+
max-width: calc(100% - 40px);
8+
}
9+
10+
&__title {
11+
@include info-viewer-title();
12+
}
13+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import type {DefinitionListItem} from '@gravity-ui/components';
2+
import {DefinitionList} from '@gravity-ui/components';
3+
import {Text} from '@gravity-ui/uikit';
4+
5+
import {ResponseError} from '../../../../components/Errors/ResponseError';
6+
import type {TEvDescribeSchemeResult} from '../../../../types/api/schema';
7+
import {cn} from '../../../../utils/cn';
8+
import {useTypedSelector} from '../../../../utils/hooks';
9+
import {getEntityName} from '../../utils';
10+
import i18n from '../i18n';
11+
12+
const b = cn('ydb-view-info');
13+
14+
import './View.scss';
15+
16+
const prepareViewItems = (data: TEvDescribeSchemeResult): DefinitionListItem[] => {
17+
const queryText = data.PathDescription?.ViewDescription?.QueryText;
18+
19+
return [
20+
{
21+
name: i18n('view.query-text'),
22+
copyText: queryText,
23+
content: (
24+
<Text variant="code-2" wordBreak="break-word">
25+
{queryText}
26+
</Text>
27+
),
28+
},
29+
];
30+
};
31+
32+
interface ViewInfoProps {
33+
data?: TEvDescribeSchemeResult;
34+
}
35+
36+
export function ViewInfo({data}: ViewInfoProps) {
37+
const entityName = getEntityName(data?.PathDescription);
38+
39+
const {error: schemaError} = useTypedSelector((state) => state.schema);
40+
41+
if (schemaError) {
42+
return <ResponseError error={schemaError} />;
43+
}
44+
45+
if (!data) {
46+
return <div className="error">No {entityName} data</div>;
47+
}
48+
49+
return (
50+
<div className={b(null)}>
51+
<div className={b('title')}>{entityName}</div>
52+
<DefinitionList
53+
nameMaxWidth={200}
54+
copyPosition="outside"
55+
className={b('properties-list')}
56+
items={prepareViewItems(data)}
57+
/>
58+
</div>
59+
);
60+
}

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,7 @@
44
"external-objects.location": "Location",
55
"external-objects.auth-method": "Auth Method",
66
"external-objects.auth-method.none": "None",
7-
"external-objects.auth-method.service-account": "Service Account"
7+
"external-objects.auth-method.service-account": "Service Account",
8+
9+
"view.query-text": "Query Text"
810
}
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-objects-info';
76

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

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

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

0 commit comments

Comments
 (0)