Unverified Commit 6c82d4a6 authored by aiwenmo's avatar aiwenmo Committed by GitHub

[Optimization-2583][studio] Optimize project and data source switching (#2584)

parent ccf84ae5
......@@ -170,7 +170,7 @@ const Result = (props: any) => {
useEffect(() => {
setData({});
loadData();
}, [currentTabs, currentTabs?.console.result]);
}, [currentTabs, currentTabs?.console?.result]);
const getColumns = (columns: string[]) => {
return columns?.map((item) => {
......
......@@ -28,14 +28,16 @@ import { connect } from '@@/exports';
import { PlusOutlined } from '@ant-design/icons';
import { ConfigProvider, Space, Tabs } from 'antd';
import React from 'react';
import {isProjectTabs} from "@/pages/DataStudio/function";
export type BottomContainerProps = {
size: number;
height: number | string;
};
const BottomContainer: React.FC<BottomContainerProps> = (props: any) => {
const { dispatch, size, bottomContainer, height } = props;
const { dispatch, size, bottomContainer, height, tabs: { panes, activeKey }, } = props;
const width = document.documentElement.clientWidth - VIEW.sideWidth * 2;
const isProject = isProjectTabs(panes, activeKey);
/**
* 侧边栏最小化
......@@ -200,7 +202,7 @@ const BottomContainer: React.FC<BottomContainerProps> = (props: any) => {
marginTop: 0,
backgroundColor: '#fff',
position: 'fixed',
bottom: VIEW.footerHeight
// bottom: VIEW.footerHeight
}}
defaultSize={{ width: '100%', height: height }}
minHeight={VIEW.midMargin}
......@@ -217,21 +219,24 @@ const BottomContainer: React.FC<BottomContainerProps> = (props: any) => {
handlerMinimize={handleMinimize}
maxWidth={width}
>
<Tabs
{!isProject &&
< Tabs
activeKey={
bottomContainer.selectKey +
'/' +
(bottomContainer.selectSubKey[bottomContainer.selectKey]
? bottomContainer.selectSubKey[bottomContainer.selectKey]
: '')
}
bottomContainer.selectKey +
'/' +
(bottomContainer.selectSubKey[bottomContainer.selectKey]
? bottomContainer.selectSubKey[bottomContainer.selectKey]
: '')
}
items={renderItems()}
tabBarStyle={{ display: 'none' }}
/>
tabBarStyle={{display: 'none'}}
/>
}
</MovableSidebar>
);
};
export default connect(({ Studio }: { Studio: StateType }) => ({
bottomContainer: Studio.bottomContainer
bottomContainer: Studio.bottomContainer,
tabs: Studio.tabs
}))(BottomContainer);
......@@ -152,6 +152,19 @@ export function getCurrentTab(
}
}
export function isProjectTabs(
panes: TabsItemType[],
activeKey: string
): boolean {
const item = panes.find((item) => item.key === activeKey);
switch (item?.type) {
case 'project':
return true;
default:
return false;
}
}
export function getTabByTaskId(
panes: TabsItemType[],
id: number
......
......@@ -22,13 +22,13 @@ import { useEditor } from '@/hooks/useEditor';
import useThemeValue from '@/hooks/useThemeValue';
import BottomContainer from '@/pages/DataStudio/BottomContainer';
import FooterContainer from '@/pages/DataStudio/FooterContainer';
import { mapDispatchToProps } from '@/pages/DataStudio/function';
import {isProjectTabs, mapDispatchToProps} from '@/pages/DataStudio/function';
import SecondHeaderContainer from '@/pages/DataStudio/HeaderContainer';
import LeftContainer from '@/pages/DataStudio/LeftContainer';
import { getDataSourceList } from '@/pages/DataStudio/LeftContainer/DataSource/service';
import { getTaskData } from '@/pages/DataStudio/LeftContainer/Project/service';
import MiddleContainer from '@/pages/DataStudio/MiddleContainer';
import { StateType, TabsItemType, TabsPageType, VIEW } from '@/pages/DataStudio/model';
import {StateType, STUDIO_MODEL, TabsItemType, TabsPageType, VIEW} from '@/pages/DataStudio/model';
import RightContainer from '@/pages/DataStudio/RightContainer';
import {
getClusterConfigurationData,
......@@ -54,6 +54,7 @@ const DataStudio = (props: any) => {
saveDataBase,
saveProject,
updateToolContentHeight,
updateBottomHeight,
saveSession,
saveEnv,
updateCenterContentHeight,
......@@ -63,14 +64,14 @@ const DataStudio = (props: any) => {
saveClusterConfiguration,
activeBreadcrumbTitle,
updateSelectBottomSubKey,
tabs
tabs: { panes, activeKey },
} = props;
const isProject = isProjectTabs(panes, activeKey);
const { token } = useToken();
const themeValue = useThemeValue();
const app = getDvaApp(); // 获取dva的实例
const persist = app._store.persist;
const bottomHeight = bottomContainer.selectKey === '' ? 0 : bottomContainer.height;
let bottomHeight = !isProject ? 0 : bottomContainer.selectKey === '' ? 0 : bottomContainer.height;
const { fullscreen } = useEditor();
const getClientSize = () => ({
......@@ -115,6 +116,13 @@ const DataStudio = (props: any) => {
});
};
useEffect(() => {
bottomHeight = !isProject ? 0 : bottomContainer.selectKey === '' ? 0 : bottomContainer.height;
const centerContentHeight = size.contentHeight - bottomHeight;
updateCenterContentHeight(centerContentHeight);
updateToolContentHeight(centerContentHeight - VIEW.leftMargin);
}, [activeKey]);
useEffect(() => {
loadData();
}, []);
......@@ -185,10 +193,10 @@ const DataStudio = (props: any) => {
if (!x.isShow) {
return true;
}
if (parseInt(tabs.activeKey) < 0) {
if (parseInt(activeKey) < 0) {
return TabsPageType.None;
}
const v = (tabs.panes as TabsItemType[]).find((item) => item.key === tabs.activeKey);
const v = (panes as TabsItemType[]).find((item) => item.key === activeKey);
return x.isShow(v?.type ?? TabsPageType.None, v?.subType);
})
.map((x) => {
......@@ -218,7 +226,7 @@ const DataStudio = (props: any) => {
<Sider collapsed collapsedWidth={40}>
<div style={{ display: 'flex', flexDirection: 'column', height: '100%' }}>
{LeftTopMenu}
{LeftBottomMenu}
{isProject && LeftBottomMenu}
</div>
</Sider>
......@@ -239,7 +247,7 @@ const DataStudio = (props: any) => {
</Content>
<RightContainer size={size} bottomHeight={bottomHeight} />
</div>
{<BottomContainer size={size} height={bottomHeight} />}
{isProject && <BottomContainer size={size} height={bottomHeight} />}
</Content>
<Sider collapsed collapsedWidth={40}>
......
......@@ -140,7 +140,7 @@ const SQLQuery: React.FC<SQLQueryProps> = (props) => {
* render
*/
return (
<Height80VHDiv>
<>
{dbId && tableName && schemaName ? (
<ProTable
bordered
......@@ -166,7 +166,7 @@ const SQLQuery: React.FC<SQLQueryProps> = (props) => {
) : (
<Empty className={'code-content-empty'} description={l('rc.ds.detail.tips')} />
)}
</Height80VHDiv>
</>
);
};
......
......@@ -34,7 +34,7 @@ const SchemaDesc: React.FC<SchemaDescProps> = (props) => {
const { tableInfo, tableColumns } = props;
return (
<Height80VHDiv>
<>
{!(Object.keys(tableInfo).length === 0 && tableColumns.length === 0) ? (
<>
<TableInfo tableInfo={tableInfo} />
......@@ -43,7 +43,7 @@ const SchemaDesc: React.FC<SchemaDescProps> = (props) => {
) : (
<Empty className={'code-content-empty'} description={l('rc.ds.detail.tips')} />
)}
</Height80VHDiv>
</>
);
};
......
......@@ -104,6 +104,7 @@ const RightTagsRouter: React.FC<RightTagsRouterProps> = (props) => {
{l('rc.ds.detail.tag.console')}
</Space>
),
disabled: true,
children: <SQLConsole />
}
];
......
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