Skip to content

Commit

Permalink
add mysql export and import feature config
Browse files Browse the repository at this point in the history
  • Loading branch information
HSunboy committed Nov 14, 2023
1 parent 5cf7e32 commit c717fe5
Show file tree
Hide file tree
Showing 8 changed files with 101 additions and 60 deletions.
4 changes: 4 additions & 0 deletions src/common/datasource/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ export interface IDataSourceModeConfig {
plEdit?: boolean;
anonymousBlock?: boolean;
supportOBProxy?: boolean;
export: {
fileLimit: boolean;
snapshot: boolean;
};
};
schema: {
table: ICreateTableConfig;
Expand Down
4 changes: 4 additions & 0 deletions src/common/datasource/mysql/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ const items: Record<ConnectType.MYSQL, IDataSourceModeConfig> = {
obclient: true,
recycleBin: false,
sqlExplain: true,
export: {
fileLimit: false,
snapshot: false,
},
},
schema: {
table: tableConfig,
Expand Down
12 changes: 12 additions & 0 deletions src/common/datasource/oceanbase/obmysql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ const items: Record<
recycleBin: true,
sqlExplain: true,
supportOBProxy: true,
export: {
fileLimit: true,
snapshot: true,
},
},
schema: {
table: tableConfig,
Expand All @@ -101,6 +105,10 @@ const items: Record<
recycleBin: true,
sqlExplain: true,
supportOBProxy: true,
export: {
fileLimit: true,
snapshot: true,
},
},
schema: {
table: tableConfig,
Expand Down Expand Up @@ -128,6 +136,10 @@ const items: Record<
recycleBin: false,
sqlExplain: false,
supportOBProxy: true,
export: {
fileLimit: true,
snapshot: true,
},
},
schema: {
table: tableConfig,
Expand Down
8 changes: 8 additions & 0 deletions src/common/datasource/oceanbase/oboracle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ const items: Record<ConnectType.CLOUD_OB_ORACLE | ConnectType.OB_ORACLE, IDataSo
plEdit: true,
anonymousBlock: true,
supportOBProxy: true,
export: {
fileLimit: true,
snapshot: true,
},
},
schema: {
table: oracleTableConfig,
Expand Down Expand Up @@ -114,6 +118,10 @@ const items: Record<ConnectType.CLOUD_OB_ORACLE | ConnectType.OB_ORACLE, IDataSo
plEdit: true,
anonymousBlock: true,
supportOBProxy: true,
export: {
fileLimit: true,
snapshot: true,
},
},
schema: {
table: oracleTableConfig,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { formatMessage } from '@/util/intl';
import { AutoComplete, Checkbox, Col, Form, FormInstance, InputNumber, Row, Select } from 'antd';
import React, { useContext } from 'react';
import FormContext from '../FormContext';
import { getDataSourceModeConfig } from '@/common/datasource';

const FormItem = Form.Item;
const Option = Select.Option;
Expand All @@ -36,6 +37,7 @@ interface IProps {
}
const ConfigPanel: React.FC<IProps> = function ({ form, isReadonlyPublicConn, connection }) {
const formContext = useContext(FormContext);
const config = getDataSourceModeConfig(connection?.type);
const exportFileMaxSizeOpt = [
{
value: formatMessage({ id: 'odc.ExportForm.ConfigPanel.Unlimited' }), //无限制
Expand Down Expand Up @@ -178,43 +180,44 @@ const ConfigPanel: React.FC<IProps> = function ({ form, isReadonlyPublicConn, co
<MaskPolicySelecter required />
</Col>
)} */}
{config?.features?.export?.fileLimit && (
<Col span={8}>
<FormItem
style={{ marginBottom: 8 }}
label={
<span>
{
formatMessage({
id: 'odc.ExportForm.ConfigPanel.MaximumSizeOfASingle',
}) /*单个文件上限(MB)*/
}

<Col span={8}>
<FormItem
style={{ marginBottom: 8 }}
label={
<span>
<HelpDoc
{...{
doc: 'exportFileMaxSize',
leftText: true,
isTip: true,
}}
/>
</span>
}
name="exportFileMaxSize"
rules={[
{
formatMessage({
id: 'odc.ExportForm.ConfigPanel.MaximumSizeOfASingle',
}) /*单个文件上限(MB)*/
}

<HelpDoc
{...{
doc: 'exportFileMaxSize',
leftText: true,
isTip: true,
}}
/>
</span>
}
name="exportFileMaxSize"
rules={[
{
required: true,
message: formatMessage({
id: 'odc.ExportForm.ConfigPanel.PleaseFillInOrSelect',
}), //请填写或者选择单个文件上限(MB)
},
() => ({
validator,
}),
]}
>
<AutoComplete options={exportFileMaxSizeOpt} />
</FormItem>
</Col>
required: true,
message: formatMessage({
id: 'odc.ExportForm.ConfigPanel.PleaseFillInOrSelect',
}), //请填写或者选择单个文件上限(MB)
},
() => ({
validator,
}),
]}
>
<AutoComplete options={exportFileMaxSizeOpt} />
</FormItem>
</Col>
)}
</Row>
{isSQL && (
<FormItem
Expand Down Expand Up @@ -422,19 +425,21 @@ const ConfigPanel: React.FC<IProps> = function ({ form, isReadonlyPublicConn, co
</FormItem>
)}

<FormItem
name="globalSnapshot"
valuePropName="checked"
style={{ marginBottom: 4 }}
>
<Checkbox>
<HelpDoc leftText isTip doc="globalSnapshot">
{formatMessage({
id: 'odc.ExportDrawer.ExportForm.UseGlobalSnapshots',
})}
</HelpDoc>
</Checkbox>
</FormItem>
{config?.features?.export?.snapshot && (
<FormItem
name="globalSnapshot"
valuePropName="checked"
style={{ marginBottom: 4 }}
>
<Checkbox>
<HelpDoc leftText isTip doc="globalSnapshot">
{formatMessage({
id: 'odc.ExportDrawer.ExportForm.UseGlobalSnapshots',
})}
</HelpDoc>
</Checkbox>
</FormItem>
)}
</FormItemPanel>
)}

Expand Down Expand Up @@ -464,7 +469,6 @@ const ConfigPanel: React.FC<IProps> = function ({ form, isReadonlyPublicConn, co
</Checkbox>
</FormItem>
)}

<FormItem
name="withDropDDL"
rules={[
Expand Down Expand Up @@ -501,7 +505,7 @@ const ConfigPanel: React.FC<IProps> = function ({ form, isReadonlyPublicConn, co
>
<TaskTimer isReadonlyPublicConn={isReadonlyPublicConn} />
</FormItemPanel>
{odc.appConfig.connection.sys && odc.appConfig.task.sys && (
{odc.appConfig.connection.sys && odc.appConfig.task.sys && config?.connection?.sys && (
<FormItem noStyle shouldUpdate>
{({ getFieldValue }) => {
const exportDbObjects = getFieldValue('exportDbObjects');
Expand Down
24 changes: 15 additions & 9 deletions src/component/Task/ExportTask/CreateModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import React from 'react';
import ExportForm, { FormType } from './ExportForm';
import FormContext from './ExportForm/FormContext';
import styles from './index.less';
import { getDataSourceModeConfig } from '@/common/datasource';
export interface IProps {
modalStore?: ModalStore;
projectId?: number;
Expand Down Expand Up @@ -147,7 +148,6 @@ class CreateModal extends React.Component<IProps, IState> {
this.setState({
submitting: true,
});

const formData = {
...this.state.formData,
...values,
Expand All @@ -162,19 +162,25 @@ class CreateModal extends React.Component<IProps, IState> {
switch (exportContent) {
case EXPORT_CONTENT.DATA_AND_STRUCT: {
formData.mergeSchemaFiles = false;
formData.exportFileMaxSize =
exportFileMaxSize === formatMessage({ id: 'odc.components.ExportDrawer.Unlimited' }) //无限制
? -1
: parseInt(exportFileMaxSize as string);
if (formData.exportFileMaxSize) {
formData.exportFileMaxSize =
exportFileMaxSize ===
formatMessage({ id: 'odc.components.ExportDrawer.Unlimited' }) //无限制
? -1
: parseInt(exportFileMaxSize as string);
}
break;
}
case EXPORT_CONTENT.DATA: {
formData.withDropDDL = false;
formData.mergeSchemaFiles = false;
formData.exportFileMaxSize =
exportFileMaxSize === formatMessage({ id: 'odc.components.ExportDrawer.Unlimited' }) //无限制
? -1
: parseInt(exportFileMaxSize as string);
if (formData.exportFileMaxSize) {
formData.exportFileMaxSize =
exportFileMaxSize ===
formatMessage({ id: 'odc.components.ExportDrawer.Unlimited' }) //无限制
? -1
: parseInt(exportFileMaxSize as string);
}
break;
}
case EXPORT_CONTENT.STRUCT: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import DatabaseSelect from '../../../../component/DatabaseSelect';
import CsvMapping from '../../csvMapping';
import CsvProvider from '../CsvProvider';
import StructDataFormItem from '../formitem/StructDataFormItem';
import { getDataSourceModeConfig } from '@/common/datasource';

const FormItem = Form.Item;

Expand All @@ -53,6 +54,7 @@ const FileSelecterPanel: React.FC<IProps> = function ({
const databaseName = database?.name;
const dataTypes = session?.dataTypes ?? [];
const isOracle = connection?.dialectType === ConnectionMode.OB_ORACLE;
const config = getDataSourceModeConfig(connection?.type);
async function fetchTable(dbName: string) {
const tables = await getTableListByDatabaseName(session?.sessionId, dbName);
setTables(tables);
Expand Down Expand Up @@ -218,7 +220,7 @@ const FileSelecterPanel: React.FC<IProps> = function ({
);
}}
</FormItem>
{odc.appConfig.connection.sys && odc.appConfig.task.sys && (
{odc.appConfig.connection.sys && odc.appConfig.task.sys && config?.connection?.sys && (
<SysFormItem
tip={(useSys: boolean, existSys: boolean, enforce: boolean) => {
if (!useSys) {
Expand Down
1 change: 1 addition & 0 deletions src/component/Task/component/DataTransferModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import React from 'react';
import CsvTable from './csvTables';
import styles from './index.less';
import ObjTable from './ObjTables';
import { getDataSourceModeConfig } from '@/common/datasource';
const SimpleTextItem: React.FC<{
label: string;
content: React.ReactNode;
Expand Down

0 comments on commit c717fe5

Please sign in to comment.