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';
import {ProForm, ProFormGroup, ProFormSelect, ProFormText} from '@ant-design/pro-components';
import {l} from '@/utils/intl';
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 CodeEdit from '@/components/CustomEditor/CodeEdit';
import {renderDataSourceType} from '@/pages/RegCenter/DataSource/components/function';
type DataSourceProFormProps = {
values: Partial<DataSources.DataSource>,
......@@ -80,7 +82,8 @@ const DataSourceProForm: React.FC<DataSourceProFormProps> = (props) => {
width={'sm'}
label={l('rc.ds.type')}
showSearch
options={renderDataSourceType()}
initialValue={dbType}
options={DATA_SOURCE_TYPE_OPTIONS}
rules={[{required: true, message: l('rc.ds.typePlaceholder')}]}
placeholder={l('rc.ds.typePlaceholder')}
......
......@@ -21,30 +21,58 @@ import {l} from '@/utils/intl';
/**
* data source type
*/
export const DATA_SOURCE_TYPE = [
{
type: 'MySQL',
}, {
type: 'Oracle',
}, {
type: 'PostgreSQL',
}, {
type: 'ClickHouse',
}, {
type: 'SQLServer',
}, {
type: 'Doris',
}, {
type: 'Phoenix',
}, {
type: 'Hive',
}, {
type: 'StarRocks',
}, {
type: 'Presto',
}
export const DATA_SOURCE_TYPE_OPTIONS = [
{
label: l('rc.ds.source'),
options: [
{
label: 'MySQL',
value: 'MySQL',
}, {
label: 'Oracle',
value: 'Oracle',
},
],
},
{
label: l('rc.ds.source'),
options: [
{
label: 'PostgreSQL',
value: 'PostgreSQL',
}, {
label: 'ClickHouse',
value: 'ClickHouse',
}, {
label: 'SQLServer',
value: 'SQLServer',
},
],
}, {
label: l('rc.ds.source'),
options: [
{
label: 'Doris',
value: 'Doris',
}, {
label: 'Phoenix',
value: 'Phoenix',
}, {
label: 'Hive',
value: 'Hive',
}, {
label: 'StarRocks',
value: 'StarRocks',
}, {
label: 'Presto',
value: 'Presto',
}
],
}
];
/**
* data source group type
*/
......
......@@ -16,8 +16,7 @@
*/
import {DATA_SOURCE_TYPE, QUERY_KEYWORD} from '@/pages/RegCenter/DataSource/components/constants';
import {DefaultOptionType} from 'antd/es/select';
import { QUERY_KEYWORD} from '@/pages/RegCenter/DataSource/components/constants';
import {
ClickHouseIcons, DefaultDBIcons,
DorisIcons, HiveIcons,
......@@ -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[]) => {
const result = data.concat(QUERY_KEYWORD).map((item: string | number) => ({
value: item,
......
......@@ -39,16 +39,11 @@ const FileTree: React.FC<FileTreeProps> = (props) => {
const {treeData, onNodeClick, onRightClick} = props;
return <>
<DirectoryTree
onSelect={(_, info) => onNodeClick(info)}
onRightClick={info => onRightClick(info)}
treeData={buildTreeData(treeData)}
/>
{
(treeData.length > 0) ?
<DirectoryTree
onSelect={(_, info) => onNodeClick(info)}
onRightClick={info => onRightClick(info)}
treeData={buildTreeData(treeData)}
/> :
<>
......
......@@ -19,9 +19,13 @@
import ResourceOverView from "@/pages/RegCenter/Resource/components/ResourceOverView";
import {PageContainer} from "@ant-design/pro-components";
import Scale from "@/components/Animation/Scale";
export default () => {
return <>
<ResourceOverView/>
</>
return <Scale>
<PageContainer breadcrumb={{style: {display: 'none'}}} title={false}>
<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