Unverified Commit 24d5e41d authored by Licho's avatar Licho Committed by GitHub

refactor: some tricky fix and refactor (#2295)

* refactor: remove water marker * refactor: reorder admin icon * refactor: close tab Signed-off-by: 's avatarLicho <lecho.sun@gmail.com> * fix: foot display partial Signed-off-by: 's avatarLicho <lecho.sun@gmail.com> * Spotless Apply --------- Signed-off-by: 's avatarLicho <lecho.sun@gmail.com> Co-authored-by: 's avatarleechor <leechor@users.noreply.github.com>
parent 881052cb
...@@ -194,73 +194,71 @@ const CodeShow = (props: CodeShowFormProps) => { ...@@ -194,73 +194,71 @@ const CodeShow = (props: CodeShowFormProps) => {
* render * render
*/ */
return ( return (
<> <div className={'monaco-float'}>
<div className={'monaco-float'}> {/* fullScreen button */}
{/* fullScreen button */} {fullScreenBtn && (
{fullScreenBtn && ( <FullscreenBtn
<FullscreenBtn isFullscreen={fullScreen}
isFullscreen={fullScreen} fullScreenCallBack={() => setFullScreen(!fullScreen)}
fullScreenCallBack={() => setFullScreen(!fullScreen)} />
/> )}
)}
{/* editor */} {/* editor */}
<Editor <Editor
width={width} width={width}
height={height} height={height}
value={loading ? 'loading...' : code} value={loading ? 'loading...' : code}
language={language} language={language}
options={{ options={{
...options, ...options,
scrollBeyondLastLine: false, scrollBeyondLastLine: false,
readOnly: true, readOnly: true,
wordWrap: autoWrap, wordWrap: autoWrap,
autoDetectHighContrast: true, autoDetectHighContrast: true,
selectOnLineNumbers: true, selectOnLineNumbers: true,
fixedOverflowWidgets: true, fixedOverflowWidgets: true,
autoClosingDelete: 'always', autoClosingDelete: 'always',
lineNumbers, lineNumbers,
scrollbar: { scrollbar: {
// Subtle shadows to the left & top. Defaults to true. // Subtle shadows to the left & top. Defaults to true.
useShadows: false, useShadows: false,
// Render vertical arrows. Defaults to false. // Render vertical arrows. Defaults to false.
// verticalHasArrows: true, // verticalHasArrows: true,
// Render horizontal arrows. Defaults to false. // Render horizontal arrows. Defaults to false.
// horizontalHasArrows: true, // horizontalHasArrows: true,
// Render vertical scrollbar. // Render vertical scrollbar.
// Accepted values: 'auto', 'visible', 'hidden'. // Accepted values: 'auto', 'visible', 'hidden'.
// Defaults to 'auto' // Defaults to 'auto'
vertical: 'visible', vertical: 'visible',
// Render horizontal scrollbar. // Render horizontal scrollbar.
// Accepted values: 'auto', 'visible', 'hidden'. // Accepted values: 'auto', 'visible', 'hidden'.
// Defaults to 'auto' // Defaults to 'auto'
horizontal: 'visible', horizontal: 'visible',
verticalScrollbarSize: 8, verticalScrollbarSize: 8,
horizontalScrollbarSize: 8, horizontalScrollbarSize: 8,
arrowSize: 30 arrowSize: 30
} }
}} }}
onMount={editorDidMount} onMount={editorDidMount}
theme={theme ? theme : convertCodeEditTheme()} theme={theme ? theme : convertCodeEditTheme()}
/> />
{/* float button */} {/* float button */}
{showFloatButton && ( {showFloatButton && (
<div <div
style={{ style={{
width: 35, width: 35,
height: height, height: height,
backgroundColor: '#f4f4f4', backgroundColor: '#f4f4f4',
paddingBlock: 10 paddingBlock: 10
}} }}
> >
<EditorFloatBtn {...restEditBtnProps} /> <EditorFloatBtn {...restEditBtnProps} />
</div> </div>
)} )}
</div> </div>
</>
); );
}; };
......
...@@ -119,7 +119,6 @@ const GlobalHeaderRight: React.FC = () => { ...@@ -119,7 +119,6 @@ const GlobalHeaderRight: React.FC = () => {
<FullscreenExitOutlined {...fullScreenProps} onClick={screenFull} /> <FullscreenExitOutlined {...fullScreenProps} onClick={screenFull} />
)} )}
</Tooltip> </Tooltip>
<Avatar />
<Tooltip placement='bottom' title={<span>{menuVersion}</span>}> <Tooltip placement='bottom' title={<span>{menuVersion}</span>}>
<Space style={actionClassName}>{menuVersion}</Space> <Space style={actionClassName}>{menuVersion}</Space>
</Tooltip> </Tooltip>
...@@ -131,6 +130,7 @@ const GlobalHeaderRight: React.FC = () => { ...@@ -131,6 +130,7 @@ const GlobalHeaderRight: React.FC = () => {
unCheckedChildren={<ThemeStar />} unCheckedChildren={<ThemeStar />}
onChange={(value) => setTheme(value ? THEME.dark : THEME.light)} onChange={(value) => setTheme(value ? THEME.dark : THEME.light)}
/> />
<Avatar />
</> </>
); );
}; };
......
...@@ -6,8 +6,9 @@ import { l } from '@/utils/intl'; ...@@ -6,8 +6,9 @@ import { l } from '@/utils/intl';
import { connect } from '@@/exports'; import { connect } from '@@/exports';
import { Modal, Select, Tabs } from 'antd'; import { Modal, Select, Tabs } from 'antd';
import TextArea from 'antd/es/input/TextArea'; import TextArea from 'antd/es/input/TextArea';
import { Tab } from 'rc-tabs/lib/interface.d';
import * as React from 'react'; import * as React from 'react';
import { ReactNode, useEffect, useState } from 'react'; import { useEffect, useState } from 'react';
export async function getPrintTables(statement: string) { export async function getPrintTables(statement: string) {
return postAll('api/statement/getPrintTables', { statement }); return postAll('api/statement/getPrintTables', { statement });
...@@ -50,7 +51,7 @@ const DataPage = (props: any) => { ...@@ -50,7 +51,7 @@ const DataPage = (props: any) => {
const TableData = (props: any) => { const TableData = (props: any) => {
const { statement, height } = props; const { statement, height } = props;
const [panes, setPanes] = useState<{ label: string; key: string; children: ReactNode }[]>([]); const [panes, setPanes] = useState<Tab[]>([]);
function onOk(title: string) { function onOk(title: string) {
const activeKey = `${panes.length + 1}`; const activeKey = `${panes.length + 1}`;
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
import { import {
DataStudioTabsItemType, DataStudioTabsItemType,
EnvType, EnvType,
FooterType,
JobRunningMsgType, JobRunningMsgType,
MetadataTabsItemType, MetadataTabsItemType,
STUDIO_MODEL, STUDIO_MODEL,
...@@ -157,7 +158,7 @@ export const getCurrentData = ( ...@@ -157,7 +158,7 @@ export const getCurrentData = (
return undefined; return undefined;
}; };
export const getFooterValue = (panes: any, activeKey: string) => { export const getFooterValue = (panes: any, activeKey: string): Partial<FooterType> => {
const currentTab = getCurrentTab(panes, activeKey); const currentTab = getCurrentTab(panes, activeKey);
if (isDataStudioTabsItemType(currentTab)) { if (isDataStudioTabsItemType(currentTab)) {
return { return {
......
...@@ -278,7 +278,7 @@ const DataStudio = (props: any) => { ...@@ -278,7 +278,7 @@ const DataStudio = (props: any) => {
return ( return (
<PageContainer title={false} breadcrumb={{ style: { display: 'none' } }}> <PageContainer title={false} breadcrumb={{ style: { display: 'none' } }}>
<PersistGate loading={null} persistor={persist}> <PersistGate loading={null} persistor={persist}>
<div style={{ marginInline: -10, width: size.width }}> <div style={{ marginInline: -10, marginTop: -6, width: size.width }}>
<SecondHeaderContainer size={size} activeBreadcrumbTitle={activeBreadcrumbTitle} /> <SecondHeaderContainer size={size} activeBreadcrumbTitle={activeBreadcrumbTitle} />
<Layout hasSider style={{ minHeight: size.contentHeight, paddingInline: 0 }}> <Layout hasSider style={{ minHeight: size.contentHeight, paddingInline: 0 }}>
<Sider collapsed collapsedWidth={40}> <Sider collapsed collapsedWidth={40}>
......
...@@ -222,7 +222,7 @@ export type JobRunningMsgType = { ...@@ -222,7 +222,7 @@ export type JobRunningMsgType = {
/** /**
* footer * footer
*/ */
type FooterType = { export type FooterType = {
codePosition: [number, number]; codePosition: [number, number];
space: number; space: number;
codeEncoding: string; codeEncoding: string;
...@@ -521,9 +521,6 @@ const Model: ModelType = { ...@@ -521,9 +521,6 @@ const Model: ModelType = {
}, },
/** /**
* flink config options * flink config options
* @param {StateType} state
* @param {any} payload
* @returns {{centerContentHeight: number, flinkConfigOptions: any, tabs: TabsType, project: {data: any[], expandKeys: [], selectKey: []}, leftContainer: Container, env: EnvType[], footContainer: FooterType, clusterConfiguration: Cluster.Config[], toolContentHeight: number, database: {dbData: DataSources.DataSource[], selectDatabaseId: number | null, expandKeys: [], selectKey: []}, sessionCluster: Cluster.Instance[], isFullScreen: boolean, rightContainer: Container, bottomContainerContent: BottomContainerContent, bottomContainer: Container}}
*/ */
saveFlinkConfigOptions(state, { payload }) { saveFlinkConfigOptions(state, { payload }) {
return { return {
...@@ -609,32 +606,27 @@ const Model: ModelType = { ...@@ -609,32 +606,27 @@ const Model: ModelType = {
if (needCloseKey === activeKey) { if (needCloseKey === activeKey) {
for (const [index, pane] of panes.entries()) { for (const [index, pane] of panes.entries()) {
if (pane.key === needCloseKey) { if (pane.key === needCloseKey) {
const item = const nextPane = panes[(index + 1) % panes.length];
index + 1 >= panes.length
? index + 1 > 1 && index + 1 === panes.length
? panes[index - 1]
: panes[0]
: panes[index + 1];
const newPanes = panes.filter((pane) => pane.key !== needCloseKey);
let footerValue: object = getFooterValue(panes, item.key);
return { return {
...state, ...state,
tabs: { tabs: {
panes: newPanes, panes: panes.filter((pane) => pane.key !== needCloseKey),
activeKey: item.key, activeKey: nextPane.key,
activeBreadcrumbTitle: activeBreadcrumbTitle:
panes.length < 2 ? '' : [item.type, item.breadcrumbLabel, item.label].join('/') panes.length < 2
? ''
: [nextPane.type, nextPane.breadcrumbLabel, nextPane.label].join('/')
}, },
footContainer: { footContainer: {
...state.footContainer, ...state.footContainer,
...footerValue ...getFooterValue(panes, nextPane.key)
} }
}; };
} }
} }
} }
const newPanes = panes.filter((pane) => pane.key !== needCloseKey); const newPanes = panes.filter((pane) => pane.key !== needCloseKey);
let footerValue: object = getFooterValue(newPanes, activeKey);
return { return {
...state, ...state,
tabs: { tabs: {
...@@ -644,10 +636,11 @@ const Model: ModelType = { ...@@ -644,10 +636,11 @@ const Model: ModelType = {
}, },
footContainer: { footContainer: {
...state.footContainer, ...state.footContainer,
...footerValue ...getFooterValue(newPanes, activeKey)
} }
}; };
}, },
/** /**
* 添加tab 如果存在则不添加 * 添加tab 如果存在则不添加
*/ */
...@@ -669,6 +662,7 @@ const Model: ModelType = { ...@@ -669,6 +662,7 @@ const Model: ModelType = {
}; };
} }
} }
node.key = node.key =
state.tabs.panes.length === 0 state.tabs.panes.length === 0
? '0' ? '0'
...@@ -712,8 +706,8 @@ const Model: ModelType = { ...@@ -712,8 +706,8 @@ const Model: ModelType = {
...state, ...state,
tabs: { tabs: {
panes: tabsItem ? [tabsItem] : [], panes: tabsItem ? [tabsItem] : [],
activeKey: tabsItem?.key || '', activeKey: tabsItem?.key ?? '',
activeBreadcrumbTitle: tabsItem?.breadcrumbLabel || '' activeBreadcrumbTitle: tabsItem?.breadcrumbLabel ?? ''
} }
}; };
}, },
......
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