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