Skip to content

Commit

Permalink
[BugFix][Web]Fix datastudio footer state (#3927)
Browse files Browse the repository at this point in the history
Co-authored-by: zackyoungh <[email protected]>
  • Loading branch information
zackyoungh and zackyoungh authored Nov 19, 2024
1 parent 917ba7c commit 2156485
Show file tree
Hide file tree
Showing 8 changed files with 185 additions and 113 deletions.
227 changes: 147 additions & 80 deletions dinky-web/src/components/Icons/CodeLanguageIcon.tsx

Large diffs are not rendered by default.

22 changes: 4 additions & 18 deletions dinky-web/src/pages/DataStudio/FooterContainer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@
*/

import { l } from '@/utils/intl';
import { connect, useModel } from '@@/exports';
import { useModel } from '@@/exports';
import { Button, GlobalToken, Space } from 'antd';
import React, { useEffect, useState } from 'react';
import { SseData, Topic } from '@/models/UseWebSocketModel';
import { CenterTab, DataStudioState } from '@/pages/DataStudio/model';
import { mapDispatchToProps } from '@/pages/DataStudio/DvaFunction';
import { DataStudioState } from '@/pages/DataStudio/model';
import { formatDate } from '@/pages/DataStudio/FooterContainer/function';

type ButtonRoute = {
Expand All @@ -32,10 +31,7 @@ type ButtonRoute = {
onClick?: () => void;
};

const FooterContainer = (props: {
token: GlobalToken;
centerContent?: DataStudioState['centerContent'];
}) => {
export default (props: { token: GlobalToken; centerContent: DataStudioState['centerContent'] }) => {
const { token, centerContent } = props;
const [memDetailInfo, setMemDetailInfo] = useState('0/0M');
const { subscribeTopic } = useModel('UseWebSocketModel', (model: any) => ({
Expand All @@ -53,7 +49,6 @@ const FooterContainer = (props: {
);
});
}, []);

const route: ButtonRoute[] = [
{
text: (
Expand Down Expand Up @@ -98,9 +93,7 @@ const FooterContainer = (props: {
));
};
const renderFooterLastUpdate = () => {
const currentTab = centerContent?.tabs.find(
(item, index) => item.id === centerContent?.activeTab
);
const currentTab = centerContent?.tabs.find((item) => item.id === centerContent?.activeTab);
if (currentTab && currentTab.tabType === 'task') {
return (
<div>
Expand Down Expand Up @@ -139,10 +132,3 @@ const FooterContainer = (props: {
</>
);
};

export default connect(
({ DataStudio }: { DataStudio: DataStudioState }) => ({
centerContent: DataStudio.centerContent
}),
mapDispatchToProps
)(FooterContainer);
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const TemplateSelect: React.FC<{ type: string; onChange: (v: string) => void }>

const renderItem = (item: Document) => {
return (
<div style={{ padding: 10}}>
<div style={{ padding: 10 }}>
<ProCard
checked={item.id == currentSelect?.id}
hoverable
Expand Down
4 changes: 1 addition & 3 deletions dinky-web/src/pages/DataStudio/Toolbar/Project/function.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,7 @@ export const buildProjectTree = (
parentId: item.parentId,
label: searchTreeNode(item.name, searchValue),
icon: item.type && item.children.length === 0 && (
<Space size={'small'}>
{getTabIcon(item.type, 20)}
</Space>
<Space size={'small'}>{getTabIcon(item.type, 20)}</Space>
),
value: item.id,
path: currentPath,
Expand Down
6 changes: 6 additions & 0 deletions dinky-web/src/pages/DataStudio/css/imgs/close-dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions dinky-web/src/pages/DataStudio/css/imgs/close-light.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 17 additions & 6 deletions dinky-web/src/pages/DataStudio/css/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
--text-color: #424242;
--panel-extra-btn-color: #000000;
--scroll-bg-color: #daecff;
--close-btn-img: url('./imgs/close-light.svg');
}

.dark-theme {
Expand All @@ -26,6 +27,7 @@
--text-color: #fafafa;
--panel-extra-btn-color: #fafafa;
--scroll-bg-color: #4d4e51;
--close-btn-img: url('./imgs/close-dark.svg');
}

.page-container {
Expand Down Expand Up @@ -280,20 +282,29 @@ body > .dragging-layer > div:last-child {
.dock-tab-close-btn {
position: absolute;
cursor: pointer;
font-family: 'Fredoka One', sans-serif;
color: var(--text-color);
right: -5px;
right: -7px;
font-size: 12px;
width: 16px;

text-align: center;
top: 12px;
outline: none;
transition: all 0.25s ease-in-out;
content: '';
width: 14px;
height: 14px;
background-image: var(--close-btn-img);
background-position: center;
}

.dock-tab-close-btn:before {
content: 'X';
font-family: emoji;
content: '';
}
.dock-tab-close-btn:hover {
background-size: 14px;
border: 1px solid #0b7ec4;
border-radius: 50%;
width: 16px;
height: 16px;
}

.dock-tab-close-btn:hover,
Expand Down
8 changes: 3 additions & 5 deletions dinky-web/src/pages/DataStudio/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import { DockLayout, TabData } from 'rc-dock';
import React, { lazy, useEffect, useMemo, useRef, useState } from 'react';
import { PageContainer } from '@ant-design/pro-layout';
import { Col, ConfigProvider, Row, Space, Spin, theme as antdTheme } from 'antd';
import { Col, ConfigProvider, Row, Spin, theme as antdTheme } from 'antd';
import Toolbar from '@/pages/DataStudio/Toolbar';
import { DataStudioActionType, RightContextMenuState } from '@/pages/DataStudio/data.d';
import {
Expand All @@ -30,8 +30,6 @@ import {
handleRightClick,
InitContextMenuPosition
} from '@/pages/DataStudio/function';
// import 'rc-dock/dist/rc-dock.css';
// import 'rc-dock/dist/rc-dock-dark.css';
import RightContextMenu, { useRightMenuItem } from '@/pages/DataStudio/RightContextMenu';
import { MenuInfo } from 'rc-menu/es/interface';
import { lazyComponent, ToolbarRoutes } from '@/pages/DataStudio/Toolbar/ToolbarRoute';
Expand Down Expand Up @@ -326,7 +324,7 @@ const DataStudio: React.FC = (props: any) => {
return { id, group, title };
};
const loadTab = (tab: TabData) => {
const { id, title, group } = tab;
const { id, group } = tab;
if (group !== 'centerContent') {
const route = ToolbarRoutes.find((x) => x.key === id) as ToolbarRoute;
const content = ToolbarRoutes.find((item) => item.key === route.key)!!.content();
Expand Down Expand Up @@ -641,7 +639,7 @@ const DataStudio: React.FC = (props: any) => {
</Col>
</Row>

<FooterContainer token={token} />
<FooterContainer token={token} centerContent={dataStudioState.centerContent} />

{/* 边缘区域布局右键菜单*/}
<RightContextMenu
Expand Down

0 comments on commit 2156485

Please sign in to comment.