Skip to content

Commit

Permalink
[BugFix][Web] Fix the catalog display field bug (DataLinkDC#3818)
Browse files Browse the repository at this point in the history
Co-authored-by: zackyoungh <[email protected]>
  • Loading branch information
zackyoungh and zackyoungh authored Sep 18, 2024
1 parent 235d85a commit 4acca23
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 32 deletions.
20 changes: 9 additions & 11 deletions dinky-web/src/pages/DataStudio/LeftContainer/Catalog/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import DirectoryTree from 'antd/es/tree/DirectoryTree';
import { DefaultOptionType } from 'rc-select/lib/Select';
import React, { useEffect, useState } from 'react';
import { getMSCatalogs, getMSColumns, getMSSchemaInfo } from './service';
import { useAsyncEffect } from 'ahooks';

const Catalog: React.FC = (props: connect) => {
const { tabs } = props;
Expand Down Expand Up @@ -73,7 +74,6 @@ const Catalog: React.FC = (props: connect) => {
const [modalVisit, setModalVisit] = useState(false);
const [row, setRow] = useState<TableDataNode>();
const [loading, setLoading] = useState<boolean>(false);
const [columnData, setColumnData] = useState([]);
const btnDispatch = useTasksDispatch();
const currentTabName = LeftMenuKey.CATALOG_KEY;
const btnEvent = [...BtnRoute[currentTabName]];
Expand All @@ -91,23 +91,20 @@ const Catalog: React.FC = (props: connect) => {
getCatalogs();
}, [envId, databaseId]);

useEffect(() => {
useAsyncEffect(async () => {
if (table) {
setLoading(true);
setColumnData([]);
getMSColumns({
const res = await getMSColumns({
envId,
catalog,
database,
table,
dialect,
databaseId
})
.then((res) => {
setLoading(false);
setColumnData(res);
})
.catch(() => {});
});
setLoading(false);
// @ts-ignore
setRow({ ...row, columns: res });
}
}, [table]);

Expand Down Expand Up @@ -147,6 +144,7 @@ const Catalog: React.FC = (props: connect) => {
const tablesData: TableDataNode[] = [];
for (const t of tables) {
tablesData.push({
driverType: '',
title: t.name,
key: t.name,
icon: <TableOutlined />,
Expand Down Expand Up @@ -347,7 +345,7 @@ const Catalog: React.FC = (props: connect) => {
</Button>
]}
>
<SchemaDesc tableInfo={row} tableColumns={columnData} />
<SchemaDesc tableInfo={row} />
</Modal>
</Spin>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,15 +207,12 @@ const DataSource = (props: any) => {
}}
/>
<ProForm
style={{ height: 40 }}
style={{ height: 40, marginTop: 10 }}
initialValues={{ selectDb: selectDatabaseId }}
submitter={false}
>
<ProFormSelect
style={{ paddingInline: 6 }}
// width={leftContainer.width }
width={'xl'}
// addonAfter={<ReloadOutlined spin={isLoadingDatabase} title={l('button.refresh')} onClick={() => refreshDataBase()} />}
allowClear={false}
name={'selectDb'}
placeholder={l('pages.metadata.selectDatabase')}
Expand All @@ -228,7 +225,7 @@ const DataSource = (props: any) => {
<SchemaTree
selectKeys={selectKeys}
expandKeys={expandKeys}
height={toolContentHeight - 64 - 20}
height={toolContentHeight - 64 - 30}
onNodeClick={handleTreeNodeClick}
treeData={treeData}
onExpand={handleTreeExpand}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ const ProjectTitle: React.FC<StateType & connect> = (props) => {

/**
* 渲染侧边栏标题
* @returns {JSX.Element}
* @returns {React.JSX.Element}
*/
const renderTitle = () => {
const renderTitle = (): React.JSX.Element => {
if (selectKey && selectKey === currentTabName) {
return (
<Space>
Expand Down
17 changes: 5 additions & 12 deletions dinky-web/src/pages/DataStudio/LeftContainer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const LeftContainer: React.FC<LeftContainerProps> = (props: any) => {
const themeValue = useThemeValue();
const MAX_WIDTH = size.width - 2 * VIEW.leftToolWidth - rightContainer.width - 700;
/**
* 侧边栏大小变化
* Sidebar size changes
* @param width
*/
const handleReSizeChange = (width: any) => {
Expand All @@ -57,7 +57,7 @@ const LeftContainer: React.FC<LeftContainerProps> = (props: any) => {
};

/**
* 侧边栏最小化
* The sidebar is minimized
*/
const handleMinimize = () => {
dispatch({
Expand All @@ -67,14 +67,14 @@ const LeftContainer: React.FC<LeftContainerProps> = (props: any) => {
};

/**
* 侧边栏最大化
* Sidebar maximization
*/
const handleMaxsize = () => {
handleReSizeChange(MAX_WIDTH);
};

/**
* 侧边栏属性
* Sidebar properties
* @type {{onResize: (event: any, direction: any, elementRef: {offsetWidth: any}) => void, visible: boolean, defaultSize: {width: any, height: any}, enable: {right: boolean}, minWidth: number, title: string, handlerMinimize: () => void, contentHeight: any, maxWidth: number}}
*/
const restMovableSidebarProps: MovableSidebarProps = {
Expand Down Expand Up @@ -106,17 +106,10 @@ const LeftContainer: React.FC<LeftContainerProps> = (props: any) => {
<Tabs activeKey={leftContainer.selectKey} items={LeftSide} tabBarStyle={{ display: 'none' }} />
);

return (
<MovableSidebar {...restMovableSidebarProps}>
{/*<Tabs activeKey={leftContainer.selectKey} items={LeftSide} tabBarStyle={{display: "none"}}/>*/}
{content}
</MovableSidebar>
);
return <MovableSidebar {...restMovableSidebarProps}>{content}</MovableSidebar>;
};

export default connect(({ Studio }: { Studio: StateType }) => ({
// leftContainer: Studio.leftContainer,
// rightContainer: Studio.rightContainer,
toolContentHeight: Studio.toolContentHeight,
tabs: Studio.tabs
}))(LeftContainer);
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import ColumnInfo from '@/pages/RegCenter/DataSource/components/DataSourceDetail
import { DataSources } from '@/types/RegCenter/data';

const GeneralJdbcDesc: React.FC<DataSources.SchemaDescProps> = (props) => {
const { tableInfo, queryParams } = props;
const { tableInfo } = props;

return <ColumnInfo columnInfo={tableInfo?.columns} />;
};
Expand Down
1 change: 0 additions & 1 deletion dinky-web/src/types/RegCenter/data.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,6 @@ declare namespace DataSources {
*/
export type SchemaDescProps = {
tableInfo?: Partial<DataSources.Table>;
tableColumns?: Partial<DataSources.Column[]>;
queryParams?: QueryParams;
};

Expand Down

0 comments on commit 4acca23

Please sign in to comment.