Skip to content

Commit

Permalink
refactor: some tricky fix and refactor (DataLinkDC#2295)
Browse files Browse the repository at this point in the history
* refactor: remove water marker

* refactor: reorder admin icon

* refactor: close tab

Signed-off-by: Licho <[email protected]>

* fix: foot display partial

Signed-off-by: Licho <[email protected]>

* Spotless Apply

---------

Signed-off-by: Licho <[email protected]>
Co-authored-by: leechor <[email protected]>
  • Loading branch information
leechor and leechor authored Sep 6, 2023
1 parent 881052c commit 24d5e41
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 88 deletions.
124 changes: 61 additions & 63 deletions dinky-web/src/components/CustomEditor/CodeShow/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -194,73 +194,71 @@ const CodeShow = (props: CodeShowFormProps) => {
* render
*/
return (
<>
<div className={'monaco-float'}>
{/* fullScreen button */}
{fullScreenBtn && (
<FullscreenBtn
isFullscreen={fullScreen}
fullScreenCallBack={() => setFullScreen(!fullScreen)}
/>
)}
<div className={'monaco-float'}>
{/* fullScreen button */}
{fullScreenBtn && (
<FullscreenBtn
isFullscreen={fullScreen}
fullScreenCallBack={() => setFullScreen(!fullScreen)}
/>
)}

{/* editor */}
<Editor
width={width}
height={height}
value={loading ? 'loading...' : code}
language={language}
options={{
...options,
scrollBeyondLastLine: false,
readOnly: true,
wordWrap: autoWrap,
autoDetectHighContrast: true,
selectOnLineNumbers: true,
fixedOverflowWidgets: true,
autoClosingDelete: 'always',
lineNumbers,
scrollbar: {
// Subtle shadows to the left & top. Defaults to true.
useShadows: false,
{/* editor */}
<Editor
width={width}
height={height}
value={loading ? 'loading...' : code}
language={language}
options={{
...options,
scrollBeyondLastLine: false,
readOnly: true,
wordWrap: autoWrap,
autoDetectHighContrast: true,
selectOnLineNumbers: true,
fixedOverflowWidgets: true,
autoClosingDelete: 'always',
lineNumbers,
scrollbar: {
// Subtle shadows to the left & top. Defaults to true.
useShadows: false,

// Render vertical arrows. Defaults to false.
// verticalHasArrows: true,
// Render horizontal arrows. Defaults to false.
// horizontalHasArrows: true,
// Render vertical arrows. Defaults to false.
// verticalHasArrows: true,
// Render horizontal arrows. Defaults to false.
// horizontalHasArrows: true,

// Render vertical scrollbar.
// Accepted values: 'auto', 'visible', 'hidden'.
// Defaults to 'auto'
vertical: 'visible',
// Render horizontal scrollbar.
// Accepted values: 'auto', 'visible', 'hidden'.
// Defaults to 'auto'
horizontal: 'visible',
verticalScrollbarSize: 8,
horizontalScrollbarSize: 8,
arrowSize: 30
}
}}
onMount={editorDidMount}
theme={theme ? theme : convertCodeEditTheme()}
/>
// Render vertical scrollbar.
// Accepted values: 'auto', 'visible', 'hidden'.
// Defaults to 'auto'
vertical: 'visible',
// Render horizontal scrollbar.
// Accepted values: 'auto', 'visible', 'hidden'.
// Defaults to 'auto'
horizontal: 'visible',
verticalScrollbarSize: 8,
horizontalScrollbarSize: 8,
arrowSize: 30
}
}}
onMount={editorDidMount}
theme={theme ? theme : convertCodeEditTheme()}
/>

{/* float button */}
{showFloatButton && (
<div
style={{
width: 35,
height: height,
backgroundColor: '#f4f4f4',
paddingBlock: 10
}}
>
<EditorFloatBtn {...restEditBtnProps} />
</div>
)}
</div>
</>
{/* float button */}
{showFloatButton && (
<div
style={{
width: 35,
height: height,
backgroundColor: '#f4f4f4',
paddingBlock: 10
}}
>
<EditorFloatBtn {...restEditBtnProps} />
</div>
)}
</div>
);
};

Expand Down
2 changes: 1 addition & 1 deletion dinky-web/src/components/RightContent/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ const GlobalHeaderRight: React.FC = () => {
<FullscreenExitOutlined {...fullScreenProps} onClick={screenFull} />
)}
</Tooltip>
<Avatar />
<Tooltip placement='bottom' title={<span>{menuVersion}</span>}>
<Space style={actionClassName}>{menuVersion}</Space>
</Tooltip>
Expand All @@ -131,6 +130,7 @@ const GlobalHeaderRight: React.FC = () => {
unCheckedChildren={<ThemeStar />}
onChange={(value) => setTheme(value ? THEME.dark : THEME.light)}
/>
<Avatar />
</>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ import { l } from '@/utils/intl';
import { connect } from '@@/exports';
import { Modal, Select, Tabs } from 'antd';
import TextArea from 'antd/es/input/TextArea';
import { Tab } from 'rc-tabs/lib/interface.d';
import * as React from 'react';
import { ReactNode, useEffect, useState } from 'react';
import { useEffect, useState } from 'react';

export async function getPrintTables(statement: string) {
return postAll('api/statement/getPrintTables', { statement });
Expand Down Expand Up @@ -50,7 +51,7 @@ const DataPage = (props: any) => {

const TableData = (props: any) => {
const { statement, height } = props;
const [panes, setPanes] = useState<{ label: string; key: string; children: ReactNode }[]>([]);
const [panes, setPanes] = useState<Tab[]>([]);

function onOk(title: string) {
const activeKey = `${panes.length + 1}`;
Expand Down
3 changes: 2 additions & 1 deletion dinky-web/src/pages/DataStudio/function.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import {
DataStudioTabsItemType,
EnvType,
FooterType,
JobRunningMsgType,
MetadataTabsItemType,
STUDIO_MODEL,
Expand Down Expand Up @@ -157,7 +158,7 @@ export const getCurrentData = (
return undefined;
};

export const getFooterValue = (panes: any, activeKey: string) => {
export const getFooterValue = (panes: any, activeKey: string): Partial<FooterType> => {
const currentTab = getCurrentTab(panes, activeKey);
if (isDataStudioTabsItemType(currentTab)) {
return {
Expand Down
2 changes: 1 addition & 1 deletion dinky-web/src/pages/DataStudio/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ const DataStudio = (props: any) => {
return (
<PageContainer title={false} breadcrumb={{ style: { display: 'none' } }}>
<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} />
<Layout hasSider style={{ minHeight: size.contentHeight, paddingInline: 0 }}>
<Sider collapsed collapsedWidth={40}>
Expand Down
34 changes: 14 additions & 20 deletions dinky-web/src/pages/DataStudio/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ export type JobRunningMsgType = {
/**
* footer
*/
type FooterType = {
export type FooterType = {
codePosition: [number, number];
space: number;
codeEncoding: string;
Expand Down Expand Up @@ -521,9 +521,6 @@ const Model: ModelType = {
},
/**
* 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 }) {
return {
Expand Down Expand Up @@ -609,32 +606,27 @@ const Model: ModelType = {
if (needCloseKey === activeKey) {
for (const [index, pane] of panes.entries()) {
if (pane.key === needCloseKey) {
const item =
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);
const nextPane = panes[(index + 1) % panes.length];
return {
...state,
tabs: {
panes: newPanes,
activeKey: item.key,
panes: panes.filter((pane) => pane.key !== needCloseKey),
activeKey: nextPane.key,
activeBreadcrumbTitle:
panes.length < 2 ? '' : [item.type, item.breadcrumbLabel, item.label].join('/')
panes.length < 2
? ''
: [nextPane.type, nextPane.breadcrumbLabel, nextPane.label].join('/')
},
footContainer: {
...state.footContainer,
...footerValue
...getFooterValue(panes, nextPane.key)
}
};
}
}
}

const newPanes = panes.filter((pane) => pane.key !== needCloseKey);
let footerValue: object = getFooterValue(newPanes, activeKey);
return {
...state,
tabs: {
Expand All @@ -644,10 +636,11 @@ const Model: ModelType = {
},
footContainer: {
...state.footContainer,
...footerValue
...getFooterValue(newPanes, activeKey)
}
};
},

/**
* 添加tab 如果存在则不添加
*/
Expand All @@ -669,6 +662,7 @@ const Model: ModelType = {
};
}
}

node.key =
state.tabs.panes.length === 0
? '0'
Expand Down Expand Up @@ -712,8 +706,8 @@ const Model: ModelType = {
...state,
tabs: {
panes: tabsItem ? [tabsItem] : [],
activeKey: tabsItem?.key || '',
activeBreadcrumbTitle: tabsItem?.breadcrumbLabel || ''
activeKey: tabsItem?.key ?? '',
activeBreadcrumbTitle: tabsItem?.breadcrumbLabel ?? ''
}
};
},
Expand Down

0 comments on commit 24d5e41

Please sign in to comment.