Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support transfer #1995

Merged
merged 11 commits into from
Mar 5, 2025
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
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"use-query-params": "^2.2.1",
"uuid": "^10.0.0",
"web-vitals": "^1.1.2",
"ydb-ui-components": "^4.5.0",
"ydb-ui-components": "^4.6.0",
"zod": "^3.24.1"
},
"scripts": {
Expand Down
3 changes: 3 additions & 0 deletions src/containers/Tenant/Diagnostics/DiagnosticsPages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ const operations = {

const ASYNC_REPLICATION_PAGES = [overview, tablets, describe];

const TRANSFER_PAGES = [overview, tablets, describe];

const DATABASE_PAGES = [
overview,
topQueries,
Expand Down Expand Up @@ -133,6 +135,7 @@ const pathTypeToPages: Record<EPathType, Page[] | undefined> = {
[EPathType.EPathTypeView]: VIEW_PAGES,

[EPathType.EPathTypeReplication]: ASYNC_REPLICATION_PAGES,
[EPathType.EPathTypeTransfer]: TRANSFER_PAGES,
[EPathType.EPathTypeResourcePool]: 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 @@ -20,6 +20,7 @@ import {AsyncReplicationInfo} from './AsyncReplicationInfo';
import {ChangefeedInfo} from './ChangefeedInfo';
import {TableInfo} from './TableInfo';
import {TopicInfo} from './TopicInfo';
import {TransferInfo} from './TransferInfo';

interface OverviewProps {
type?: EPathType;
Expand Down Expand Up @@ -94,6 +95,7 @@ function Overview({type, path, database}: OverviewProps) {
[EPathType.EPathTypeExternalDataSource]: () => <ExternalDataSourceInfo data={data} />,
[EPathType.EPathTypeView]: () => <ViewInfo data={data} />,
[EPathType.EPathTypeReplication]: () => <AsyncReplicationInfo data={data} />,
[EPathType.EPathTypeTransfer]: () => <TransferInfo data={data} />,
};

return (type && pathTypeToComponent[type]?.()) || <TableInfo data={data} type={type} />;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import {Label} from '@gravity-ui/uikit';

import type {TConnectionParams} from '../../../../../types/api/schema/replication';

interface CredentialsProps {
connection?: TConnectionParams;
}

export function Credentials({connection}: CredentialsProps) {
if (!connection) {
return null;
}

if (connection.StaticCredentials) {
return (
<Label value={connection.StaticCredentials.User} theme="normal">
user
</Label>
);
}

if ('OAuthToken' in connection) {
return 'OAuth';
}

return 'unknown';
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import type {DefinitionListItem} from '@gravity-ui/components';
import {Flex, Text} from '@gravity-ui/uikit';

import {AsyncReplicationState} from '../../../../../components/AsyncReplicationState';
import {YDBDefinitionList} from '../../../../../components/YDBDefinitionList/YDBDefinitionList';
import {YqlHighlighter} from '../../../../../components/YqlHighlighter/YqlHighlighter';
import type {TEvDescribeSchemeResult} from '../../../../../types/api/schema';
import {getEntityName} from '../../../utils';

import {Credentials} from './Credentials';
import i18n from './i18n';

interface TransferProps {
data?: TEvDescribeSchemeResult;
}

/** Displays overview for Transfer EPathType */
export function TransferInfo({data}: TransferProps) {
const entityName = getEntityName(data?.PathDescription);

if (!data) {
return (
<div className="error">
{i18n('noData')} {entityName}
</div>
);
}

const transferItems = prepareTransferItems(data);

return (
<Flex direction="column" gap="4">
<YDBDefinitionList title={entityName} items={transferItems} />
</Flex>
);
}

function prepareTransferItems(data: TEvDescribeSchemeResult) {
const transferDescription = data.PathDescription?.ReplicationDescription || {};
const state = transferDescription.State;
const srcConnectionParams = transferDescription.Config?.SrcConnectionParams || {};
const {Endpoint, Database} = srcConnectionParams;
const target = transferDescription.Config?.TransferSpecific?.Targets[0];
const srcPath = target?.SrcPath;
const dstPath = target?.DstPath;
const transformLambda = target?.TransformLambda;

const info: DefinitionListItem[] = [];

if (state) {
info.push({
name: i18n('state.label'),
content: <AsyncReplicationState state={state} />,
});
}

if (Endpoint) {
info.push({
name: i18n('srcConnection.endpoint.label'),
copyText: Endpoint,
content: <Text variant="code-inline-2">{Endpoint}</Text>,
});
}

if (Database) {
info.push({
name: i18n('srcConnection.database.label'),
copyText: Database,
content: <Text variant="code-inline-2">{Database}</Text>,
});
}

if (srcConnectionParams) {
info.push({
name: i18n('credentials.label'),
content: <Credentials connection={srcConnectionParams} />,
});
}

info.push({
name: i18n('srcPath.label'),
copyText: srcPath,
content: <Text variant="code-inline-2">{srcPath}</Text>,
});

info.push({
name: i18n('dstPath.label'),
copyText: dstPath,
content: <Text variant="code-inline-2">{dstPath}</Text>,
});

info.push({
name: i18n('transformLambda.label'),
copyText: transformLambda,
content: transformLambda ? <YqlHighlighter>{transformLambda}</YqlHighlighter> : null,
});

return info;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"credentials.label": "Credentials",
"noData": "No data for entity:",
"srcConnection.database.label": "Source Database Path",
"srcConnection.endpoint.label": "Source Cluster Endpoint",
"state.label": "State",
"srcPath.label": "Source Topic",
"dstPath.label": "Destination Table",
"transformLambda.label": "Transformation Lambda"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import {registerKeysets} from '../../../../../../utils/i18n';

import en from './en.json';

const COMPONENT = 'ydb-diagnostics-transfer-info';

export default registerKeysets(COMPONENT, {en});
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './TransferInfo';
14 changes: 14 additions & 0 deletions src/containers/Tenant/ObjectSummary/ObjectSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,20 @@ export function ObjectSummary({
return [];
}

return [
{
name: i18n('field_state'),
content: <AsyncReplicationState state={state} />,
},
];
},
[EPathType.EPathTypeTransfer]: () => {
const state = PathDescription?.ReplicationDescription?.State;

if (!state) {
return [];
}

return [
{
name: i18n('field_state'),
Expand Down
17 changes: 17 additions & 0 deletions src/containers/Tenant/Query/NewSQL/NewSQL.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,23 @@ export function NewSQL() {
},
],
},
{
text: i18n('menu.transfer'),
items: [
{
text: i18n('action.create-transfer'),
action: actions.createTransfer,
},
{
text: i18n('action.alter-transfer'),
action: actions.alterTransfer,
},
{
text: i18n('action.drop-transfer'),
action: actions.dropTransfer,
},
],
},
{
text: i18n('menu.capture'),
items: [
Expand Down
6 changes: 5 additions & 1 deletion src/containers/Tenant/Query/NewSQL/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,22 @@
"menu.topics": "Topics",
"menu.capture": "Change data capture",
"menu.replication": "Async replication",
"menu.transfer": "Transfer",
"menu.users": "Users",
"action.create-topic": "Create Topic",
"action.drop-topic": "Drop Topic",
"action.alter-topic": "Alter Topic",
"action.create-cdc-stream": "Create changefeed",
"action.create-async-replication": "Create async replication",
"action.create-transfer": "Create transfer",
"action.create-user": "Create user",
"action.create-group": "Create group",
"action.drop-user": "Drop user",
"action.drop-group": "Drop group",
"action.grant-privilege": "Grant privilege",
"action.revoke-privilege": "Revoke privilege",
"action.alter-async-replication": "Alter async replication",
"action.drop-async-replication": "Drop async replication"
"action.drop-async-replication": "Drop async replication",
"action.alter-transfer": "Alter transfer",
"action.drop-transfer": "Drop transfer"
}
3 changes: 3 additions & 0 deletions src/containers/Tenant/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"actions.createTopic": "Create topic...",
"actions.createColumnTable": "Create column table...",
"actions.createAsyncReplication": "Create async replication...",
"actions.createTransfer": "Create transfer...",
"actions.createView": "Create view...",
"actions.dropTable": "Drop table...",
"actions.dropTopic": "Drop topic...",
Expand All @@ -46,7 +47,9 @@
"actions.selectQuery": "Select query...",
"actions.upsertQuery": "Upsert query...",
"actions.alterReplication": "Alter async replicaton...",
"actions.alterTransfer": "Alter transfer...",
"actions.dropReplication": "Drop async replicaton...",
"actions.dropTransfer": "Drop transfer...",
"actions.createDirectory": "Create directory",
"schema.tree.dialog.placeholder": "Relative path",
"schema.tree.dialog.invalid": "Invalid path",
Expand Down
1 change: 1 addition & 0 deletions src/containers/Tenant/utils/controls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export const getSchemaControls =

const nodeTypeToControls: Record<NavigationTreeNodeType, Controls> = {
async_replication: undefined,
transfer: undefined,

database: undefined,
directory: undefined,
Expand Down
6 changes: 6 additions & 0 deletions src/containers/Tenant/utils/newSQLQueryActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ import {
alterAsyncReplicationTemplate,
alterTableTemplate,
alterTopicTemplate,
alterTransferTemplate,
createAsyncReplicationTemplate,
createCdcStreamTemplate,
createColumnTableTemplate,
createExternalTableTemplate,
createGroupTemplate,
createTableTemplate,
createTopicTemplate,
createTransferTemplate,
createUserTemplate,
createViewTemplate,
deleteRowsTemplate,
Expand All @@ -19,6 +21,7 @@ import {
dropTableIndex,
dropTableTemplate,
dropTopicTemplate,
dropTransferTemplate,
dropUserTemplate,
grantPrivilegeTemplate,
revokePrivilegeTemplate,
Expand All @@ -38,6 +41,9 @@ export const bindActions = (changeUserInput: (input: string) => void) => {
createAsyncReplication: inputQuery(createAsyncReplicationTemplate),
alterAsyncReplication: inputQuery(alterAsyncReplicationTemplate),
dropAsyncReplication: inputQuery(dropAsyncReplicationTemplate),
createTransfer: inputQuery(createTransferTemplate),
alterTransfer: inputQuery(alterTransferTemplate),
dropTransfer: inputQuery(dropTransferTemplate),
alterTable: inputQuery(alterTableTemplate),
selectQuery: inputQuery(selectQueryTemplate),
upsertQuery: inputQuery(upsertQueryTemplate),
Expand Down
7 changes: 7 additions & 0 deletions src/containers/Tenant/utils/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const pathTypeToNodeType: Record<EPathType, NavigationTreeNodeType | undefined>
[EPathType.EPathTypeView]: 'view',

[EPathType.EPathTypeReplication]: 'async_replication',
[EPathType.EPathTypeTransfer]: 'transfer',
[EPathType.EPathTypeResourcePool]: 'resource_pool',
};

Expand Down Expand Up @@ -87,6 +88,7 @@ const pathTypeToEntityName: Record<EPathType, string | undefined> = {
[EPathType.EPathTypeView]: 'View',

[EPathType.EPathTypeReplication]: 'Async Replication',
[EPathType.EPathTypeTransfer]: 'Transfer',
[EPathType.EPathTypeResourcePool]: 'Resource Pool',
};

Expand Down Expand Up @@ -128,6 +130,7 @@ const pathTypeToIsTable: Record<EPathType, boolean> = {
[EPathType.EPathTypePersQueueGroup]: false,
[EPathType.EPathTypeExternalDataSource]: false,
[EPathType.EPathTypeReplication]: false,
[EPathType.EPathTypeTransfer]: false,
[EPathType.EPathTypeResourcePool]: false,
};

Expand Down Expand Up @@ -169,6 +172,7 @@ const pathTypeToIsColumn: Record<EPathType, boolean> = {
[EPathType.EPathTypeView]: false,

[EPathType.EPathTypeReplication]: false,
[EPathType.EPathTypeTransfer]: false,
[EPathType.EPathTypeResourcePool]: false,
};

Expand All @@ -195,6 +199,7 @@ const pathTypeToIsDatabase: Record<EPathType, boolean> = {
[EPathType.EPathTypeView]: false,

[EPathType.EPathTypeReplication]: false,
[EPathType.EPathTypeTransfer]: false,
[EPathType.EPathTypeResourcePool]: false,
};

Expand Down Expand Up @@ -226,6 +231,7 @@ const pathTypeToEntityWithMergedImplementation: Record<EPathType, boolean> = {
[EPathType.EPathTypeView]: false,

[EPathType.EPathTypeReplication]: false,
[EPathType.EPathTypeTransfer]: false,
[EPathType.EPathTypeResourcePool]: false,
};

Expand Down Expand Up @@ -253,6 +259,7 @@ const pathTypeToChildless: Record<EPathType, boolean> = {
[EPathType.EPathTypeResourcePool]: true,

[EPathType.EPathTypeReplication]: true,
[EPathType.EPathTypeTransfer]: true,

[EPathType.EPathTypeInvalid]: false,
[EPathType.EPathTypeColumnStore]: false,
Expand Down
Loading
Loading