Skip to content

Commit 824237d

Browse files
committed
open Table editing
1 parent 9c235b1 commit 824237d

10 files changed

Lines changed: 66 additions & 27 deletions

File tree

chat2db-client/src/components/ConnectionEdit/config/dataSource.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,7 +1013,7 @@ export const dataSourceFormConfigs: IConnectionConfig[] = [
10131013
],
10141014
pattern: /jdbc:clickhouse:\/\/(.*):(\d+)(\/(\w+))?/,
10151015
template: 'jdbc:clickhouse://{host}:{port}/{database}',
1016-
excludes: [OperationColumn.ExportDDL, OperationColumn.CreateTable,OperationColumn.EditTable]
1016+
excludes: [OperationColumn.ViewDDL, OperationColumn.CreateTable,OperationColumn.EditTable]
10171017
//排除掉导出ddl 和 创建表功能 支持的功能见 ./enum.ts => OperationColumn
10181018
},
10191019
ssh: sshConfig,
@@ -1122,7 +1122,7 @@ export const dataSourceFormConfigs: IConnectionConfig[] = [
11221122
],
11231123
pattern: /jdbc:dm:\/\/(.*):(\d+)(\/(\w+))?/,
11241124
template: 'jdbc:dm://{host}:{port}/{database}',
1125-
excludes: [OperationColumn.EditTable]
1125+
// excludes: [OperationColumn.EditTable]
11261126

11271127
},
11281128
ssh: sshConfig,
@@ -1249,7 +1249,7 @@ export const dataSourceFormConfigs: IConnectionConfig[] = [
12491249
],
12501250
pattern: /jdbc:db2:\/\/(.*):(\d+)(\/(\w+))?/,
12511251
template: 'jdbc:db2://{host}:{port}/{database}',
1252-
excludes: [OperationColumn.EditTable]
1252+
// excludes: [OperationColumn.EditTable]
12531253

12541254
},
12551255
ssh: sshConfig,
@@ -1373,7 +1373,7 @@ export const dataSourceFormConfigs: IConnectionConfig[] = [
13731373
],
13741374
pattern: /jdbc:presto:\/\/(.*):(\d+)(\/(\w+))?/,
13751375
template: 'jdbc:presto://{host}:{port}/{database}',
1376-
excludes: [OperationColumn.EditTable]
1376+
// excludes: [OperationColumn.EditTable]
13771377

13781378
},
13791379
ssh: sshConfig,
@@ -1497,7 +1497,7 @@ export const dataSourceFormConfigs: IConnectionConfig[] = [
14971497
],
14981498
pattern: /jdbc:oceanbase:\/\/(.*):(\d+)(\/(\w+))?/,
14991499
template: 'jdbc:oceanbase://{host}:{port}/{database}',
1500-
excludes: [OperationColumn.EditTable]
1500+
// excludes: [OperationColumn.EditTable]
15011501

15021502
},
15031503
ssh: sshConfig,
@@ -1743,7 +1743,7 @@ export const dataSourceFormConfigs: IConnectionConfig[] = [
17431743
],
17441744
pattern: /jdbc:hive2:\/\/(.*):(\d+)(\/(\w+))?/,
17451745
template: 'jdbc:hive2://{host}:{port}/{database}',
1746-
excludes: [OperationColumn.EditTable]
1746+
// excludes: [OperationColumn.EditTable]
17471747

17481748
},
17491749
ssh: sshConfig,
@@ -1867,7 +1867,7 @@ export const dataSourceFormConfigs: IConnectionConfig[] = [
18671867
],
18681868
pattern: /jdbc:kingbase8:\/\/(.*):(\d+)(\/(\w+))?/,
18691869
template: 'jdbc:kingbase8://{host}:{port}/{database}',
1870-
excludes: [OperationColumn.EditTable]
1870+
// excludes: [OperationColumn.EditTable]
18711871

