Skip to content

Commit 2627140

Browse files
committed
WorkspaceExtend
1 parent bc8a050 commit 2627140

21 files changed

Lines changed: 254 additions & 205 deletions

File tree

chat2db-client/src/components/ConsoleEditor/components/OperationLine/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22
import i18n from '@/i18n';
33
import { Button } from 'antd';
4-
import { IBoundInfo } from '../../index';
4+
import { IBoundInfo } from '@/typings/workspace';
55
import styles from './index.less';
66
import Iconfont from '@/components/Iconfont';
77
import SelectBoundInfo from '../SelectBoundInfo';

chat2db-client/src/components/ConsoleEditor/hooks/useSaveEditorData.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import indexedDB from '@/indexedDB';
55
import historyServer from '@/service/history';
66
import i18n from '@/i18n';
77
import { getCookie } from '@/utils';
8+
import { getSavedConsoleList } from '@/pages/main/workspace/store/console';
89

910

1011
interface IProps {
@@ -30,6 +31,7 @@ export const useSaveEditorData = (props: IProps) => {
3031
};
3132

3233
historyServer.updateSavedConsole(p).then(() => {
34+
getSavedConsoleList();
3335
indexedDB.deleteData('chat2db', 'workspaceConsoleDDL', boundInfo.consoleId!);
3436
lastSyncConsole.current = value;
3537
setSaveStatus(ConsoleStatus.RELEASE);

chat2db-client/src/components/Modal/BaseModal/index.tsx

Lines changed: 43 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,61 @@
1-
import React, { memo, useEffect, useState } from 'react';
1+
import React, { memo, useEffect, useMemo, useState } from 'react';
22
import { Modal as AntdModal } from 'antd';
33
import { injectOpenModal } from '@/store/common/components';
44

5-
export type IModalData = {
6-
title?: string;
7-
width?: string;
8-
footer?: React.ReactNode | false;
9-
content: React.ReactNode | false
10-
} | null | false
5+
export type IModalData =
6+
| {
7+
title?: string;
8+
width?: string;
9+
onOk?: () => void;
10+
footer?: React.ReactNode | false;
11+
content: React.ReactNode | false;
12+
}
13+
| null
14+
| false;
1115

1216
const Modal = memo(() => {
1317
const [open, setOpen] = useState(false);
1418
const [modalData, setModalData] = useState<IModalData>(null);
1519

16-
const openModal = (params:IModalData)=>{
17-
if(params === false){
18-
setOpen(false)
19-
}else{
20-
setOpen(true)
21-
setModalData(params)
20+
const openModal = (params: IModalData) => {
21+
if (params === false) {
22+
setOpen(false);
23+
} else {
24+
setOpen(true);
25+
setModalData(params);
2226
}
23-
}
27+
};
2428

2529
useEffect(() => {
2630
injectOpenModal(openModal);
2731
}, []);
2832

33+
const footer = useMemo(() => {
34+
if (modalData && modalData.footer) {
35+
return {
36+
footer: modalData.footer,
37+
onOk: modalData.onOk,
38+
};
39+
} else {
40+
return {};
41+
}
42+
}, [modalData]);
43+
2944
return (
30-
!!modalData &&
31-
<AntdModal
32-
title={modalData.title}
33-
open={open}
34-
width={modalData.width}
35-
onCancel={() => {
36-
setOpen(false);
37-
}}
38-
destroyOnClose={true}
39-
footer={modalData.footer || false}
40-
>
41-
{modalData.content}
42-
</AntdModal>
45+
!!modalData && (
46+
<AntdModal
47+
title={modalData.title}
48+
open={open}
49+
width={modalData.width}
50+
onCancel={() => {
51+
setOpen(false);
52+
}}
53+
destroyOnClose={true}
54+
{...footer}
55+
>
56+
{modalData.content}
57+
</AntdModal>
58+
)
4359
);
4460
});
4561

chat2db-client/src/components/Output/index.less

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,14 @@
1010
position: sticky;
1111
top: 0;
1212
z-index: 1;
13-
background-color: var(--color-bg-subtle);
14-
border-bottom: 1px solid var(--color-border);
15-
line-height: 32px;
1613
display: flex;
1714
align-items: center;
18-
font-size: 14px;
19-
padding: 0px 4px;
15+
16+
background-color: var(--color-bg-subtle);
17+
line-height: 32px;
18+
padding: 0px 10px;
19+
font-weight: bold;
20+
border-bottom: 1px solid var(--color-border);
2021
i {
2122
margin-right: 6px;
2223
}
@@ -31,7 +32,7 @@
3132
display: flex;
3233
align-items: center;
3334
}
34-
.timeSpan{
35+
.timeSpan {
3536
margin-right: 4px;
3637
font-weight: 500;
3738
}
@@ -42,18 +43,19 @@
4243
color: var(--color-success);
4344
}
4445
}
45-
.failureIconBox{
46+
.failureIconBox {
4647
i {
4748
color: var(--color-error);
4849
}
4950
}
5051
> div {
5152
line-height: 22px;
5253
}
53-
.sqlPlace{
54+
.sqlPlace {
5455
color: var(--color-warning-text);
5556
}
56-
.sqlPlace,.sqlBox{
57+
.sqlPlace,
58+
.sqlBox {
5759
padding-left: 18px;
5860
}
5961
padding: 2px 0px;

chat2db-client/src/components/Output/index.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import i18n from '@/i18n';
99

1010
interface IProps {
1111
className?: string;
12-
curWorkspaceParams: any;
1312
}
1413

1514
interface IDatasource extends IHistoryRecord {
@@ -22,11 +21,11 @@ export default memo<IProps>((props) => {
2221
const outputContentRef = React.useRef<HTMLDivElement>(null);
2322
const curPageRef = React.useRef(1);
2423
const finishedRef = React.useRef(false);
25-
24+
2625
const getHistoryList = () => {
2726
return historyService
2827
.getHistoryList({
29-
dataSourceId:props.curWorkspaceParams.dataSourceId,
28+
// dataSourceId:props.curWorkspaceParams.dataSourceId,
3029
pageNo: curPageRef.current++,
3130
pageSize: 40,
3231
})
@@ -53,7 +52,7 @@ export default memo<IProps>((props) => {
5352
return (
5453
<div className={classnames(styles.output, className)}>
5554
<div className={styles.outputTitle}>
56-
<Iconfont code="&#xe8ad;" />
55+
{/* <Iconfont code="&#xe8ad;" /> */}
5756
{i18n('common.title.executiveLogging')}
5857
</div>
5958
<div className={styles.outputContent} ref={outputContentRef}>
@@ -74,7 +73,7 @@ export default memo<IProps>((props) => {
7473
</div>
7574
<span className={styles.timeSpan}>[{item.gmtCreate}]</span>
7675
{/* {!!item.operationRows && <span>{item.operationRows} rows</span>} */}
77-
{!!item.useTime && <span>{i18n('common.text.executionTime',item.useTime)}</span>}
76+
{!!item.useTime && <span>{i18n('common.text.executionTime', item.useTime)}</span>}
7877
</div>
7978
<div className={styles.sqlPlace}>{nameList.filter((name) => name).join(' > ')}</div>
8079
<div className={styles.sqlBox} dangerouslySetInnerHTML={{ __html: item.highlightedCode }} />

chat2db-client/src/i18n/en-us/common.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,4 +118,5 @@ export default {
118118
'common.button.closeOthers': 'Close others',
119119
'common.label.tcp': 'TCP',
120120
'common.label.LocalFile': 'LocalFile',
121+
'common.text.rename': 'Rename',
121122
};

chat2db-client/src/i18n/en-us/workspace.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ export default {
22
'workspace.title': 'Workspace',
33
'workspace.cascader.placeholder': 'Select Here',
44
'workspace.ai.input.placeholder': 'Enter your plain text statement here',
5-
'workspace.title.saved': 'Saved',
5+
'workspace.title.savedConsole': 'Saved console',
66
'workspace.menu.ViewDDL': 'View DDL',
77
'workspace.menu.deleteTable': 'Delete Table',
88
'workspace.menu.openTable': 'Open Table',

chat2db-client/src/i18n/zh-cn/common.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,4 +117,5 @@ export default {
117117
'common.button.closeOthers': '关闭其他',
118118
'common.label.tcp': '线上',
119119
'common.label.LocalFile': '本地',
120+
'common.text.rename': '重命名',
120121
};

chat2db-client/src/i18n/zh-cn/workspace.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ export default {
22
'workspace.title': '工作台',
33
'workspace.cascader.placeholder': '请选择',
44
'workspace.ai.input.placeholder': '在这里输入纯文本语句',
5-
'workspace.title.saved': '保存记录',
5+
'workspace.title.savedConsole': '保存记录',
66
'workspace.menu.ViewDDL': '查看DDL',
77
'workspace.menu.deleteTable': '删除表',
88
'workspace.menu.openTable': '打开表',

chat2db-client/src/pages/main/store/connection/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import connectionService from '@/service/connection';
88

99
import { setCurrentConnectionDetails } from '@/pages/main/workspace/store/common';
1010
import { useWorkspaceStore } from '@/pages/main/workspace/store';
11-
import { getSavedConsoleList } from '@/pages/main/workspace/store/console';
11+
import { getOpenConsoleList } from '@/pages/main/workspace/store/console';
1212

1313
export interface IConnectionStore {
1414
connectionList: IConnectionListItem[] | null;
@@ -47,7 +47,7 @@ export const getConnectionList: () => Promise<IConnectionListItem[]> = () => {
4747
useConnectionStore.setState({ connectionList });
4848
resolve(connectionList);
4949
// 连接删除后需要更新下 consoleList
50-
getSavedConsoleList();
50+
getOpenConsoleList();
5151

5252
// 如果连接列表为空,则设置当前连接为空
5353
if (connectionList.length === 0) {

0 commit comments

Comments
 (0)