Skip to content

Commit 1d37d3b

Browse files
committed
Hide edit tables for unsupported databases
1 parent 2ff7e86 commit 1d37d3b

3 files changed

Lines changed: 25 additions & 25 deletions

File tree

  • chat2db-client/src

chat2db-client/src/blocks/DatabaseTableEditor/ColumnList/index.tsx

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -409,22 +409,6 @@ const ColumnList = forwardRef((props: IProps, ref: ForwardedRef<IColumnListRef>)
409409
/>
410410
</Form.Item>
411411
)}
412-
{editingConfig?.supportDefaultValue && (
413-
<Form.Item labelCol={labelCol} label={i18n('editTable.label.defaultValue')} name="defaultValue">
414-
<CustomSelect
415-
options={[
416-
{
417-
label: 'EMPTY_STRING',
418-
value: 'EMPTY_STRING',
419-
},
420-
{
421-
label: 'NULL',
422-
value: 'NULL',
423-
},
424-
]}
425-
/>
426-
</Form.Item>
427-
)}
428412
{editingConfig?.supportCharset && (
429413
<Form.Item labelCol={labelCol} label={i18n('editTable.label.characterSet')} name="charSetName">
430414
<CustomSelect options={databaseSupportField.charsets} />

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

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,6 @@ export const dataSourceFormConfigs: IConnectionConfig[] = [
360360
],
361361
pattern: /jdbc:postgresql:\/\/(.*):(\d+)(\/(\w+))?/,
362362
template: 'jdbc:postgresql://{host}:{port}/{database}',
363-
excludes: [OperationColumn.EditTable]
364363
},
365364
ssh: sshConfig,
366365
},
@@ -612,7 +611,6 @@ export const dataSourceFormConfigs: IConnectionConfig[] = [
612611
],
613612
pattern: /jdbc:h2:tcp:\/\/(.*):(\d+)(\/(\w+))?/,
614613
template: 'jdbc:h2:tcp://{host}:{port}/{database}',
615-
excludes: [OperationColumn.EditTable]
616614
},
617615
ssh: sshConfig,
618616
},
@@ -1015,7 +1013,7 @@ export const dataSourceFormConfigs: IConnectionConfig[] = [
10151013
],
10161014
pattern: /jdbc:clickhouse:\/\/(.*):(\d+)(\/(\w+))?/,
10171015
template: 'jdbc:clickhouse://{host}:{port}/{database}',
1018-
excludes: [OperationColumn.ExportDDL, OperationColumn.CreateTable]
1016+
excludes: [OperationColumn.ExportDDL, OperationColumn.CreateTable,OperationColumn.EditTable]
10191017
//排除掉导出ddl 和 创建表功能 支持的功能见 ./enum.ts => OperationColumn
10201018
},
10211019
ssh: sshConfig,
@@ -1124,6 +1122,8 @@ export const dataSourceFormConfigs: IConnectionConfig[] = [
11241122
],
11251123
pattern: /jdbc:dm:\/\/(.*):(\d+)(\/(\w+))?/,
11261124
template: 'jdbc:dm://{host}:{port}/{database}',
1125+
excludes: [OperationColumn.EditTable]
1126+
11271127
},
11281128
ssh: sshConfig,
11291129
extendInfo: [
@@ -1249,6 +1249,8 @@ export const dataSourceFormConfigs: IConnectionConfig[] = [
12491249
],
12501250
pattern: /jdbc:db2:\/\/(.*):(\d+)(\/(\w+))?/,
12511251
template: 'jdbc:db2://{host}:{port}/{database}',
1252+
excludes: [OperationColumn.EditTable]
1253+
12521254
},
12531255
ssh: sshConfig,
12541256
extendInfo: [
@@ -1371,6 +1373,8 @@ export const dataSourceFormConfigs: IConnectionConfig[] = [
13711373
],
13721374
pattern: /jdbc:presto:\/\/(.*):(\d+)(\/(\w+))?/,
13731375
template: 'jdbc:presto://{host}:{port}/{database}',
1376+
excludes: [OperationColumn.EditTable]
1377+
13741378
},
13751379
ssh: sshConfig,
13761380
extendInfo: [
@@ -1493,6 +1497,8 @@ export const dataSourceFormConfigs: IConnectionConfig[] = [
14931497
],
14941498
pattern: /jdbc:oceanbase:\/\/(.*):(\d+)(\/(\w+))?/,
14951499
template: 'jdbc:oceanbase://{host}:{port}/{database}',
1500+
excludes: [OperationColumn.EditTable]
1501+
14961502
},
14971503
ssh: sshConfig,
14981504
extendInfo: [
@@ -1737,6 +1743,8 @@ export const dataSourceFormConfigs: IConnectionConfig[] = [
17371743
],
17381744
pattern: /jdbc:hive2:\/\/(.*):(\d+)(\/(\w+))?/,
17391745
template: 'jdbc:hive2://{host}:{port}/{database}',
1746+
excludes: [OperationColumn.EditTable]
1747+
17401748
},
17411749
ssh: sshConfig,
17421750
extendInfo: [
@@ -1859,6 +1867,8 @@ export const dataSourceFormConfigs: IConnectionConfig[] = [
18591867
],
18601868
pattern: /jdbc:kingbase8:\/\/(.*):(\d+)(\/(\w+))?/,
18611869
template: 'jdbc:kingbase8://{host}:{port}/{database}',
1870+
excludes: [OperationColumn.EditTable]
1871+
18621872
},
18631873
ssh: sshConfig,
18641874
extendInfo: [

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

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { IConnectionModelType } from '@/models/connection';
99
import { IWorkspaceModelType } from '@/models/workspace';
1010
import Tree from '../Tree';
1111
import { treeConfig } from '../Tree/treeConfig';
12-
import { TreeNodeType, WorkspaceTabType, ConsoleStatus, ConsoleOpenedStatus } from '@/constants';
12+
import { TreeNodeType, WorkspaceTabType, ConsoleStatus, ConsoleOpenedStatus, OperationColumn } from '@/constants';
1313
import { approximateTreeNode } from '@/utils';
1414
import { useUpdateEffect } from '@/hooks/useUpdateEffect';
1515
import { v4 as uuidV4 } from 'uuid';
@@ -18,6 +18,7 @@ import styles from './index.less';
1818
import { ExportTypeEnum } from '@/typings/resultTable';
1919
import historyService from '@/service/history';
2020
import { debounce } from 'lodash';
21+
import { dataSourceFormConfigs } from '@/components/ConnectionEdit/config/dataSource';
2122

2223
interface IOption {
2324
value: TreeNodeType;
@@ -72,8 +73,8 @@ const TableList = dvaModel((props: any) => {
7273
props.onExport && props.onExport(exportType);
7374
};
7475

75-
const items: MenuProps['items'] = useMemo(
76-
() => [
76+
const items: MenuProps['items'] = useMemo(() => {
77+
const list = [
7778
{
7879
label: (
7980
<div className={styles.operationItem}>
@@ -177,9 +178,14 @@ const TableList = dvaModel((props: any) => {
177178
},
178179
],
179180
},
180-
],
181-
[curWorkspaceParams],
182-
);
181+
];
182+
const dataSourceFormConfig = dataSourceFormConfigs.find((item) => item.type === curWorkspaceParams.databaseType);
183+
184+
if (dataSourceFormConfig?.baseInfo.excludes?.includes(OperationColumn.EditTable)) {
185+
list.splice(1, 1);
186+
}
187+
return list;
188+
}, [curWorkspaceParams]);
183189

184190
useUpdateEffect(() => {
185191
setCurList([]);

0 commit comments

Comments
 (0)