Unverified Commit c32067d7 authored by zhu-mingye's avatar zhu-mingye Committed by GitHub

optimization some code (#2110)

parent d58f1c3e
...@@ -21,10 +21,12 @@ import {Values} from 'async-validator'; ...@@ -21,10 +21,12 @@ import {Values} from 'async-validator';
import {ProForm, ProFormGroup, ProFormSelect, ProFormText} from '@ant-design/pro-components'; import {ProForm, ProFormGroup, ProFormSelect, ProFormText} from '@ant-design/pro-components';
import {l} from '@/utils/intl'; import {l} from '@/utils/intl';
import {DataSources} from '@/types/RegCenter/data.d'; import {DataSources} from '@/types/RegCenter/data.d';
import {AUTO_COMPLETE_TYPE, GROUP_TYPE} from '@/pages/RegCenter/DataSource/components/constants'; import {DATA_SOURCE_TYPE_OPTIONS,
AUTO_COMPLETE_TYPE,
GROUP_TYPE
} from '@/pages/RegCenter/DataSource/components/constants';
import {AutoComplete, Input} from 'antd'; import {AutoComplete, Input} from 'antd';
import CodeEdit from '@/components/CustomEditor/CodeEdit'; import CodeEdit from '@/components/CustomEditor/CodeEdit';
import {renderDataSourceType} from '@/pages/RegCenter/DataSource/components/function';
type DataSourceProFormProps = { type DataSourceProFormProps = {
values: Partial<DataSources.DataSource>, values: Partial<DataSources.DataSource>,
...@@ -80,7 +82,8 @@ const DataSourceProForm: React.FC<DataSourceProFormProps> = (props) => { ...@@ -80,7 +82,8 @@ const DataSourceProForm: React.FC<DataSourceProFormProps> = (props) => {
width={'sm'} width={'sm'}
label={l('rc.ds.type')} label={l('rc.ds.type')}
showSearch showSearch
options={renderDataSourceType()} initialValue={dbType}
options={DATA_SOURCE_TYPE_OPTIONS}
rules={[{required: true, message: l('rc.ds.typePlaceholder')}]} rules={[{required: true, message: l('rc.ds.typePlaceholder')}]}
placeholder={l('rc.ds.typePlaceholder')} placeholder={l('rc.ds.typePlaceholder')}
......
...@@ -21,30 +21,58 @@ import {l} from '@/utils/intl'; ...@@ -21,30 +21,58 @@ import {l} from '@/utils/intl';
/** /**
* data source type * data source type
*/ */
export const DATA_SOURCE_TYPE = [
export const DATA_SOURCE_TYPE_OPTIONS = [
{ {
type: 'MySQL', label: l('rc.ds.source'),
}, { options: [
type: 'Oracle', {
label: 'MySQL',
value: 'MySQL',
}, { }, {
type: 'PostgreSQL', label: 'Oracle',
value: 'Oracle',
},
],
},
{
label: l('rc.ds.source'),
options: [
{
label: 'PostgreSQL',
value: 'PostgreSQL',
}, { }, {
type: 'ClickHouse', label: 'ClickHouse',
value: 'ClickHouse',
}, { }, {
type: 'SQLServer', label: 'SQLServer',
value: 'SQLServer',
},
],
}, { }, {
type: 'Doris', label: l('rc.ds.source'),
options: [
{
label: 'Doris',
value: 'Doris',
}, { }, {
type: 'Phoenix', label: 'Phoenix',
value: 'Phoenix',
}, { }, {
type: 'Hive', label: 'Hive',
value: 'Hive',
}, { }, {
type: 'StarRocks', label: 'StarRocks',
value: 'StarRocks',
}, { }, {
type: 'Presto', label: 'Presto',
value: 'Presto',
}
],
} }
]; ];
/** /**
* data source group type * data source group type
*/ */
......
...@@ -16,8 +16,7 @@ ...@@ -16,8 +16,7 @@
*/ */
import {DATA_SOURCE_TYPE, QUERY_KEYWORD} from '@/pages/RegCenter/DataSource/components/constants'; import { QUERY_KEYWORD} from '@/pages/RegCenter/DataSource/components/constants';
import {DefaultOptionType} from 'antd/es/select';
import { import {
ClickHouseIcons, DefaultDBIcons, ClickHouseIcons, DefaultDBIcons,
DorisIcons, HiveIcons, DorisIcons, HiveIcons,
...@@ -60,21 +59,6 @@ export const renderDBIcon = (type: string, size?: number) => { ...@@ -60,21 +59,6 @@ export const renderDBIcon = (type: string, size?: number) => {
} }
}; };
/**
* render DataSourceType
*/
export const renderDataSourceType = () => {
let dataSourceType: DefaultOptionType[] = [];
DATA_SOURCE_TYPE.forEach((item: { type: string }) => {
dataSourceType.push({
key: item.type,
value: item.type,
label: item.type,
});
});
return dataSourceType;
};
export const buildColumnsQueryKeyWord = (data: string[]) => { export const buildColumnsQueryKeyWord = (data: string[]) => {
const result = data.concat(QUERY_KEYWORD).map((item: string | number) => ({ const result = data.concat(QUERY_KEYWORD).map((item: string | number) => ({
value: item, value: item,
......
...@@ -39,16 +39,11 @@ const FileTree: React.FC<FileTreeProps> = (props) => { ...@@ -39,16 +39,11 @@ const FileTree: React.FC<FileTreeProps> = (props) => {
const {treeData, onNodeClick, onRightClick} = props; const {treeData, onNodeClick, onRightClick} = props;
return <> return <>
<DirectoryTree
onSelect={(_, info) => onNodeClick(info)}
onRightClick={info => onRightClick(info)}
treeData={buildTreeData(treeData)}
/>
{ {
(treeData.length > 0) ? (treeData.length > 0) ?
<DirectoryTree <DirectoryTree
onSelect={(_, info) => onNodeClick(info)} onSelect={(_, info) => onNodeClick(info)}
onRightClick={info => onRightClick(info)}
treeData={buildTreeData(treeData)} treeData={buildTreeData(treeData)}
/> : /> :
<> <>
......
...@@ -19,9 +19,13 @@ ...@@ -19,9 +19,13 @@
import ResourceOverView from "@/pages/RegCenter/Resource/components/ResourceOverView"; import ResourceOverView from "@/pages/RegCenter/Resource/components/ResourceOverView";
import {PageContainer} from "@ant-design/pro-components";
import Scale from "@/components/Animation/Scale";
export default () => { export default () => {
return <> return <Scale>
<PageContainer breadcrumb={{style: {display: 'none'}}} title={false}>
<ResourceOverView/> <ResourceOverView/>
</> </PageContainer>
</Scale>
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment