Skip to content

Commit 966ff4b

Browse files
authored
feat: support transfer (#1995)
1 parent 5dc37e0 commit 966ff4b

File tree

20 files changed

+288
-6
lines changed

20 files changed

+288
-6
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
@@ -58,7 +58,7 @@
5858
"use-query-params": "^2.2.1",
5959
"uuid": "^10.0.0",
6060
"web-vitals": "^1.1.2",
61-
"ydb-ui-components": "^4.5.0",
61+
"ydb-ui-components": "^4.6.0",
6262
"zod": "^3.24.1"
6363
},
6464
"scripts": {

src/containers/Tenant/Diagnostics/DiagnosticsPages.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ const operations = {
8282

8383
const ASYNC_REPLICATION_PAGES = [overview, tablets, describe];
8484

85+
const TRANSFER_PAGES = [overview, tablets, describe];
86+
8587
const DATABASE_PAGES = [
8688
overview,
8789
topQueries,
@@ -133,6 +135,7 @@ const pathTypeToPages: Record<EPathType, Page[] | undefined> = {
133135
[EPathType.EPathTypeView]: VIEW_PAGES,
134136

135137
[EPathType.EPathTypeReplication]: ASYNC_REPLICATION_PAGES,
138+
[EPathType.EPathTypeTransfer]: TRANSFER_PAGES,
136139
[EPathType.EPathTypeResourcePool]: DIR_PAGES,
137140
};
138141

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {AsyncReplicationInfo} from './AsyncReplicationInfo';
2020
import {ChangefeedInfo} from './ChangefeedInfo';
2121
import {TableInfo} from './TableInfo';
2222
import {TopicInfo} from './TopicInfo';
23+
import {TransferInfo} from './TransferInfo';
2324

2425
interface OverviewProps {
2526
type?: EPathType;
@@ -94,6 +95,7 @@ function Overview({type, path, database}: OverviewProps) {
9495
[EPathType.EPathTypeExternalDataSource]: () => <ExternalDataSourceInfo data={data} />,
9596
[EPathType.EPathTypeView]: () => <ViewInfo data={data} />,
9697
[EPathType.EPathTypeReplication]: () => <AsyncReplicationInfo data={data} />,
98+
[EPathType.EPathTypeTransfer]: () => <TransferInfo data={data} />,
9799
};
98100

99101
return (type && pathTypeToComponent[type]?.()) || <TableInfo data={data} type={type} />;
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import {Label} from '@gravity-ui/uikit';
2+
3+
import type {TConnectionParams} from '../../../../../types/api/schema/replication';
4+
5+
interface CredentialsProps {
6+
connection?: TConnectionParams;
7+
}
8+
9+
export function Credentials({connection}: CredentialsProps) {
10+
if (!connection) {
11+
return null;
12+
}
13+
14+
if (connection.StaticCredentials) {
15+
return (
16+
<Label value={connection.StaticCredentials.User} theme="normal">
17+
user
18+
</Label>
19+
);
20+
}
21+
22+
if ('OAuthToken' in connection) {
23+
return 'OAuth';
24+
}
25+
26+
return 'unknown';
27+
}
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
import type {DefinitionListItem} from '@gravity-ui/components';
2+
import {Flex, Text} from '@gravity-ui/uikit';
3+
4+
import {AsyncReplicationState} from '../../../../../components/AsyncReplicationState';
5+
import {YDBDefinitionList} from '../../../../../components/YDBDefinitionList/YDBDefinitionList';
6+
import {YqlHighlighter} from '../../../../../components/YqlHighlighter/YqlHighlighter';
7+
import type {TEvDescribeSchemeResult} from '../../../../../types/api/schema';
8+
import {getEntityName} from '../../../utils';
9+
10+
import {Credentials} from './Credentials';
11+
import i18n from './i18n';
12+
13+
interface TransferProps {
14+
data?: TEvDescribeSchemeResult;
15+
}
16+
17+
/** Displays overview for Transfer EPathType */
18+
export function TransferInfo({data}: TransferProps) {
19+
const entityName = getEntityName(data?.PathDescription);
20+
21+
if (!data) {
22+
return (
23+
<div className="error">
24+
{i18n('noData')} {entityName}
25+
</div>
26+
);
27+
}
28+
29+
const transferItems = prepareTransferItems(data);
30+
31+
return (
32+
<Flex direction="column" gap="4">
33+
<YDBDefinitionList title={entityName} items={transferItems} />
34+
</Flex>
35+
);
36+
}
37+
38+
function prepareTransferItems(data: TEvDescribeSchemeResult) {
39+
const transferDescription = data.PathDescription?.ReplicationDescription || {};
40+
const state = transferDescription.State;
41+
const srcConnectionParams = transferDescription.Config?.SrcConnectionParams || {};
42+
const {Endpoint, Database} = srcConnectionParams;
43+
const target = transferDescription.Config?.TransferSpecific?.Targets[0];
44+
const srcPath = target?.SrcPath;
45+
const dstPath = target?.DstPath;
46+
const transformLambda = target?.TransformLambda;
47+
48+
const info: DefinitionListItem[] = [];
49+
50+
if (state) {
51+
info.push({
52+
name: i18n('state.label'),
53+
content: <AsyncReplicationState state={state} />,
54+
});
55+
}
56+
57+
if (Endpoint) {
58+
info.push({
59+
name: i18n('srcConnection.endpoint.label'),
60+
copyText: Endpoint,
61+
content: <Text variant="code-inline-2">{Endpoint}</Text>,
62+
});
63+
}
64+
65+
if (Database) {
66+
info.push({
67+
name: i18n('srcConnection.database.label'),
68+
copyText: Database,
69+
content: <Text variant="code-inline-2">{Database}</Text>,
70+
});
71+
}
72+
73+
if (srcConnectionParams) {
74+
info.push({
75+
name: i18n('credentials.label'),
76+
content: <Credentials connection={srcConnectionParams} />,
77+
});
78+
}
79+
80+
info.push({
81+
name: i18n('srcPath.label'),
82+
copyText: srcPath,
83+
content: <Text variant="code-inline-2">{srcPath}</Text>,
84+
});
85+
86+
info.push({
87+
name: i18n('dstPath.label'),
88+
copyText: dstPath,
89+
content: <Text variant="code-inline-2">{dstPath}</Text>,
90+
});
91+
92+
info.push({
93+
name: i18n('transformLambda.label'),
94+
copyText: transformLambda,
95+
content: transformLambda ? <YqlHighlighter>{transformLambda}</YqlHighlighter> : null,
96+
});
97+
98+
return info;
99+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"credentials.label": "Credentials",
3+
"noData": "No data for entity:",
4+
"srcConnection.database.label": "Source Database Path",
5+
"srcConnection.endpoint.label": "Source Cluster Endpoint",
6+
"state.label": "State",
7+
"srcPath.label": "Source Topic",
8+
"dstPath.label": "Destination Table",
9+
"transformLambda.label": "Transformation Lambda"
10+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import {registerKeysets} from '../../../../../../utils/i18n';
2+
3+
import en from './en.json';
4+
5+
const COMPONENT = 'ydb-diagnostics-transfer-info';
6+
7+
export default registerKeysets(COMPONENT, {en});
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './TransferInfo';

src/containers/Tenant/ObjectSummary/ObjectSummary.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,20 @@ export function ObjectSummary({
310310
return [];
311311
}
312312

313+
return [
314+
{
315+
name: i18n('field_state'),
316+
content: <AsyncReplicationState state={state} />,
317+
},
318+
];
319+
},
320+
[EPathType.EPathTypeTransfer]: () => {
321+
const state = PathDescription?.ReplicationDescription?.State;
322+
323+
if (!state) {
324+
return [];
325+
}
326+
313327
return [
314328
{
315329
name: i18n('field_state'),

0 commit comments

Comments
 (0)