Unverified Commit 0feb635d authored by aiwenmo's avatar aiwenmo Committed by GitHub

Merge pull request #87 from zhu-mingye/dev

fixbug && add SQLStudio Right Menu
parents 2a2d4f6b 87addd4d
......@@ -88,6 +88,7 @@ public class CatalogueServiceImpl extends SuperServiceImpl<CatalogueMapper, Cata
}else{
Task task = new Task();
task.setId(oldCatalogue.getTaskId());
task.setName(catalogue.getName());
task.setAlias(catalogue.getName());
taskService.updateById(task);
this.updateById(catalogue);
......
import {message, Tabs} from 'antd';
import {message, Tabs, Menu, Dropdown} from 'antd';
import React, {useState} from 'react';
import {connect} from "umi";
import {StateType} from "@/pages/FlinkSqlStudio/model";
import {connect} from 'umi';
import {StateType} from '@/pages/FlinkSqlStudio/model';
import styles from './index.less';
import StudioEdit from '../StudioEdit';
import {saveTask} from "@/components/Studio/StudioEvent/DDL";
import { DIALECT } from '../conf';
import {saveTask} from '@/components/Studio/StudioEvent/DDL';
import {DIALECT} from '../conf';
const {TabPane} = Tabs;
const EditorTabs = (props: any) => {
const {tabs, dispatch, current, toolHeight,width} = props;
const {tabs, dispatch, current, toolHeight, width} = props;
const onChange = (activeKey: any) => {
dispatch&&dispatch({
type: "Studio/saveToolHeight",
payload: toolHeight-0.0001,
dispatch &&
dispatch({
type: 'Studio/saveToolHeight',
payload: toolHeight - 0.0001,
});
dispatch({
type: "Studio/changeActiveKey",
type: 'Studio/changeActiveKey',
payload: activeKey,
});
};
......@@ -27,9 +28,10 @@ const EditorTabs = (props: any) => {
if (action == 'add') {
add();
} else if (action == 'remove') {
dispatch&&dispatch({
type: "Studio/saveToolHeight",
payload: toolHeight-0.0001,
dispatch &&
dispatch({
type: 'Studio/saveToolHeight',
payload: toolHeight - 0.0001,
});
if (current.isModified) {
saveTask(current, dispatch);
......@@ -51,7 +53,7 @@ const EditorTabs = (props: any) => {
}
});
let panes = tabs.panes;
const newPanes = panes.filter(pane => pane.key.toString() != targetKey);
const newPanes = panes.filter((pane) => pane.key.toString() != targetKey);
if (newPanes.length && newActiveKey.toString() === targetKey) {
if (lastIndex > 0) {
newActiveKey = newPanes[lastIndex].key;
......@@ -60,13 +62,49 @@ const EditorTabs = (props: any) => {
}
}
dispatch({
type: "Studio/saveTabs",
type: 'Studio/saveTabs',
payload: {
activeKey: newActiveKey,
panes: newPanes,
},
});
};
const handleClickMenu = (e: any, current) => {
dispatch({
type: 'Studio/closeTabs',
payload: {
deleteType: e.key,
current
},
});
};
const menu = (pane) => (
<Menu onClick={(e) => handleClickMenu(e, pane)}>
<Menu.Item key="CLOSE_OTHER">
<span>关闭其他</span>
</Menu.Item>
<Menu.Item key="CLOSE_ALL">
<span>关闭所有</span>
</Menu.Item>
</Menu>
);
const Tab = (pane: any) => (
<span>
{pane.key === 0 ? (
pane.title
) : (
<Dropdown overlay={menu(pane)} trigger={['contextMenu']}>
<span className="ant-dropdown-link">
{pane.title}
</span>
</Dropdown>
)}
</span>
);
return (
<Tabs
hideAdd
......@@ -75,18 +113,21 @@ const EditorTabs = (props: any) => {
onChange={onChange}
activeKey={tabs.activeKey + ''}
onEdit={onEdit}
className={styles["edit-tabs"]}
className={styles['edit-tabs']}
style={{height: toolHeight}}
>
{tabs.panes.map(pane => (
<TabPane tab={pane.title} key={pane.key} closable={pane.closable}>
<StudioEdit tabsKey={pane.key} height={(toolHeight - 32)} width={width}
language={current.task.dialect===DIALECT.JAVA?'java':'sql'}/>
{tabs.panes.map((pane) => (
<TabPane tab={Tab(pane)} key={pane.key} closable={pane.closable}>
<StudioEdit
tabsKey={pane.key}
height={toolHeight - 32}
width={width}
language={current.task.dialect === DIALECT.JAVA ? 'java' : 'sql'}
/>
</TabPane>
))}
</Tabs>
)
);
};
export default connect(({Studio}: { Studio: StateType }) => ({
......
This diff is collapsed.
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