Skip to content

Commit bda204e

Browse files
author
Zabilsya
committed
[DOP-22196] fix after review
1 parent 372841b commit bda204e

File tree

8 files changed

+85
-12
lines changed

8 files changed

+85
-12
lines changed

src/entities/connection/constants.ts

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,30 @@ import { prepareOptionsForSelect } from '@shared/ui';
33

44
import { ConnectionBucketStyle, ConnectionProtocol } from './api';
55

6-
export const CONNECTION_TYPE_SELECT_OPTIONS = prepareOptionsForSelect<ConnectionType>({
7-
data: Object.values(ConnectionType),
8-
renderLabel: (data) => data,
9-
renderValue: (data) => data,
6+
export const CONNECTION_TYPE_NAMES: Record<ConnectionType, string> = {
7+
[ConnectionType.CLICKHOUSE]: 'ClickHouse',
8+
[ConnectionType.HDFS]: 'HDFS',
9+
[ConnectionType.HIVE]: 'Hive',
10+
[ConnectionType.MS_SQL]: 'MSSQL',
11+
[ConnectionType.MY_SQL]: 'MySQL',
12+
[ConnectionType.ORACLE]: 'Oracle',
13+
[ConnectionType.POSTGRES]: 'Postgres',
14+
[ConnectionType.S3]: 'S3',
15+
};
16+
17+
export const CONNECTION_TYPE_SELECT_OPTIONS = prepareOptionsForSelect({
18+
data: [
19+
{ value: ConnectionType.CLICKHOUSE, label: CONNECTION_TYPE_NAMES[ConnectionType.CLICKHOUSE] },
20+
{ value: ConnectionType.HDFS, label: CONNECTION_TYPE_NAMES[ConnectionType.HDFS] },
21+
{ value: ConnectionType.HIVE, label: CONNECTION_TYPE_NAMES[ConnectionType.HIVE] },
22+
{ value: ConnectionType.MS_SQL, label: CONNECTION_TYPE_NAMES[ConnectionType.MS_SQL] },
23+
{ value: ConnectionType.MY_SQL, label: CONNECTION_TYPE_NAMES[ConnectionType.MY_SQL] },
24+
{ value: ConnectionType.ORACLE, label: CONNECTION_TYPE_NAMES[ConnectionType.ORACLE] },
25+
{ value: ConnectionType.POSTGRES, label: CONNECTION_TYPE_NAMES[ConnectionType.POSTGRES] },
26+
{ value: ConnectionType.S3, label: CONNECTION_TYPE_NAMES[ConnectionType.S3] },
27+
],
28+
renderLabel: (data) => data.label,
29+
renderValue: (data) => data.value,
1030
});
1131

1232
export const CONNECTION_BUCKET_STYLE_SELECT_OPTIONS = prepareOptionsForSelect<ConnectionBucketStyle>({

src/entities/transfer/api/types.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,18 @@ export interface Transfer {
1212
| TransferParamsHive
1313
| TransferParamsOracle
1414
| TransferParamsPostgres
15+
| TransferParamsClickhouse
16+
| TransferParamsMsSql
17+
| TransferParamsMySql
1518
| TransferSourceParamsHdfs
1619
| TransferSourceParamsS3;
1720
target_params:
1821
| TransferParamsHive
1922
| TransferParamsOracle
2023
| TransferParamsPostgres
24+
| TransferParamsClickhouse
25+
| TransferParamsMsSql
26+
| TransferParamsMySql
2127
| TransferTargetParamsHdfs
2228
| TransferTargetParamsS3;
2329
strategy_params: TransferStrategyParams;
@@ -46,6 +52,21 @@ interface TransferParamsPostgres {
4652
table_name: string;
4753
}
4854

55+
interface TransferParamsMySql {
56+
type: ConnectionType.MY_SQL;
57+
table_name: string;
58+
}
59+
60+
interface TransferParamsMsSql {
61+
type: ConnectionType.MS_SQL;
62+
table_name: string;
63+
}
64+
65+
interface TransferParamsClickhouse {
66+
type: ConnectionType.CLICKHOUSE;
67+
table_name: string;
68+
}
69+
4970
interface TransferParamsHdfs {
5071
type: ConnectionType.HDFS;
5172
directory_path: string;

src/features/connection/ConnectionDetailInfo/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from 'react';
22
import { Descriptions } from 'antd';
33
import { Link } from 'react-router-dom';
4+
import { CONNECTION_TYPE_NAMES } from '@entities/connection';
45

56
import { ConnectionDetailInfoProps } from './types';
67
import { getConnectionAuthData, getConnectionData } from './utils';
@@ -21,7 +22,7 @@ export const ConnectionDetailInfo = ({ connection, group, ...props }: Connection
2122
<Link to={`/groups/${group.id}`}>{group.name}</Link>
2223
</Descriptions.Item>
2324
<Descriptions.Item label="Type" span={3}>
24-
{connection.connection_data.type}
25+
{CONNECTION_TYPE_NAMES[connection.connection_data.type]}
2526
</Descriptions.Item>
2627
{getConnectionAuthData({ data: connection.auth_data }).map((item, index) => (
2728
<Descriptions.Item label={item.label} span={3} key={index}>

src/features/connection/ConnectionList/constants.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react';
22
import { PaginationResponse } from '@shared/types';
33
import { TableColumns } from '@shared/ui';
44
import { Link } from 'react-router-dom';
5-
import { Connection } from '@entities/connection';
5+
import { Connection, CONNECTION_TYPE_NAMES } from '@entities/connection';
66

77
export const CONNECTION_LIST_COLUMNS: TableColumns<PaginationResponse<Connection>> = [
88
{
@@ -19,7 +19,7 @@ export const CONNECTION_LIST_COLUMNS: TableColumns<PaginationResponse<Connection
1919
{
2020
title: 'Type',
2121
dataIndex: 'connection_data',
22-
render: (data, record) => record.connection_data.type,
22+
render: (data, record) => CONNECTION_TYPE_NAMES[record.connection_data.type],
2323
width: 100,
2424
},
2525
{

src/features/connection/UpdateConnection/utils/getUpdateConnectionInitialValues/index.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,33 @@ export const getUpdateConnectionInitialValues = (connection: Connection): Update
4747
...connection.auth_data,
4848
});
4949
}
50+
if (
51+
connection.auth_data.type === ConnectionType.MS_SQL &&
52+
connection.connection_data.type === ConnectionType.MS_SQL
53+
) {
54+
return Object.assign(baseFormData, {
55+
...connection.connection_data,
56+
...connection.auth_data,
57+
});
58+
}
59+
if (
60+
connection.auth_data.type === ConnectionType.MY_SQL &&
61+
connection.connection_data.type === ConnectionType.MY_SQL
62+
) {
63+
return Object.assign(baseFormData, {
64+
...connection.connection_data,
65+
...connection.auth_data,
66+
});
67+
}
68+
if (
69+
connection.auth_data.type === ConnectionType.CLICKHOUSE &&
70+
connection.connection_data.type === ConnectionType.CLICKHOUSE
71+
) {
72+
return Object.assign(baseFormData, {
73+
...connection.connection_data,
74+
...connection.auth_data,
75+
});
76+
}
5077
return {
5178
name: connection.name,
5279
description: connection.description,

src/features/transfer/TransferDetailInfo/components/TransferParams/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React from 'react';
22
import { Descriptions } from 'antd';
3+
import { CONNECTION_TYPE_NAMES } from '@entities/connection';
34

45
import { TransferParamsProps } from './types';
56
import { getDescriptionItems } from './utils';
@@ -8,7 +9,7 @@ export const TransferParams = ({ data, ...props }: TransferParamsProps) => {
89
return (
910
<Descriptions {...props}>
1011
<Descriptions.Item label="Type" span={3}>
11-
{data.type}
12+
{CONNECTION_TYPE_NAMES[data.type]}
1213
</Descriptions.Item>
1314
{getDescriptionItems({ data }).map((item, index) => (
1415
<Descriptions.Item label={item.label} span={3} key={index}>

src/features/transfer/TransferDetailInfo/components/TransferParams/utils/getDescriptionItems/index.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ export const getDescriptionItems = ({ data }: GetDescriptionItemsProps): Descrip
2323
case ConnectionType.HIVE:
2424
case ConnectionType.ORACLE:
2525
case ConnectionType.POSTGRES:
26+
case ConnectionType.CLICKHOUSE:
27+
case ConnectionType.MY_SQL:
28+
case ConnectionType.MS_SQL:
2629
return [
2730
{
2831
label: 'Table name',

src/shared/types/connection.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
export enum ConnectionType {
2-
HIVE = 'hive',
2+
CLICKHOUSE = 'clickhouse',
33
HDFS = 'hdfs',
4+
HIVE = 'hive',
5+
MS_SQL = 'mssql',
6+
MY_SQL = 'mysql',
47
ORACLE = 'oracle',
58
POSTGRES = 'postgres',
6-
CLICKHOUSE = 'clickhouse',
7-
MY_SQL = 'mysql',
8-
MS_SQL = 'mssql',
99
S3 = 's3',
1010
}

0 commit comments

Comments
 (0)