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