Skip to content
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
74 changes: 70 additions & 4 deletions src/entities/connection/api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,32 @@ export type Connection = {
} & ConnectionData;

export type ConnectionData =
| ConnectionHive
| ConnectionFtp
| ConnectionFtps
| ConnectionSftp
| ConnectionWebdav
| ConnectionSamba
| ConnectionHdfs
| ConnectionS3
| ConnectionHive
| ConnectionOracle
| ConnectionPostgres
| ConnectionClickhouse
| ConnectionMySql
| ConnectionMsSql
| ConnectionS3;
| ConnectionMsSql;

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

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

export type ConnectionSambaProtocol = 'SMB' | 'NetBIOS';

export type ConnectionSambaAuthType = 'NTLMv1' | 'NTLMv2';

export enum ConnectionAuthType {
BASIC = 'basic',
S3 = 's3',
SAMBA = 'samba',
}

interface ConnectionAuthBasic {
Expand All @@ -38,6 +48,13 @@ interface ConnectionAuthS3 {
secret_key?: string;
}

interface ConnectionAuthSamba {
type: ConnectionAuthType.SAMBA;
user: string;
password?: string;
auth_type: ConnectionSambaAuthType;
}

export interface ConnectionHive {
type: ConnectionType.HIVE;
auth_data: ConnectionAuthBasic;
Expand Down Expand Up @@ -81,7 +98,7 @@ export interface ConnectionClickhouse {
connection_data: {
host: string;
port: number;
database_name: string;
database_name: string | null;
};
}

Expand All @@ -105,6 +122,55 @@ export interface ConnectionMsSql {
};
}

export interface ConnectionFtp {
type: ConnectionType.FTP;
auth_data: ConnectionAuthBasic;
connection_data: {
host: string;
port: number;
};
}

export interface ConnectionFtps {
type: ConnectionType.FTPS;
auth_data: ConnectionAuthBasic;
connection_data: {
host: string;
port: number;
};
}

export interface ConnectionSftp {
type: ConnectionType.SFTP;
auth_data: ConnectionAuthBasic;
connection_data: {
host: string;
port: number;
};
}

export interface ConnectionWebdav {
type: ConnectionType.WEBDAV;
auth_data: ConnectionAuthBasic;
connection_data: {
host: string;
port: number | null;
protocol: ConnectionProtocol;
};
}

export interface ConnectionSamba {
type: ConnectionType.SAMBA;
auth_data: ConnectionAuthSamba;
connection_data: {
host: string;
share: string;
port: number | null;
protocol: ConnectionSambaProtocol;
domain: string;
};
}

export interface ConnectionS3 {
type: ConnectionType.S3;
auth_data: ConnectionAuthS3;
Expand Down
1 change: 1 addition & 0 deletions src/entities/connection/assets/ftp.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 18 additions & 1 deletion src/entities/connection/assets/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,22 @@ import MssqlIcon from './mssql.svg';
import MysqlIcon from './mysql.svg';
import OracleIcon from './oracle.svg';
import PostgresIcon from './postgres.svg';
import WebDavIcon from './webdav.svg';
import SambaIcon from './samba.svg';
import FtpIcon from './ftp.svg';
import SftpIcon from './sftp.svg';

export { ClickhouseIcon, HdfsIcon, HiveIcon, MssqlIcon, MysqlIcon, OracleIcon, PostgresIcon, S3Icon };
export {
ClickhouseIcon,
HdfsIcon,
HiveIcon,
MssqlIcon,
MysqlIcon,
OracleIcon,
PostgresIcon,
S3Icon,
WebDavIcon,
SambaIcon,
FtpIcon,
SftpIcon,
};
1 change: 1 addition & 0 deletions src/entities/connection/assets/samba.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/entities/connection/assets/sftp.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 changes: 49 additions & 0 deletions src/entities/connection/assets/webdav.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 33 additions & 5 deletions src/entities/connection/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,69 @@ import React, { ReactNode } from 'react';
import { ConnectionType } from '@shared/types';
import { prepareOptionsForSelect } from '@shared/ui';

import { ClickhouseIcon, HdfsIcon, HiveIcon, MssqlIcon, MysqlIcon, OracleIcon, PostgresIcon, S3Icon } from './assets';
import {
ClickhouseIcon,
FtpIcon,
HdfsIcon,
HiveIcon,
MssqlIcon,
MysqlIcon,
OracleIcon,
PostgresIcon,
S3Icon,
SambaIcon,
SftpIcon,
WebDavIcon,
} from './assets';
import { ConnectionBucketStyle, ConnectionProtocol } from './api';

export const CONNECTION_TYPE_NAMES: Record<ConnectionType, string> = {
[ConnectionType.CLICKHOUSE]: 'ClickHouse',
[ConnectionType.FTP]: 'FTP',
[ConnectionType.FTPS]: 'FTPS',
[ConnectionType.SFTP]: 'SFTP',
[ConnectionType.WEBDAV]: 'WebDAV',
[ConnectionType.SAMBA]: 'Samba',
[ConnectionType.HDFS]: 'HDFS',
[ConnectionType.S3]: 'S3',
[ConnectionType.CLICKHOUSE]: 'ClickHouse',
[ConnectionType.HIVE]: 'Hive',
[ConnectionType.MS_SQL]: 'MSSQL',
[ConnectionType.MY_SQL]: 'MySQL',
[ConnectionType.ORACLE]: 'Oracle',
[ConnectionType.POSTGRES]: 'Postgres',
[ConnectionType.S3]: 'S3',
};

export const CONNECTION_ICONS: Record<ConnectionType, ReactNode> = {
[ConnectionType.CLICKHOUSE]: <ClickhouseIcon />,
[ConnectionType.FTP]: <FtpIcon />,
[ConnectionType.FTPS]: <FtpIcon />,
[ConnectionType.SFTP]: <SftpIcon />,
[ConnectionType.WEBDAV]: <WebDavIcon />,
[ConnectionType.SAMBA]: <SambaIcon />,
[ConnectionType.HDFS]: <HdfsIcon />,
[ConnectionType.S3]: <S3Icon />,
[ConnectionType.CLICKHOUSE]: <ClickhouseIcon />,
[ConnectionType.HIVE]: <HiveIcon />,
[ConnectionType.MS_SQL]: <MssqlIcon />,
[ConnectionType.MY_SQL]: <MysqlIcon />,
[ConnectionType.ORACLE]: <OracleIcon />,
[ConnectionType.POSTGRES]: <PostgresIcon />,
[ConnectionType.S3]: <S3Icon />,
};

export const CONNECTION_TYPE_SELECT_OPTIONS = prepareOptionsForSelect({
data: [
{ value: ConnectionType.CLICKHOUSE, label: CONNECTION_TYPE_NAMES[ConnectionType.CLICKHOUSE] },
{ value: ConnectionType.FTP, label: CONNECTION_TYPE_NAMES[ConnectionType.FTP] },
{ value: ConnectionType.FTPS, label: CONNECTION_TYPE_NAMES[ConnectionType.FTPS] },
{ value: ConnectionType.HDFS, label: CONNECTION_TYPE_NAMES[ConnectionType.HDFS] },
{ value: ConnectionType.HIVE, label: CONNECTION_TYPE_NAMES[ConnectionType.HIVE] },
{ value: ConnectionType.MS_SQL, label: CONNECTION_TYPE_NAMES[ConnectionType.MS_SQL] },
{ value: ConnectionType.MY_SQL, label: CONNECTION_TYPE_NAMES[ConnectionType.MY_SQL] },
{ value: ConnectionType.ORACLE, label: CONNECTION_TYPE_NAMES[ConnectionType.ORACLE] },
{ value: ConnectionType.POSTGRES, label: CONNECTION_TYPE_NAMES[ConnectionType.POSTGRES] },
{ value: ConnectionType.SAMBA, label: CONNECTION_TYPE_NAMES[ConnectionType.SAMBA] },
{ value: ConnectionType.SFTP, label: CONNECTION_TYPE_NAMES[ConnectionType.SFTP] },
{ value: ConnectionType.S3, label: CONNECTION_TYPE_NAMES[ConnectionType.S3] },
{ value: ConnectionType.WEBDAV, label: CONNECTION_TYPE_NAMES[ConnectionType.WEBDAV] },
],
renderLabel: (data) => data.label,
renderValue: (data) => data.value,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { ConnectionSambaAuthType } from '@entities/connection';
import { prepareOptionsForSelect } from '@shared/ui';

export const CONNECTION_SAMBA_AUTH_TYPE_SELECT_OPTIONS = prepareOptionsForSelect<ConnectionSambaAuthType>({
data: ['NTLMv1', 'NTLMv2'],
renderLabel: (data) => data,
renderValue: (data) => data,
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import React from 'react';
import { Form, Input } from 'antd';
import { Select } from '@shared/ui';

import { useSensitiveFields } from '../../hooks';

import { CONNECTION_SAMBA_AUTH_TYPE_SELECT_OPTIONS } from './constants';

export const ConnectionAuthSamba = () => {
const { isRequired } = useSensitiveFields();

return (
<>
{/* Hide Form.Item control, because its value is set in 'useSelectConnectionType' hook */}
<Form.Item name={['auth_data', 'type']} hidden>
<Input size="large" />
</Form.Item>
<Form.Item label="User" name={['auth_data', 'user']} rules={[{ required: true }]}>
<Input size="large" />
</Form.Item>
<Form.Item label="Password" name={['auth_data', 'password']} rules={[{ required: isRequired }]}>
<Input.Password size="large" />
</Form.Item>
<Form.Item name={['auth_data', 'auth_type']}>
<Select
size="large"
options={CONNECTION_SAMBA_AUTH_TYPE_SELECT_OPTIONS}
placeholder="Select connection protocol"
/>
</Form.Item>
</>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { ConnectionAuthBasic } from '../ConnectionAuthBasic';
export const ConnectionClickhouse = () => {
return (
<>
<Form.Item label="Database name" name={['connection_data', 'database_name']} rules={[{ required: true }]}>
<Form.Item label="Database name" name={['connection_data', 'database_name']}>
<Input size="large" />
</Form.Item>
<Form.Item label="Host" name={['connection_data', 'host']} rules={[{ required: true }]}>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React from 'react';
import { Form, Input, InputNumber } from 'antd';

import { MAX_ALLOWED_PORT, MIN_ALLOWED_PORT } from '../../constants';
import { ConnectionAuthBasic } from '../ConnectionAuthBasic';

export const ConnectionFtp = () => {
return (
<>
<Form.Item label="Host" name={['connection_data', 'host']} rules={[{ required: true }]}>
<Input size="large" />
</Form.Item>
<Form.Item label="Port" name={['connection_data', 'port']} rules={[{ required: true }]}>
<InputNumber size="large" min={MIN_ALLOWED_PORT} max={MAX_ALLOWED_PORT} />
</Form.Item>
<ConnectionAuthBasic />
</>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React from 'react';
import { Form, Input, InputNumber } from 'antd';

import { MAX_ALLOWED_PORT, MIN_ALLOWED_PORT } from '../../constants';
import { ConnectionAuthBasic } from '../ConnectionAuthBasic';

export const ConnectionSftp = () => {
return (
<>
<Form.Item label="Host" name={['connection_data', 'host']} rules={[{ required: true }]}>
<Input size="large" />
</Form.Item>
<Form.Item label="Port" name={['connection_data', 'port']} rules={[{ required: true }]}>
<InputNumber size="large" min={MIN_ALLOWED_PORT} max={MAX_ALLOWED_PORT} />
</Form.Item>
<ConnectionAuthBasic />
</>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ export const ConnectionS3 = () => {
<Form.Item label="Host" name={['connection_data', 'host']} rules={[{ required: true }]}>
<Input size="large" />
</Form.Item>
<Form.Item label="Protocol" name={['connection_data', 'protocol']} rules={[{ required: true }]}>
<Form.Item label="Protocol" name={['connection_data', 'protocol']}>
<Select size="large" options={CONNECTION_PROTOCOL_SELECT_OPTIONS} placeholder="Select connection protocol" />
</Form.Item>
<Form.Item label="Bucket style" name={['connection_data', 'bucket_style']} rules={[{ required: true }]}>
<Form.Item label="Bucket style" name={['connection_data', 'bucket_style']}>
Comment thread
dolfinus marked this conversation as resolved.
<Select
size="large"
options={CONNECTION_BUCKET_STYLE_SELECT_OPTIONS}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { ConnectionSambaProtocol } from '@entities/connection/api';
import { prepareOptionsForSelect } from '@shared/ui';

export const CONNECTION_SAMBA_PROTOCOL_SELECT_OPTIONS = prepareOptionsForSelect<ConnectionSambaProtocol>({
data: ['NetBIOS', 'SMB'],
renderLabel: (data) => data,
renderValue: (data) => data,
});
Loading