From c717fe532cce52730d860f2a51b985685e7c8d10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=93=E5=BA=B7?= Date: Tue, 14 Nov 2023 13:48:44 +0800 Subject: [PATCH] add mysql export and import feature config --- src/common/datasource/interface.ts | 4 + src/common/datasource/mysql/index.tsx | 4 + src/common/datasource/oceanbase/obmysql.ts | 12 ++ src/common/datasource/oceanbase/oboracle.ts | 8 ++ .../ExportForm/ConfigPanel/index.tsx | 104 +++++++++--------- .../Task/ExportTask/CreateModal/index.tsx | 24 ++-- .../ImportForm/ConfigPanel/index.tsx | 4 +- .../component/DataTransferModal/index.tsx | 1 + 8 files changed, 101 insertions(+), 60 deletions(-) diff --git a/src/common/datasource/interface.ts b/src/common/datasource/interface.ts index 96cb8341e..e90d182b1 100644 --- a/src/common/datasource/interface.ts +++ b/src/common/datasource/interface.ts @@ -129,6 +129,10 @@ export interface IDataSourceModeConfig { plEdit?: boolean; anonymousBlock?: boolean; supportOBProxy?: boolean; + export: { + fileLimit: boolean; + snapshot: boolean; + }; }; schema: { table: ICreateTableConfig; diff --git a/src/common/datasource/mysql/index.tsx b/src/common/datasource/mysql/index.tsx index dc0c1adeb..fdfa10f07 100644 --- a/src/common/datasource/mysql/index.tsx +++ b/src/common/datasource/mysql/index.tsx @@ -79,6 +79,10 @@ const items: Record = { obclient: true, recycleBin: false, sqlExplain: true, + export: { + fileLimit: false, + snapshot: false, + }, }, schema: { table: tableConfig, diff --git a/src/common/datasource/oceanbase/obmysql.ts b/src/common/datasource/oceanbase/obmysql.ts index 66d5a695f..0ecc98d73 100644 --- a/src/common/datasource/oceanbase/obmysql.ts +++ b/src/common/datasource/oceanbase/obmysql.ts @@ -75,6 +75,10 @@ const items: Record< recycleBin: true, sqlExplain: true, supportOBProxy: true, + export: { + fileLimit: true, + snapshot: true, + }, }, schema: { table: tableConfig, @@ -101,6 +105,10 @@ const items: Record< recycleBin: true, sqlExplain: true, supportOBProxy: true, + export: { + fileLimit: true, + snapshot: true, + }, }, schema: { table: tableConfig, @@ -128,6 +136,10 @@ const items: Record< recycleBin: false, sqlExplain: false, supportOBProxy: true, + export: { + fileLimit: true, + snapshot: true, + }, }, schema: { table: tableConfig, diff --git a/src/common/datasource/oceanbase/oboracle.ts b/src/common/datasource/oceanbase/oboracle.ts index c8de12149..d1665a9a1 100644 --- a/src/common/datasource/oceanbase/oboracle.ts +++ b/src/common/datasource/oceanbase/oboracle.ts @@ -76,6 +76,10 @@ const items: Record = function ({ form, isReadonlyPublicConn, connection }) { const formContext = useContext(FormContext); + const config = getDataSourceModeConfig(connection?.type); const exportFileMaxSizeOpt = [ { value: formatMessage({ id: 'odc.ExportForm.ConfigPanel.Unlimited' }), //无限制 @@ -178,43 +180,44 @@ const ConfigPanel: React.FC = function ({ form, isReadonlyPublicConn, co )} */} + {config?.features?.export?.fileLimit && ( + + + { + formatMessage({ + id: 'odc.ExportForm.ConfigPanel.MaximumSizeOfASingle', + }) /*单个文件上限(MB)*/ + } - - + + + } + name="exportFileMaxSize" + rules={[ { - formatMessage({ - id: 'odc.ExportForm.ConfigPanel.MaximumSizeOfASingle', - }) /*单个文件上限(MB)*/ - } - - - - } - name="exportFileMaxSize" - rules={[ - { - required: true, - message: formatMessage({ - id: 'odc.ExportForm.ConfigPanel.PleaseFillInOrSelect', - }), //请填写或者选择单个文件上限(MB) - }, - () => ({ - validator, - }), - ]} - > - - - + required: true, + message: formatMessage({ + id: 'odc.ExportForm.ConfigPanel.PleaseFillInOrSelect', + }), //请填写或者选择单个文件上限(MB) + }, + () => ({ + validator, + }), + ]} + > + + + + )} {isSQL && ( = function ({ form, isReadonlyPublicConn, co )} - - - - {formatMessage({ - id: 'odc.ExportDrawer.ExportForm.UseGlobalSnapshots', - })} - - - + {config?.features?.export?.snapshot && ( + + + + {formatMessage({ + id: 'odc.ExportDrawer.ExportForm.UseGlobalSnapshots', + })} + + + + )} )} @@ -464,7 +469,6 @@ const ConfigPanel: React.FC = function ({ form, isReadonlyPublicConn, co )} - = function ({ form, isReadonlyPublicConn, co > - {odc.appConfig.connection.sys && odc.appConfig.task.sys && ( + {odc.appConfig.connection.sys && odc.appConfig.task.sys && config?.connection?.sys && ( {({ getFieldValue }) => { const exportDbObjects = getFieldValue('exportDbObjects'); diff --git a/src/component/Task/ExportTask/CreateModal/index.tsx b/src/component/Task/ExportTask/CreateModal/index.tsx index 47218bc87..36f0f5997 100644 --- a/src/component/Task/ExportTask/CreateModal/index.tsx +++ b/src/component/Task/ExportTask/CreateModal/index.tsx @@ -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; @@ -147,7 +148,6 @@ class CreateModal extends React.Component { this.setState({ submitting: true, }); - const formData = { ...this.state.formData, ...values, @@ -162,19 +162,25 @@ class CreateModal extends React.Component { 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: { diff --git a/src/component/Task/ImportTask/CreateModal/ImportForm/ConfigPanel/index.tsx b/src/component/Task/ImportTask/CreateModal/ImportForm/ConfigPanel/index.tsx index f7f6d5c34..88f1d6f49 100644 --- a/src/component/Task/ImportTask/CreateModal/ImportForm/ConfigPanel/index.tsx +++ b/src/component/Task/ImportTask/CreateModal/ImportForm/ConfigPanel/index.tsx @@ -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; @@ -53,6 +54,7 @@ const FileSelecterPanel: React.FC = 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); @@ -218,7 +220,7 @@ const FileSelecterPanel: React.FC = function ({ ); }} - {odc.appConfig.connection.sys && odc.appConfig.task.sys && ( + {odc.appConfig.connection.sys && odc.appConfig.task.sys && config?.connection?.sys && ( { if (!useSys) { diff --git a/src/component/Task/component/DataTransferModal/index.tsx b/src/component/Task/component/DataTransferModal/index.tsx index 1c1b852da..dee5d4aa1 100644 --- a/src/component/Task/component/DataTransferModal/index.tsx +++ b/src/component/Task/component/DataTransferModal/index.tsx @@ -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;