Unverified Commit 9cb07085 authored by Licho's avatar Licho Committed by GitHub

remove metadata copy table cell (#2169)

* refactor: package uri wrong, and trivial optimization * feat: remove metadata table copy
parent e12fe5b1
...@@ -38,6 +38,7 @@ const MovableSidebar: React.FC<MovableSidebarProps> = (props) => { ...@@ -38,6 +38,7 @@ const MovableSidebar: React.FC<MovableSidebarProps> = (props) => {
, children, title, contentHeight, handlerMinimize, handlerMaxsize, tagList , children, title, contentHeight, handlerMinimize, handlerMaxsize, tagList
} = props; } = props;
const [showBtn,setShowBtn] = useState(false) const [showBtn,setShowBtn] = useState(false)
return ( return (
<div onMouseEnter={() => setShowBtn(true)} onMouseLeave={() => setShowBtn(false)}> <div onMouseEnter={() => setShowBtn(true)} onMouseLeave={() => setShowBtn(false)}>
<Resizable <Resizable
...@@ -72,7 +73,7 @@ const MovableSidebar: React.FC<MovableSidebarProps> = (props) => { ...@@ -72,7 +73,7 @@ const MovableSidebar: React.FC<MovableSidebarProps> = (props) => {
{/*>*/} {/*>*/}
{/* <div style={{height: contentHeight,marginBlock:-5,marginInline:-10}}>{children}</div>*/} {/* <div style={{height: contentHeight,marginBlock:-5,marginInline:-10}}>{children}</div>*/}
{/*</PageContainer>*/} {/*</PageContainer>*/}
<Fragment> <>
<div style={{backgroundColor:token.colorBgBase,borderBlockColor:themeValue.borderColor}} className={"container-header"}> <div style={{backgroundColor:token.colorBgBase,borderBlockColor:themeValue.borderColor}} className={"container-header"}>
<div>{title}</div> <div>{title}</div>
{/*<div style={{display:showBtn?"block":"none",animation: (showBtn?"show-anim":"hide-anim")+" 2s"}}>*/} {/*<div style={{display:showBtn?"block":"none",animation: (showBtn?"show-anim":"hide-anim")+" 2s"}}>*/}
...@@ -84,7 +85,7 @@ const MovableSidebar: React.FC<MovableSidebarProps> = (props) => { ...@@ -84,7 +85,7 @@ const MovableSidebar: React.FC<MovableSidebarProps> = (props) => {
</div> </div>
</div> </div>
<div style={{height: contentHeight,backgroundColor:token.colorBgBase}}>{children}</div> <div style={{height: contentHeight,backgroundColor:token.colorBgBase}}>{children}</div>
</Fragment> </>
</Resizable> </Resizable>
</div> </div>
......
...@@ -17,7 +17,7 @@ const MetaData = (props: any) => { ...@@ -17,7 +17,7 @@ const MetaData = (props: any) => {
const {dispatch ,toolContentHeight,leftContainer, database: { dbData , selectDatabaseId , expandKeys, selectKeys} } = props; const {dispatch ,toolContentHeight,leftContainer, database: { dbData , selectDatabaseId , expandKeys, selectKeys} } = props;
const [treeData, setTreeData] = useState<[]>([]); const [treeData, setTreeData] = useState<[]>([]);
const [loadingDatabase, setLoadingDatabase] = useState(false); const [isLoadingDatabase, setIsLoadingDatabase] = useState(false);
const selectDb = (dbData as DataSources.DataSource[]).filter(x=> x.id === selectDatabaseId)[0] const selectDb = (dbData as DataSources.DataSource[]).filter(x=> x.id === selectDatabaseId)[0]
/** /**
...@@ -26,33 +26,29 @@ const MetaData = (props: any) => { ...@@ -26,33 +26,29 @@ const MetaData = (props: any) => {
*/ */
const onRefreshTreeData = (databaseId: number) => { const onRefreshTreeData = (databaseId: number) => {
if (!databaseId) { if (!databaseId) {
setLoadingDatabase(false); setIsLoadingDatabase(false);
return; return;
} }
setLoadingDatabase(true); setIsLoadingDatabase(true);
const res = showMetaDataTable(databaseId); const res = showMetaDataTable(databaseId);
res.then((tables) => { res.then((tables) => {
setLoadingDatabase(false); setIsLoadingDatabase(false);
if (tables) { for (let table of tables) {
for (let i = 0; i < tables.length; i++) { table.title = table.name;
tables[i].title = tables[i].name; table.key = table.name;
tables[i].key = tables[i].name; table.icon = <DatabaseOutlined/>;
tables[i].icon = <DatabaseOutlined/>; table.children = table.tables;
tables[i].children = tables[i].tables; for (let child of table.children) {
for (let j = 0; j < tables[i].children.length; j++) { child.title = child.name;
tables[i].children[j].title = tables[i].children[j].name; child.key = table.name + '.' + child.name;
tables[i].children[j].key = tables[i].name + '.' + tables[i].children[j].name; child.icon = <TableOutlined/>;
tables[i].children[j].icon = <TableOutlined/>; child.isLeaf = true;
tables[i].children[j].isLeaf = true; child.schema = table.name;
tables[i].children[j].schema = tables[i].name; child.table = child.name;
tables[i].children[j].table = tables[i].children[j].name;
} }
} }
setTreeData(tables); setTreeData(tables ?? []);
} else {
setTreeData([]);
}
}); });
}; };
...@@ -69,12 +65,13 @@ const MetaData = (props: any) => { ...@@ -69,12 +65,13 @@ const MetaData = (props: any) => {
const onChangeDataBase = (value: number) => { const onChangeDataBase = (value: number) => {
onRefreshTreeData(value); onRefreshTreeData(value);
}; };
/** /**
* 刷新数据库列表 * 刷新数据库列表
*/ */
const refreshDataBase = () => { const refreshDataBase = () => {
if (!selectDatabaseId) return; if (!selectDatabaseId) return;
setLoadingDatabase(true); setIsLoadingDatabase(true);
clearMetaDataTable(selectDatabaseId).then(() => { clearMetaDataTable(selectDatabaseId).then(() => {
onChangeDataBase(selectDatabaseId); onChangeDataBase(selectDatabaseId);
}) })
...@@ -94,6 +91,7 @@ const MetaData = (props: any) => { ...@@ -94,6 +91,7 @@ const MetaData = (props: any) => {
} }
)) ))
}; };
/** /**
* 树节点点击事件 添加tab页 并传递参数 * 树节点点击事件 添加tab页 并传递参数
* @param keys * @param keys
...@@ -106,6 +104,7 @@ const MetaData = (props: any) => { ...@@ -106,6 +104,7 @@ const MetaData = (props: any) => {
type: "Studio/updateDatabaseSelectKey", type: "Studio/updateDatabaseSelectKey",
payload: keys payload: keys
}) })
const {node: {isLeaf, parentId: schemaName, name: tableName, fullInfo}} = info; const {node: {isLeaf, parentId: schemaName, name: tableName, fullInfo}} = info;
if (isLeaf) { if (isLeaf) {
const queryParams = {id: selectDatabaseId , schemaName, tableName}; const queryParams = {id: selectDatabaseId , schemaName, tableName};
...@@ -148,12 +147,11 @@ const MetaData = (props: any) => { ...@@ -148,12 +147,11 @@ const MetaData = (props: any) => {
return ( return (
<Spin spinning={isLoadingDatabase} delay={500}>
<Spin spinning={loadingDatabase} delay={500}>
<ProForm style={{height: 40}} initialValues={{selectDb:selectDatabaseId}} submitter={false}> <ProForm style={{height: 40}} initialValues={{selectDb:selectDatabaseId}} submitter={false}>
<ProFormSelect <ProFormSelect
width={leftContainer.width - 45 } width={leftContainer.width - 45 }
addonAfter={<ReloadOutlined spin={loadingDatabase} title={l('button.refresh')} onClick={() => refreshDataBase()} />} addonAfter={<ReloadOutlined spin={isLoadingDatabase} title={l('button.refresh')} onClick={() => refreshDataBase()} />}
allowClear={false} allowClear={false}
name={"selectDb"} name={"selectDb"}
placeholder={l('pages.metadata.selectDatabase')} placeholder={l('pages.metadata.selectDatabase')}
......
...@@ -17,6 +17,8 @@ const LeftContainer:React.FC<LeftContainerProps> = (props:any) => { ...@@ -17,6 +17,8 @@ const LeftContainer:React.FC<LeftContainerProps> = (props:any) => {
const {toolContentHeight ,leftContainer , rightContainer} = props const {toolContentHeight ,leftContainer , rightContainer} = props
const MAX_WIDTH = size.width - 2 * VIEW.leftToolWidth - rightContainer.width - 700
/** /**
* 侧边栏大小变化 * 侧边栏大小变化
* @param width * @param width
...@@ -41,8 +43,8 @@ const LeftContainer:React.FC<LeftContainerProps> = (props:any) => { ...@@ -41,8 +43,8 @@ const LeftContainer:React.FC<LeftContainerProps> = (props:any) => {
/** /**
* 侧边栏最大化 * 侧边栏最大化
*/ */
const handleMaxsize = (widthChangeValue: number) => { const handleMaxsize = () => {
handleReSizeChange(widthChangeValue) handleReSizeChange(MAX_WIDTH)
} }
/** /**
...@@ -54,11 +56,11 @@ const LeftContainer:React.FC<LeftContainerProps> = (props:any) => { ...@@ -54,11 +56,11 @@ const LeftContainer:React.FC<LeftContainerProps> = (props:any) => {
onResize: (event: any, direction: any, elementRef: { offsetWidth: any; }) => handleReSizeChange(elementRef.offsetWidth), onResize: (event: any, direction: any, elementRef: { offsetWidth: any; }) => handleReSizeChange(elementRef.offsetWidth),
title: <Title>{l(leftContainer.selectKey)}</Title>, title: <Title>{l(leftContainer.selectKey)}</Title>,
handlerMinimize: ()=> handleMinimize(), handlerMinimize: ()=> handleMinimize(),
handlerMaxsize: () => handleMaxsize(size.width - 2 * VIEW.leftToolWidth - rightContainer.width - 700), handlerMaxsize: () => handleMaxsize(),
visible: leftContainer.selectKey !== "", visible: leftContainer.selectKey !== "",
defaultSize: {width: leftContainer.width, height: leftContainer.height}, defaultSize: {width: leftContainer.width, height: leftContainer.height},
minWidth: 260, minWidth: 260,
maxWidth: size.width - 2 * VIEW.leftToolWidth - rightContainer.width - 700, // maxWidth: MAX_WIDTH, //
enable: {right: true}, enable: {right: true},
style:{borderInlineEnd: "1px solid "+themeValue.borderColor} style:{borderInlineEnd: "1px solid "+themeValue.borderColor}
} }
......
...@@ -465,7 +465,7 @@ const Model: ModelType = { ...@@ -465,7 +465,7 @@ const Model: ModelType = {
* @returns {{centerContentHeight: number, toolContentHeight: number, database: DataSources.DataSource[], tabs: {panes: TabsItemType[], activeKey: number}, isFullScreen: boolean, rightContainer: Container, leftContainer: Container, bottomContainer: Container}} * @returns {{centerContentHeight: number, toolContentHeight: number, database: DataSources.DataSource[], tabs: {panes: TabsItemType[], activeKey: number}, isFullScreen: boolean, rightContainer: Container, leftContainer: Container, bottomContainer: Container}}
*/ */
addTab(state, {payload }) { addTab(state, {payload }) {
const node=payload as TabsItemType; const node= payload as TabsItemType;
for (const item of state.tabs.panes) { for (const item of state.tabs.panes) {
if (item.id === node.id) { if (item.id === node.id) {
return { return {
...@@ -477,6 +477,7 @@ const Model: ModelType = { ...@@ -477,6 +477,7 @@ const Model: ModelType = {
}; };
} }
} }
node.key=state.tabs.panes.length === 0 ? "0" :(parseInt(state.tabs.panes[state.tabs.panes.length-1].key)+1 ).toString(); node.key=state.tabs.panes.length === 0 ? "0" :(parseInt(state.tabs.panes[state.tabs.panes.length-1].key)+1 ).toString();
return { return {
...state, ...state,
......
...@@ -41,7 +41,6 @@ const ColumnInfo: React.FC<ColumnInfoProps> = (props) => { ...@@ -41,7 +41,6 @@ const ColumnInfo: React.FC<ColumnInfoProps> = (props) => {
dataIndex: 'name', dataIndex: 'name',
width: '10%', width: '10%',
ellipsis: true, ellipsis: true,
copyable: true,
}, },
{ {
title: l('rc.ds.columnType'), title: l('rc.ds.columnType'),
......
...@@ -66,7 +66,7 @@ const SchemaTree: React.FC<SchemaTreeProps> = (props) => { ...@@ -66,7 +66,7 @@ const SchemaTree: React.FC<SchemaTreeProps> = (props) => {
<DirectoryTree <DirectoryTree
expandedKeys={expandKeys} expandedKeys={expandKeys}
selectedKeys={selectKeys} selectedKeys={selectKeys}
onExpand={(keys) => onExpand(keys)} onExpand={onExpand}
style={style} style={style}
className={'treeList'} className={'treeList'}
onSelect={onNodeClick} onSelect={onNodeClick}
......
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