Skip to content

Commit e56a5ce

Browse files
author
Zabilsya
committed
[DOP-22300] add increment_by field
1 parent 41ce398 commit e56a5ce

File tree

19 files changed

+153
-18
lines changed

19 files changed

+153
-18
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ export const ConnectionAuthBasic = () => {
88

99
return (
1010
<>
11-
<Form.Item name={['auth_data', 'type']} hidden />
11+
<Form.Item name={['auth_data', 'type']} hidden>
12+
<Input size="large" />
13+
</Form.Item>
1214
<Form.Item label="User" name={['auth_data', 'user']} rules={[{ required: true }]}>
1315
<Input size="large" />
1416
</Form.Item>

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ export const ConnectionAuthS3 = () => {
88

99
return (
1010
<>
11-
<Form.Item name={['auth_data', 'type']} hidden />
11+
<Form.Item name={['auth_data', 'type']} hidden>
12+
<Input size="large" />
13+
</Form.Item>
1214
<Form.Item label="Access key" name={['auth_data', 'access_key']} rules={[{ required: true }]}>
1315
<Input size="large" />
1416
</Form.Item>

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,18 @@ export const ConnectionOracle = () => {
1111
const [isSidDisabled, setSidDisabled] = useState(false);
1212

1313
const changeDisabledFields = useCallback(() => {
14-
const serviceName = form.getFieldValue('service_name');
15-
const sid = form.getFieldValue('sid');
14+
const serviceName = form.getFieldValue(['connection_data', 'service_name']);
15+
const sid = form.getFieldValue(['connection_data', 'sid']);
1616
setServiceNameDisabled(!!sid);
1717
setSidDisabled(!!serviceName);
1818
}, [form]);
1919

2020
const handleFieldChange = () => {
2121
changeDisabledFields();
22-
form.validateFields(['service_name', 'sid']);
22+
form.validateFields([
23+
['connection_data', 'service_name'],
24+
['connection_data', 'sid'],
25+
]);
2326
};
2427

2528
//* It needs to validate required fields service_name and sid correctly if they have initial values

src/entities/group/api/hooks/useGetInitialGroup/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ export const useGetInitialGroup = ({ id }: GetGroupRequest): UseQueryResult<Grou
1010
queryKey: [GroupQueryKey.GET_GROUP, id],
1111
queryFn: () => groupService.getGroup({ id }),
1212
enabled: !!id,
13+
throwOnError: false,
1314
});
1415
};

src/entities/transfer/api/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export type TransferConnectionParamFieldName = 'source_params' | 'target_params'
3838

3939
export interface TransferStrategyParams {
4040
type: 'full' | 'incremental';
41+
increment_by?: string;
4142
}
4243

4344
interface TransferParamsHive {

src/entities/transfer/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
export * from './api';
2-
export * from './constants';
32
export * from './ui';
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import React from 'react';
2+
import { ConnectionType } from '@shared/types';
3+
import { Form, Input } from 'antd';
4+
5+
import { IncrementByFormProps } from './types';
6+
7+
export const IncrementByForm = ({ sourceConnectionType }: IncrementByFormProps) => {
8+
switch (sourceConnectionType) {
9+
case ConnectionType.CLICKHOUSE:
10+
case ConnectionType.HIVE:
11+
case ConnectionType.MS_SQL:
12+
case ConnectionType.MY_SQL:
13+
case ConnectionType.ORACLE:
14+
case ConnectionType.POSTGRES:
15+
return (
16+
<Form.Item label="Increment by" name={['strategy_params', 'increment_by']} rules={[{ required: true }]}>
17+
<Input size="large" />
18+
</Form.Item>
19+
);
20+
case ConnectionType.HDFS:
21+
case ConnectionType.S3:
22+
return null;
23+
}
24+
};
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { ConnectionType } from '@shared/types';
2+
3+
export interface IncrementByFormProps {
4+
sourceConnectionType: ConnectionType;
5+
}

src/entities/transfer/constants.ts renamed to src/features/transfer/MutateTransferForm/components/StrategyParams/components/StrategyTypeForm/constants.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1+
import { TransferStrategyParams } from '@entities/transfer';
12
import { prepareOptionsForSelect } from '@shared/ui';
23

3-
import { TransferStrategyParams } from './api';
4-
54
export const TRANSFER_STRATEGY_PARAMS_SELECT_OPTIONS = prepareOptionsForSelect<TransferStrategyParams['type']>({
65
data: ['full', 'incremental'],
76
renderLabel: (data) => data,
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import React, { useLayoutEffect, useState } from 'react';
2+
import { Select } from '@shared/ui';
3+
import { Form } from 'antd';
4+
import { ConnectionType } from '@shared/types';
5+
6+
import { TRANSFER_STRATEGY_PARAMS_SELECT_OPTIONS } from './constants';
7+
import { StrategyTypeFormProps } from './types';
8+
9+
export const StrategyTypeForm = ({ sourceConnectionType }: StrategyTypeFormProps) => {
10+
const [isDisabled, setDisabled] = useState(false);
11+
const formInstance = Form.useFormInstance();
12+
13+
// change strategy_params type value and disabled field state depending on source connection type
14+
useLayoutEffect(() => {
15+
switch (sourceConnectionType) {
16+
case ConnectionType.HDFS:
17+
case ConnectionType.S3:
18+
setDisabled(true);
19+
return formInstance.setFieldValue(['strategy_params', 'type'], 'full');
20+
case ConnectionType.CLICKHOUSE:
21+
case ConnectionType.HIVE:
22+
case ConnectionType.MS_SQL:
23+
case ConnectionType.MY_SQL:
24+
case ConnectionType.ORACLE:
25+
case ConnectionType.POSTGRES:
26+
return setDisabled(false);
27+
}
28+
}, [formInstance, sourceConnectionType]);
29+
30+
return (
31+
<Form.Item label="Strategy params" name={['strategy_params', 'type']} rules={[{ required: true }]}>
32+
<Select
33+
size="large"
34+
options={TRANSFER_STRATEGY_PARAMS_SELECT_OPTIONS}
35+
placeholder="Select strategy"
36+
disabled={isDisabled}
37+
/>
38+
</Form.Item>
39+
);
40+
};

0 commit comments

Comments
 (0)