18721872
},
18731873
ssh: sshConfig,

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ export default memo<IProps>((props) => {
2424
className={classnames(styles.iconPanelLeft, styles.iconPanel, { [styles.iconPanelLeftHidden]: !panelLeft })}
2525
onClick={togglePanelLeft}
2626
/>
27-
{/* <div
27+
<div
2828
className={classnames(styles.iconPanelRight, styles.iconPanel, { [styles.iconPanelRightHidden]: !panelRight })}
2929
onClick={togglePanelRight}
30-
/> */}
30+
/>
3131
</div>
3232
);
3333
});

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ if (__ENV__ === 'local') {
99
/* 在线链接服务仅供平台体验和调试使用,平台不承诺服务的稳定性,企业客户需下载字体包自行发布使用并做好备份。 */
1010
@font-face {
1111
font-family: 'iconfont'; /* Project id 3633546 */
12-
src: url('//at.alicdn.com/t/c/font_3633546_41e9epm207i.woff2?t=1697978442427') format('woff2'),
13-
url('//at.alicdn.com/t/c/font_3633546_41e9epm207i.woff?t=1697978442427') format('woff'),
14-
url('//at.alicdn.com/t/c/font_3633546_41e9epm207i.ttf?t=1697978442427') format('truetype');
12+
src: url('//at.alicdn.com/t/c/font_3633546_201093ssteq.woff2?t=1698848610675') format('woff2'),
13+
url('//at.alicdn.com/t/c/font_3633546_201093ssteq.woff?t=1698848610675') format('woff'),
14+
url('//at.alicdn.com/t/c/font_3633546_201093ssteq.ttf?t=1698848610675') format('truetype');
1515
}
1616
`;
1717
const style = document.createElement('style');

chat2db-client/src/constants/tree.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,10 @@ export enum OperationColumn {
3030
CreateTable = 'createTable', //创建表
3131
CreateConsole = 'createConsole', // 新建console
3232
DeleteTable = 'deleteTable', // 删除表
33-
ExportDDL = 'exportDDL', // 导出ddl
33+
ViewDDL = 'viewDDL', // 导出ddl
3434
EditSource = 'editSource', // 编辑数据源
3535
Top = 'top', // 置顶
3636
EditTable = 'editTable', // 编辑表
3737
EditTableData = 'editTableData', // 编辑表数据
38+
CopyName = 'copyName', // 复制名称
3839
}

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.cascader.placeholder': 'Select Here',
33
'workspace.ai.input.placeholder': 'Enter your plain text statement here',
44
'workspace.title.saved': 'Saved',
5-
'workspace.menu.exportDDL': 'Export DDL',
5+
'workspace.menu.ViewDDL': 'View DDL',
66
'workspace.menu.deleteTable': 'Delete Table',
77
'workspace.menu.editTable': 'Edit Table',
88
'workspace.menu.pin': 'Pin',

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.cascader.placeholder': '请选择',
33
'workspace.ai.input.placeholder': '在这里输入纯文本语句',
44
'workspace.title.saved': '保存记录',
5-
'workspace.menu.exportDDL': '导出DDL',
5+
'workspace.menu.ViewDDL': '查看DDL',
66
'workspace.menu.deleteTable': '删除表',
77
'workspace.menu.editTable': '修改表',
88
'workspace.menu.pin': '置顶',

chat2db-client/src/pages/main/workspace/components/Tree/TreeNodeRightClick/index.less

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
}
1515
}
1616
}
17+
.errorOperationItem{
18+
19+
}
1720

1821
.monacoEditorBox {
1922
margin-top: -15px;

chat2db-client/src/pages/main/workspace/components/Tree/TreeNodeRightClick/index.tsx

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import React, { memo, useMemo, useRef, useState } from 'react';
2+
import { message, Modal, Input, Dropdown, notification } from 'antd';
3+
import classnames from 'classnames';
24
import i18n from '@/i18n';
35
import styles from './index.less';
46
import Iconfont from '@/components/Iconfont';
5-
import { message, Modal, Input, Dropdown, notification } from 'antd';
67
import { TreeNodeType, CreateTabIntroType, WorkspaceTabType, OperationColumn } from '@/constants';
78
import { ITreeConfigItem, treeConfig } from '@/pages/main/workspace/components/Tree/treeConfig';
89
import { ITreeNode } from '@/typings';
@@ -59,10 +60,10 @@ function TreeNodeRightClick(props: IProps) {
5960
},
6061
};
6162
},
62-
[OperationColumn.ExportDDL]: () => {
63+
[OperationColumn.ViewDDL]: () => {
6364
return {
64-
text: i18n('workspace.menu.exportDDL'),
65-
icon: '\ue613',
65+
text: i18n('workspace.menu.ViewDDL'),
66+
icon: '\ue665',
6667
handle: () => {
6768
mysqlServer
6869
.exportCreateTableSql({
@@ -151,13 +152,22 @@ function TreeNodeRightClick(props: IProps) {
151152
},
152153
};
153154
},
154-
[OperationColumn.Top]: (data) => {
155+
[OperationColumn.Top]: (_data) => {
155156
return {
156-
text: data.pinned ? i18n('workspace.menu.unPin') : i18n('workspace.menu.pin'),
157-
icon: data.pinned ? '\ue61d' : '\ue627',
157+
text: _data.pinned ? i18n('workspace.menu.unPin') : i18n('workspace.menu.pin'),
158+
icon: _data.pinned ? '\ue61d' : '\ue627',
158159
handle: handleTop,
159160
};
160161
},
162+
[OperationColumn.CopyName]: (_data) => {
163+
return {
164+
text: i18n('common.button.copy'),
165+
icon: '\uec7a',
166+
handle: ()=>{
167+
navigator.clipboard.writeText(_data.key.toString())
168+
},
169+
};
170+
},
161171
};
162172

163173
function handleTop() {
@@ -262,7 +272,7 @@ function TreeNodeRightClick(props: IProps) {
262272
return {
263273
key: i,
264274
label: (
265-
<div className={styles.operationItem}>
275+
<div className={classnames(styles.operationItem)}>
266276
<Iconfont className={styles.operationIcon} code={concrete?.icon} />
267277
<div className={styles.operationTitle}>{concrete.text}</div>
268278
</div>

chat2db-client/src/pages/main/workspace/components/Tree/treeConfig.tsx

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export const switchIcon: Partial<{ [key in TreeNodeType]: { icon: string; unfold
6060
// CreateTable = 'createTable',
6161
// CreateConsole = 'createConsole',
6262
// DeleteTable = 'deleteTable',
63-
// ExportDDL = 'exportDDL',
63+
// ViewDDL = 'viewDDL',
6464
// EditSource = 'editSource',
6565
// Top = 'top',
6666
// EditTable = 'editTable',
@@ -256,10 +256,10 @@ export const treeConfig: { [key in TreeNodeType]: ITreeConfigItem } = {
256256
});
257257
},
258258
operationColumn: [
259-
// OperationColumn.EditTableData,
260259
OperationColumn.Top,
261-
OperationColumn.ExportDDL,
260+
OperationColumn.ViewDDL,
262261
OperationColumn.EditTable,
262+
OperationColumn.CopyName,
263263
OperationColumn.DeleteTable,
264264
],
265265
},
@@ -325,6 +325,9 @@ export const treeConfig: { [key in TreeNodeType]: ITreeConfigItem } = {
325325

326326
[TreeNodeType.FUNCTION]: {
327327
icon: '\ue76a',
328+
operationColumn: [
329+
OperationColumn.CopyName
330+
],
328331
},
329332

330333
[TreeNodeType.PROCEDURES]: {
@@ -359,6 +362,9 @@ export const treeConfig: { [key in TreeNodeType]: ITreeConfigItem } = {
359362

360363
[TreeNodeType.PROCEDURE]: {
361364
icon: '\ue73c',
365+
operationColumn: [
366+
OperationColumn.CopyName
367+
],
362368
},
363369

364370
[TreeNodeType.TRIGGERS]: {
@@ -393,6 +399,9 @@ export const treeConfig: { [key in TreeNodeType]: ITreeConfigItem } = {
393399

394400
[TreeNodeType.TRIGGER]: {
395401
icon: '\ue64a',
402+
operationColumn: [
403+
OperationColumn.CopyName
404+
],
396405
},
397406

398407
[TreeNodeType.VIEW]: {
@@ -410,6 +419,9 @@ export const treeConfig: { [key in TreeNodeType]: ITreeConfigItem } = {
410419
r(list);
411420
});
412421
},
422+
operationColumn: [
423+
OperationColumn.CopyName
424+
],
413425
},
414426

415427
[TreeNodeType.VIEWCOLUMNS]: {
@@ -442,6 +454,9 @@ export const treeConfig: { [key in TreeNodeType]: ITreeConfigItem } = {
442454
},
443455
[TreeNodeType.VIEWCOLUMN]: {
444456
icon: '\ue647',
457+
operationColumn: [
458+
OperationColumn.CopyName
459+
],
445460
},
446461

447462
[TreeNodeType.COLUMNS]: {
@@ -472,6 +487,9 @@ export const treeConfig: { [key in TreeNodeType]: ITreeConfigItem } = {
472487
},
473488
[TreeNodeType.COLUMN]: {
474489
icon: '\ue611',
490+
operationColumn: [
491+
OperationColumn.CopyName
492+
],
475493
},
476494
[TreeNodeType.KEYS]: {
477495
icon: '\ueac5',
@@ -498,6 +516,10 @@ export const treeConfig: { [key in TreeNodeType]: ITreeConfigItem } = {
498516
},
499517
[TreeNodeType.KEY]: {
500518
icon: '\ue775',
519+
operationColumn: [
520+
OperationColumn.CopyName
521+
],
522+
501523
},
502524
[TreeNodeType.INDEXES]: {
503525
icon: '\ueac5',
@@ -524,5 +546,8 @@ export const treeConfig: { [key in TreeNodeType]: ITreeConfigItem } = {
524546
},
525547
[TreeNodeType.INDEX]: {
526548
icon: '\ue65b',
549+
operationColumn: [
550+
OperationColumn.CopyName
551+
],
527552
},
528553
};

chat2db-client/src/pages/main/workspace/components/WorkspaceRight/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ const WorkspaceRight = memo<IProps>((props: IProps) => {
620620
items={tabsList}
621621
/>
622622
</div>
623-
{/* <WorkspaceExtend curWorkspaceParams={curWorkspaceParams} className={styles.workspaceExtend} /> */}
623+
<WorkspaceExtend curWorkspaceParams={curWorkspaceParams} className={styles.workspaceExtend} />
624624
</LoadingContent>
625625
</div>
626626
);

0 commit comments

Comments
 (0)