Skip to content

Commit a5814b5

Browse files
ZabilsyaZabilsya
andauthored
[DOP-22298] add new connection types (#75)
Co-authored-by: Zabilsya <[email protected]>
1 parent b5396b6 commit a5814b5

File tree

50 files changed

+553
-256
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+553
-256
lines changed

src/entities/connection/api/types.ts

Lines changed: 70 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,32 @@ export type Connection = {
88
} & ConnectionData;
99

1010
export type ConnectionData =
11-
| ConnectionHive
11+
| ConnectionFtp
12+
| ConnectionFtps
13+
| ConnectionSftp
14+
| ConnectionWebdav
15+
| ConnectionSamba
1216
| ConnectionHdfs
17+
| ConnectionS3
18+
| ConnectionHive
1319
| ConnectionOracle
1420
| ConnectionPostgres
1521
| ConnectionClickhouse
1622
| ConnectionMySql
17-
| ConnectionMsSql
18-
| ConnectionS3;
23+
| ConnectionMsSql;
1924

2025
export type ConnectionBucketStyle = 'domain' | 'path';
2126

2227
export type ConnectionProtocol = 'https' | 'http';
2328

29+
export type ConnectionSambaProtocol = 'SMB' | 'NetBIOS';
30+
31+
export type ConnectionSambaAuthType = 'NTLMv1' | 'NTLMv2';
32+
2433
export enum ConnectionAuthType {
2534
BASIC = 'basic',
2635
S3 = 's3',
36+
SAMBA = 'samba',
2737
}
2838

2939
interface ConnectionAuthBasic {
@@ -38,6 +48,13 @@ interface ConnectionAuthS3 {
3848
secret_key?: string;
3949
}
4050

51+
interface ConnectionAuthSamba {
52+
type: ConnectionAuthType.SAMBA;
53+
user: string;
54+
password?: string;
55+
auth_type: ConnectionSambaAuthType;
56+
}
57+
4158
export interface ConnectionHive {
4259
type: ConnectionType.HIVE;
4360
auth_data: ConnectionAuthBasic;
@@ -81,7 +98,7 @@ export interface ConnectionClickhouse {
8198
connection_data: {
8299
host: string;
83100
port: number;
84-
database_name: string;
101+
database_name: string | null;
85102
};
86103
}
87104

@@ -105,6 +122,55 @@ export interface ConnectionMsSql {
105122
};
106123
}
107124

125+
export interface ConnectionFtp {
126+
type: ConnectionType.FTP;
127+
auth_data: ConnectionAuthBasic;
128+
connection_data: {
129+
host: string;
130+
port: number;
131+
};
132+
}
133+
134+
export interface ConnectionFtps {
135+
type: ConnectionType.FTPS;
136+
auth_data: ConnectionAuthBasic;
137+
connection_data: {
138+
host: string;
139+
port: number;
140+
};
141+
}
142+
143+
export interface ConnectionSftp {
144+
type: ConnectionType.SFTP;
145+
auth_data: ConnectionAuthBasic;
146+
connection_data: {
147+
host: string;
148+
port: number;
149+
};
150+
}
151+
152+
export interface ConnectionWebdav {
153+
type: ConnectionType.WEBDAV;
154+
auth_data: ConnectionAuthBasic;
155+
connection_data: {
156+
host: string;
157+
port: number | null;
158+
protocol: ConnectionProtocol;
159+
};
160+
}
161+
162+
export interface ConnectionSamba {
163+
type: ConnectionType.SAMBA;
164+
auth_data: ConnectionAuthSamba;
165+
connection_data: {
166+
host: string;
167+
share: string;
168+
port: number | null;
169+
protocol: ConnectionSambaProtocol;
170+
domain: string;
171+
};
172+
}
173+
108174
export interface ConnectionS3 {
109175
type: ConnectionType.S3;
110176
auth_data: ConnectionAuthS3;
Lines changed: 1 addition & 0 deletions
Loading

src/entities/connection/assets/index.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,22 @@ import MssqlIcon from './mssql.svg';
66
import MysqlIcon from './mysql.svg';
77
import OracleIcon from './oracle.svg';
88
import PostgresIcon from './postgres.svg';
9+
import WebDavIcon from './webdav.svg';
10+
import SambaIcon from './samba.svg';
11+
import FtpIcon from './ftp.svg';
12+
import SftpIcon from './sftp.svg';
913

10-
export { ClickhouseIcon, HdfsIcon, HiveIcon, MssqlIcon, MysqlIcon, OracleIcon, PostgresIcon, S3Icon };
14+
export {
15+
ClickhouseIcon,
16+
HdfsIcon,
17+
HiveIcon,
18+
MssqlIcon,
19+
MysqlIcon,
20+
OracleIcon,
21+
PostgresIcon,
22+
S3Icon,
23+
WebDavIcon,
24+
SambaIcon,
25+
FtpIcon,
26+
SftpIcon,
27+
};

src/entities/connection/assets/samba.svg

Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 49 additions & 0 deletions
Loading

src/entities/connection/constants.tsx

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,41 +2,69 @@ import React, { ReactNode } from 'react';
22
import { ConnectionType } from '@shared/types';
33
import { prepareOptionsForSelect } from '@shared/ui';
44

5-
import { ClickhouseIcon, HdfsIcon, HiveIcon, MssqlIcon, MysqlIcon, OracleIcon, PostgresIcon, S3Icon } from './assets';
5+
import {
6+
ClickhouseIcon,
7+
FtpIcon,
8+
HdfsIcon,
9+
HiveIcon,
10+
MssqlIcon,
11+
MysqlIcon,
12+
OracleIcon,
13+
PostgresIcon,
14+
S3Icon,
15+
SambaIcon,
16+
SftpIcon,
17+
WebDavIcon,
18+
} from './assets';
619
import { ConnectionBucketStyle, ConnectionProtocol } from './api';
720

821
export const CONNECTION_TYPE_NAMES: Record<ConnectionType, string> = {
9-
[ConnectionType.CLICKHOUSE]: 'ClickHouse',
22+
[ConnectionType.FTP]: 'FTP',
23+
[ConnectionType.FTPS]: 'FTPS',
24+
[ConnectionType.SFTP]: 'SFTP',
25+
[ConnectionType.WEBDAV]: 'WebDAV',
26+
[ConnectionType.SAMBA]: 'Samba',
1027
[ConnectionType.HDFS]: 'HDFS',
28+
[ConnectionType.S3]: 'S3',
29+
[ConnectionType.CLICKHOUSE]: 'ClickHouse',
1130
[ConnectionType.HIVE]: 'Hive',
1231
[ConnectionType.MS_SQL]: 'MSSQL',
1332
[ConnectionType.MY_SQL]: 'MySQL',
1433
[ConnectionType.ORACLE]: 'Oracle',
1534
[ConnectionType.POSTGRES]: 'Postgres',
16-
[ConnectionType.S3]: 'S3',
1735
};
1836

1937
export const CONNECTION_ICONS: Record<ConnectionType, ReactNode> = {
20-
[ConnectionType.CLICKHOUSE]: <ClickhouseIcon />,
38+
[ConnectionType.FTP]: <FtpIcon />,
39+
[ConnectionType.FTPS]: <FtpIcon />,
40+
[ConnectionType.SFTP]: <SftpIcon />,
41+
[ConnectionType.WEBDAV]: <WebDavIcon />,
42+
[ConnectionType.SAMBA]: <SambaIcon />,
2143
[ConnectionType.HDFS]: <HdfsIcon />,
44+
[ConnectionType.S3]: <S3Icon />,
45+
[ConnectionType.CLICKHOUSE]: <ClickhouseIcon />,
2246
[ConnectionType.HIVE]: <HiveIcon />,
2347
[ConnectionType.MS_SQL]: <MssqlIcon />,
2448
[ConnectionType.MY_SQL]: <MysqlIcon />,
2549
[ConnectionType.ORACLE]: <OracleIcon />,
2650
[ConnectionType.POSTGRES]: <PostgresIcon />,
27-
[ConnectionType.S3]: <S3Icon />,
2851
};
2952

3053
export const CONNECTION_TYPE_SELECT_OPTIONS = prepareOptionsForSelect({
3154
data: [
3255
{ value: ConnectionType.CLICKHOUSE, label: CONNECTION_TYPE_NAMES[ConnectionType.CLICKHOUSE] },
56+
{ value: ConnectionType.FTP, label: CONNECTION_TYPE_NAMES[ConnectionType.FTP] },
57+
{ value: ConnectionType.FTPS, label: CONNECTION_TYPE_NAMES[ConnectionType.FTPS] },
3358
{ value: ConnectionType.HDFS, label: CONNECTION_TYPE_NAMES[ConnectionType.HDFS] },
3459
{ value: ConnectionType.HIVE, label: CONNECTION_TYPE_NAMES[ConnectionType.HIVE] },
3560
{ value: ConnectionType.MS_SQL, label: CONNECTION_TYPE_NAMES[ConnectionType.MS_SQL] },
3661
{ value: ConnectionType.MY_SQL, label: CONNECTION_TYPE_NAMES[ConnectionType.MY_SQL] },
3762
{ value: ConnectionType.ORACLE, label: CONNECTION_TYPE_NAMES[ConnectionType.ORACLE] },
3863
{ value: ConnectionType.POSTGRES, label: CONNECTION_TYPE_NAMES[ConnectionType.POSTGRES] },
64+
{ value: ConnectionType.SAMBA, label: CONNECTION_TYPE_NAMES[ConnectionType.SAMBA] },
65+
{ value: ConnectionType.SFTP, label: CONNECTION_TYPE_NAMES[ConnectionType.SFTP] },
3966
{ value: ConnectionType.S3, label: CONNECTION_TYPE_NAMES[ConnectionType.S3] },
67+
{ value: ConnectionType.WEBDAV, label: CONNECTION_TYPE_NAMES[ConnectionType.WEBDAV] },
4068
],
4169
renderLabel: (data) => data.label,
4270
renderValue: (data) => data.value,
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { ConnectionSambaAuthType } from '@entities/connection';
2+
import { prepareOptionsForSelect } from '@shared/ui';
3+
4+
export const CONNECTION_SAMBA_AUTH_TYPE_SELECT_OPTIONS = prepareOptionsForSelect<ConnectionSambaAuthType>({
5+
data: ['NTLMv1', 'NTLMv2'],
6+
renderLabel: (data) => data,
7+
renderValue: (data) => data,
8+
});
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import React from 'react';
2+
import { Form, Input } from 'antd';
3+
import { Select } from '@shared/ui';
4+
5+
import { useSensitiveFields } from '../../hooks';
6+
7+
import { CONNECTION_SAMBA_AUTH_TYPE_SELECT_OPTIONS } from './constants';
8+
9+
export const ConnectionAuthSamba = () => {
10+
const { isRequired } = useSensitiveFields();
11+
12+
return (
13+
<>
14+
{/* Hide Form.Item control, because its value is set in 'useSelectConnectionType' hook */}
15+
<Form.Item name={['auth_data', 'type']} hidden>
16+
<Input size="large" />
17+
</Form.Item>
18+
<Form.Item label="User" name={['auth_data', 'user']} rules={[{ required: true }]}>
19+
<Input size="large" />
20+
</Form.Item>
21+
<Form.Item label="Password" name={['auth_data', 'password']} rules={[{ required: isRequired }]}>
22+
<Input.Password size="large" />
23+
</Form.Item>
24+
<Form.Item name={['auth_data', 'auth_type']}>
25+
<Select
26+
size="large"
27+
options={CONNECTION_SAMBA_AUTH_TYPE_SELECT_OPTIONS}
28+
placeholder="Select connection protocol"
29+
/>
30+
</Form.Item>
31+
</>
32+
);
33+
};

src/entities/connection/ui/ConnectionTypeForm/components/ConnectionClickhouse/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { ConnectionAuthBasic } from '../ConnectionAuthBasic';
77
export const ConnectionClickhouse = () => {
88
return (
99
<>
10-
<Form.Item label="Database name" name={['connection_data', 'database_name']} rules={[{ required: true }]}>
10+
<Form.Item label="Database name" name={['connection_data', 'database_name']}>
1111
<Input size="large" />
1212
</Form.Item>
1313
<Form.Item label="Host" name={['connection_data', 'host']} rules={[{ required: true }]}>

0 commit comments

Comments
 (0)