From 7e9548985c9d1dae81911e06802b50444f4cd502 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=95=85=E6=99=9A?= Date: Mon, 8 Jul 2024 21:28:40 +0800 Subject: [PATCH 1/2] PullRequest: 465 feat/dev-4.3.1-objectSearch-interactive MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Merge branch 'feat/dev-4.3.1-objectSearch-interactive of git@code.alipay.com:oceanbase/oceanbase-developer-center.git into dev-4.3.1 https://code.alipay.com/oceanbase/oceanbase-developer-center/pull_requests/465 Signed-off-by: 晓康 * Fixes oceanbase/odc#2727, Fixes oceanbase/odc#2728, Fixes oceanbase/odc#2742, Fixes oceanbase/odc#2767 --- .../components/DatabaseList.tsx | 101 ++++++---- .../components/ObjectList.tsx | 175 +++++++++++++----- .../DatabaseSearchModal/components/Search.tsx | 92 +++------ .../DatabaseSearchModal/constant.ts | 5 + .../DatabaseSearchModal/index.less | 25 +-- .../DatabaseSearchModal/index.tsx | 28 +-- src/style/theme/dark.less | 1 + src/style/theme/white.less | 1 + 8 files changed, 253 insertions(+), 175 deletions(-) diff --git a/src/page/Workspace/SideBar/ResourceTree/DatabaseSearchModal/components/DatabaseList.tsx b/src/page/Workspace/SideBar/ResourceTree/DatabaseSearchModal/components/DatabaseList.tsx index f99bc017f..900965880 100644 --- a/src/page/Workspace/SideBar/ResourceTree/DatabaseSearchModal/components/DatabaseList.tsx +++ b/src/page/Workspace/SideBar/ResourceTree/DatabaseSearchModal/components/DatabaseList.tsx @@ -1,5 +1,5 @@ import { formatMessage } from '@/util/intl'; -import { Button } from 'antd'; +import { Button, Space } from 'antd'; import styles from '../index.less'; import DataBaseStatusIcon from '@/component/StatusIcon/DatabaseIcon'; import ResourceTreeContext from '@/page/Workspace/context/ResourceTreeContext'; @@ -7,17 +7,16 @@ import React, { useState, useContext } from 'react'; import { IDatabase, IDatabaseObject } from '@/d.ts/database'; import { ModalStore } from '@/store/modal'; import { openNewSQLPage } from '@/store/helper/page'; +import { getDataSourceStyleByConnectType } from '@/common/datasource'; +import Icon from '@ant-design/icons'; interface Iprops { database: IDatabase; setDatabase: React.Dispatch>; databaseList: IDatabase[]; objectlist: IDatabaseObject; - setSelectDatabaseState: React.Dispatch>; searchKey: string; setSearchKey: React.Dispatch>; - isSelectAll: boolean; - setSelectAllState: React.Dispatch>; modalStore: ModalStore; } @@ -25,17 +24,18 @@ const DatabaseList = ({ database, setDatabase, databaseList, - setSelectDatabaseState, searchKey, setSearchKey, - isSelectAll, - setSelectAllState, modalStore, objectlist, }: Iprops) => { - const { selectProjectId } = useContext(ResourceTreeContext); + const { selectDatasourceId, selectProjectId, projectList, datasourceList } = + useContext(ResourceTreeContext); const [activeDatabase, setActiveDatabase] = useState(); + const selectProject = projectList?.find((p) => p.id == selectProjectId); + const selectDatasource = datasourceList?.find((d) => d.id == selectDatasourceId); + const getOptions = () => { if (objectlist) { return objectlist.databases; @@ -46,18 +46,11 @@ const DatabaseList = ({ }; const options = getOptions(); - const changeDatabase = (item) => { + const changeDatabase = (e, item) => { + if (!item?.authorizedPermissionTypes?.length) return; setDatabase(item); - setSelectDatabaseState(true); - setSearchKey(''); - setSelectAllState(false); - }; - - const selectAll = () => { - setDatabase(null); - setSelectDatabaseState(false); setSearchKey(''); - setSelectAllState(true); + openSql(e, item); }; const openSql = (e, db) => { @@ -76,38 +69,63 @@ const DatabaseList = ({ modalStore.changeDatabaseSearchModalVisible(false); }; + const getDataSourceIcon = (type) => { + const DBIcon = getDataSourceStyleByConnectType(type)?.icon; + return ( + + ); + }; + const getPositioninButton = (db: IDatabase) => { if (activeDatabase?.id !== db.id) return null; - if (!!db?.authorizedPermissionTypes?.length) { + if (!db?.authorizedPermissionTypes?.length) { return ( - ); } + }; + + if (database && !searchKey) { return ( - ); - }; - + } return (
-
- {formatMessage({ - id: 'src.page.Workspace.SideBar.ResourceTree.DatabaseSearchModal.components.69106FDA', - defaultMessage: '全部数据库', - })} +
+ {selectProject + ? formatMessage( + { + id: 'src.page.Workspace.SideBar.ResourceTree.DatabaseSearchModal.components.6D5791AB', + defaultMessage: '当前项目: ${selectProject?.name}', + }, + { selectProjectName: selectProject?.name }, + ) + : formatMessage( + { + id: 'src.page.Workspace.SideBar.ResourceTree.DatabaseSearchModal.components.987D5B8A', + defaultMessage: '当前数据源: ${selectDatasource?.name}', + }, + { selectDatasourceName: selectDatasource?.name }, + )}
{options?.length ? options.map((db) => { @@ -115,7 +133,7 @@ const DatabaseList = ({ <>
changeDatabase(db)} + onClick={(e) => changeDatabase(e, db)} className={ database?.id === db?.id ? styles.databaseItemActive : styles.databaseItem } @@ -133,7 +151,12 @@ const DatabaseList = ({
{db?.name}
- {selectProjectId ? db?.dataSource?.name : null} + {selectProjectId ? ( + + {getDataSourceIcon(db?.dataSource?.dialectType)} + {db?.dataSource?.name} + + ) : null}
{getPositioninButton(db)} diff --git a/src/page/Workspace/SideBar/ResourceTree/DatabaseSearchModal/components/ObjectList.tsx b/src/page/Workspace/SideBar/ResourceTree/DatabaseSearchModal/components/ObjectList.tsx index d0e531486..dafb20d0e 100644 --- a/src/page/Workspace/SideBar/ResourceTree/DatabaseSearchModal/components/ObjectList.tsx +++ b/src/page/Workspace/SideBar/ResourceTree/DatabaseSearchModal/components/ObjectList.tsx @@ -18,6 +18,8 @@ import { ModalStore } from '@/store/modal'; interface Iprops { database: IDatabase; objectlist: IDatabaseObject; + setDatabase: React.Dispatch>; + setSearchKey: React.Dispatch>; activeKey: string; setActiveKey: React.Dispatch>; modalStore: ModalStore; @@ -26,9 +28,11 @@ interface Iprops { const ObjectList = ({ database, + setDatabase, objectlist, activeKey, setActiveKey, + setSearchKey, modalStore, loading, }: Iprops) => { @@ -40,6 +44,8 @@ const ObjectList = ({ const typeObjectTree = typeList?.map((i) => { if (i === DbObjectType.column) { return { key: i, data: objectlist?.dbColumns }; + } else if (i === DbObjectType.database) { + return { key: i, data: objectlist?.databases }; } else { return { key: i, data: objectlist?.dbObjects?.filter((obj) => obj.type === i) }; } @@ -87,10 +93,8 @@ const ObjectList = ({ {datasourceIcon(dialectTypeIcon?.component)} {dataSourceName} {divider} - {commonIcon(dbIcon?.component)} {databaseName} {divider} - {commonIcon(DbObjsIcon[type])} @@ -99,19 +103,27 @@ const ObjectList = ({ ); - + case DbObjectType.database: { + const { dataSource } = item; + const { name: dataSourceName, dialectType } = dataSource; + const dialectTypeIcon = getDataSourceStyleByConnectType(dialectType)?.icon; + return ( + <> + {datasourceIcon(dialectTypeIcon?.component)} + {dataSourceName} + + ); + } default: { const { database } = item; const { name: databaseName, dataSource } = database; const { name: dataSourceName, dialectType } = dataSource; const dialectTypeIcon = getDataSourceStyleByConnectType(dialectType)?.icon; - const dbIcon = getDataSourceStyleByConnectType(dialectType)?.dbIcon; return ( <> {datasourceIcon(dialectTypeIcon?.component)} {dataSourceName} {divider} - {commonIcon(dbIcon?.component)} {databaseName} @@ -128,7 +140,7 @@ const ObjectList = ({ {!objectlist?.dbColumns?.length && !objectlist?.dbObjects?.length ? (
- +
) : (
@@ -136,7 +148,24 @@ const ObjectList = ({ if (i?.data?.length) { return (
-
{DbObjectTypeMap[i.key].label}
+
+
{DbObjectTypeMap[i.key].label}
+ {i.data.length > ALL_TAB_MAX_LENGTH ? ( + + ) : null} +
{i.data.map((object, index) => { if (index < ALL_TAB_MAX_LENGTH) { @@ -148,15 +177,25 @@ const ObjectList = ({ onMouseLeave={() => setActiveDatabase(null)} >
- - + {i.key === DbObjectType.database ? ( + + ) : ( + + )} {object?.name}
- {permissionBtn(object)} + {i.key === DbObjectType.database + ? selectDbBtn(object) + : permissionBtn(object)}
); } })}
- {i.data.length > ALL_TAB_MAX_LENGTH ? ( - - ) : null}
@@ -203,11 +232,16 @@ const ObjectList = ({ ); }; - const applyPermission = (e, object) => { + const applyTablePermission = (e, object) => { e.stopPropagation(); - modalStore.changeApplyDatabasePermissionModal(true, { - projectId: object?.dbObject?.database?.project?.id || object?.database?.project?.id, - databaseId: object?.dbObject?.database?.id || object?.database?.id, + const params = { + projectId: object?.database?.project?.id, + databaseId: object?.database?.id, + tableName: object?.name, + tableId: object?.id, + }; + modalStore.changeApplyTablePermissionModal(true, { + ...params, }); modalStore.changeDatabaseSearchModalVisible(false); }; @@ -226,7 +260,7 @@ const ObjectList = ({ + ); + } + return ( + + ); + }; + const openTree = (e, object) => { if (!hasPermission(object)) return; const type = object?.type || DbObjectType.column; @@ -250,11 +321,18 @@ const ObjectList = ({ const renderObjectTypeTabs = (type) => { const currentObjectList = typeObjectTree?.find((i) => i.key === type); + const isDatabasetab = currentObjectList.key === DbObjectType.database; return ( {!currentObjectList?.data?.length ? (
- + +
暂无数据
如果检索不到已存在的数据库对象,请先同步元数据 + + } + />
) : (
@@ -262,15 +340,27 @@ const ObjectList = ({ return (
openTree(e, object)} + onClick={(e) => { + !isDatabasetab ? openTree(e, object) : null; + }} onMouseEnter={() => setActiveDatabase(object)} onMouseLeave={() => setActiveDatabase(null)} >
- + {isDatabasetab ? ( + + ) : ( + + )} {object?.name}
- {permissionBtn(object)} + {isDatabasetab ? selectDbBtn(object) : permissionBtn(object)}
); })} @@ -323,6 +413,7 @@ const ObjectList = ({ }, ].concat( objectTypeConfig[dbType]?.map((i) => { + if (i === DbObjectType.database && database) return; return { key: i, label: {DbObjectTypeMap?.[i]?.label}, diff --git a/src/page/Workspace/SideBar/ResourceTree/DatabaseSearchModal/components/Search.tsx b/src/page/Workspace/SideBar/ResourceTree/DatabaseSearchModal/components/Search.tsx index 9f6bd7d73..1e61ddcf2 100644 --- a/src/page/Workspace/SideBar/ResourceTree/DatabaseSearchModal/components/Search.tsx +++ b/src/page/Workspace/SideBar/ResourceTree/DatabaseSearchModal/components/Search.tsx @@ -3,7 +3,7 @@ import { Input, Tooltip } from 'antd'; import React, { useContext, useEffect, useRef } from 'react'; import ResourceTreeContext from '@/page/Workspace/context/ResourceTreeContext'; import styles from '../index.less'; -import { DownOutlined, SearchOutlined, LoadingOutlined } from '@ant-design/icons'; +import { SearchOutlined, LoadingOutlined, CloseCircleFilled } from '@ant-design/icons'; import DataBaseStatusIcon from '@/component/StatusIcon/DatabaseIcon'; import { IDatabase } from '@/d.ts/database'; import { SearchTypeMap } from '../constant'; @@ -13,23 +13,19 @@ interface Iprops { database: IDatabase; visible: boolean; onChangeInput: (SearchTypeMap: SearchTypeMap, value: string) => void; - isSelectDatabase: boolean; searchKey: string; - isSelectAll: boolean; - setSelectAllState: React.Dispatch>; loading: boolean; setDatabase: React.Dispatch>; + setSearchKey: React.Dispatch>; } const Search = ({ database, visible, onChangeInput, - isSelectDatabase, searchKey, - isSelectAll, - setSelectAllState, loading, setDatabase, + setSearchKey, }: Iprops) => { const { selectDatasourceId, selectProjectId, projectList, datasourceList } = useContext(ResourceTreeContext); @@ -47,11 +43,9 @@ const Search = ({ const getDataBase = () => { const divider = () => - (isSelectAll || database) && ( + database && ( <> - - - + / ); @@ -62,64 +56,39 @@ const Search = ({ className={styles.selectedDatabase} onClick={() => { setDatabase(null); - setSelectAllState(false); onChangeInput(SearchTypeMap.DATABASE, null); }} > - + {database?.name} {divider()} ); } - if (isSelectAll) { - return ( - { - setDatabase(null); - setSelectAllState(false); - onChangeInput(SearchTypeMap.DATABASE, null); - }} - > - {formatMessage({ - id: 'src.page.Workspace.SideBar.ResourceTree.DatabaseSearchModal.components.9F4C3737', - defaultMessage: '全部数据库', - })} - - {divider()} - - ); - } return null; }; - const handleChangeDatabaswSearch = (e) => { + const handleChangeDatabaseSearch = (e) => { onChangeInput(SearchTypeMap.DATABASE, e.target.value); }; const handleChangeObjectSearch = (e) => { - if (isSelectAll) { - onChangeInput(SearchTypeMap.OBJECT, e.target.value); - } else if (e.target.value === '') { - onChangeInput(SearchTypeMap.DATABASE, ''); - } else { - onChangeInput(SearchTypeMap.OBJECT, e.target.value); - } + onChangeInput(SearchTypeMap.OBJECT, e.target.value); }; const getObjectInput = () => { - if (isSelectDatabase && !database) { + if (!database) { return ( ); @@ -140,33 +109,28 @@ const Search = ({ const getIcon = () => { const props = { - style: { color: 'var(--code-normal-color)' }, + style: { color: 'var(--icon-color-normal-2)' }, }; if (loading) { return ; } + if (searchKey || database) { + return ( + { + setSearchKey(''); + onChangeInput(SearchTypeMap.DATABASE, ''); + setDatabase(null); + }} + /> + ); + } return ; }; return (
-
- {selectProject - ? formatMessage( - { - id: 'src.page.Workspace.SideBar.ResourceTree.DatabaseSearchModal.components.6D5791AB', - defaultMessage: '当前项目: ${selectProject?.name}', - }, - { selectProjectName: selectProject?.name }, - ) - : formatMessage( - { - id: 'src.page.Workspace.SideBar.ResourceTree.DatabaseSearchModal.components.987D5B8A', - defaultMessage: '当前数据源: ${selectDatasource?.name}', - }, - { selectDatasourceName: selectDatasource?.name }, - )} -
{getDataBase()} diff --git a/src/page/Workspace/SideBar/ResourceTree/DatabaseSearchModal/constant.ts b/src/page/Workspace/SideBar/ResourceTree/DatabaseSearchModal/constant.ts index c59e4f307..bf2c77d5c 100644 --- a/src/page/Workspace/SideBar/ResourceTree/DatabaseSearchModal/constant.ts +++ b/src/page/Workspace/SideBar/ResourceTree/DatabaseSearchModal/constant.ts @@ -16,6 +16,7 @@ import { TopTab as PackageTopTab } from '@/page/Workspace/components/PackagePage import { DbObjectTypeTextMap } from '@/constant/label'; const mysqlObjectType = [ + DbObjectType.database, DbObjectType.table, DbObjectType.column, DbObjectType.function, @@ -24,6 +25,7 @@ const mysqlObjectType = [ ]; const oracleObjectType = [ + DbObjectType.database, DbObjectType.table, DbObjectType.column, DbObjectType.function, @@ -61,6 +63,9 @@ export const DbObjectTypeMap = { defaultMessage: '全部', }), }, + [DbObjectType.database]: { + label: DbObjectTypeTextMap.DATABASE, + }, [DbObjectType.table]: { label: DbObjectTypeTextMap.TABLE, openPage: (object) => openTableViewPage, diff --git a/src/page/Workspace/SideBar/ResourceTree/DatabaseSearchModal/index.less b/src/page/Workspace/SideBar/ResourceTree/DatabaseSearchModal/index.less index 414654632..7b4ab34c4 100644 --- a/src/page/Workspace/SideBar/ResourceTree/DatabaseSearchModal/index.less +++ b/src/page/Workspace/SideBar/ResourceTree/DatabaseSearchModal/index.less @@ -6,7 +6,7 @@ border-radius: 6px; .ant-modal-header { padding: 8px 12px; - border-radius: 8px 8px; + border-radius: 8px 8px 0 0; .ant-modal-title { font-size: 12px; line-height: 20px; @@ -17,14 +17,11 @@ } } } - .listTitle { + .searchInfo { color: var(--text-color-secondary); - height: 18px; - font-weight: 400; - font-size: 20px; - line-height: 18px; - transform: scale(0.5); - transform-origin: left; + font-size: 12px; + line-height: 20px; + padding: 4px 12px; } .title { color: rgba(0, 0, 0, 0.65); @@ -47,10 +44,12 @@ } .selectTitle { padding-left: 4px; - max-width: 280px; + max-width: 180px; text-overflow: ellipsis; text-wrap: nowrap; overflow: hidden; + display: inline-block; + vertical-align: top; } .selectIcon { font-size: 8px; @@ -121,10 +120,11 @@ .objectTypeBox { .objectTypeTitle { font-weight: 500; - padding: 6px 12px; + padding: 0px 12px 8px 12px; + line-height: 20px; } .objectTypeItem { - padding: 6px 12px; + padding: 4px 12px; display: flex; justify-content: space-between; flex-wrap: nowrap; @@ -135,7 +135,8 @@ } } .objectTypeItemMore { - padding: 6px 12px; + padding: 0px 12px; + height: 20px; } } .objectItem { diff --git a/src/page/Workspace/SideBar/ResourceTree/DatabaseSearchModal/index.tsx b/src/page/Workspace/SideBar/ResourceTree/DatabaseSearchModal/index.tsx index daaf48683..cadf5756d 100644 --- a/src/page/Workspace/SideBar/ResourceTree/DatabaseSearchModal/index.tsx +++ b/src/page/Workspace/SideBar/ResourceTree/DatabaseSearchModal/index.tsx @@ -11,6 +11,7 @@ import ObjectList from './components/ObjectList'; import DatabaseList from './components/DatabaseList'; import { IDatabase, IDatabaseObject } from '@/d.ts/database'; import classNames from 'classnames'; +import { DbObjectType } from '@/d.ts'; interface IProps { modalStore?: ModalStore; @@ -19,12 +20,9 @@ interface IProps { const DatabaseSearchModal = ({ modalStore }: IProps) => { const [database, setDatabase] = useState(); const [searchKey, setSearchKey] = useState(''); - const [isSelectDatabase, setSelectDatabaseState] = useState(false); - const [isSelectAll, setSelectAllState] = useState(true); const [objectlist, setObjectlist] = useState(); const [activeKey, setActiveKey] = useState(SEARCH_OBJECT_FROM_ALL_DATABASE); const [loading, setLoading] = useState(false); - const { selectDatasourceId, selectProjectId, databaseList } = useContext(ResourceTreeContext); const handleCancel = () => { @@ -40,13 +38,13 @@ const DatabaseSearchModal = ({ modalStore }: IProps) => { }, [database]); const getType = () => { - if (isSelectDatabase && !database) return 'SCHEMA'; + if (activeKey === DbObjectType.database) return 'SCHEMA'; if (activeKey === SEARCH_OBJECT_FROM_ALL_DATABASE) return null; return activeKey; }; const getObjectListData = async (value) => { - const databaseIds = isSelectAll ? null : database?.id; + const databaseIds = database?.id; const type = getType(); setLoading(true); const res = await getDatabaseObject( @@ -65,30 +63,24 @@ const DatabaseSearchModal = ({ modalStore }: IProps) => { getObjectListData(value); switch (type) { case SearchTypeMap.OBJECT: { - setSelectDatabaseState(false); + // setSelectDatabaseState(false); break; } case SearchTypeMap.DATABASE: { - setSelectDatabaseState(true); + // setSelectDatabaseState(true); } } }; const contentRender = () => { - if (isSelectAll && !searchKey) { - return null; - } - if (isSelectDatabase) { + if (!searchKey) { return ( @@ -97,9 +89,11 @@ const DatabaseSearchModal = ({ modalStore }: IProps) => { return ( @@ -115,12 +109,10 @@ const DatabaseSearchModal = ({ modalStore }: IProps) => { database={database} visible={modalStore.databaseSearchModalVisible && modalStore.canDatabaseSearchModalOpen} onChangeInput={onChangeInput} - isSelectDatabase={isSelectDatabase} searchKey={searchKey} - isSelectAll={isSelectAll} - setSelectAllState={setSelectAllState} loading={loading} setDatabase={setDatabase} + setSearchKey={setSearchKey} /> } open={modalStore.databaseSearchModalVisible && modalStore.canDatabaseSearchModalOpen} @@ -129,7 +121,7 @@ const DatabaseSearchModal = ({ modalStore }: IProps) => { maskClosable={true} closable={false} className={classNames(styles.databaseSearchModal, { - [styles.withPanel]: !isSelectAll || searchKey, + [styles.withPanel]: searchKey, })} destroyOnClose={true} footer={null} diff --git a/src/style/theme/dark.less b/src/style/theme/dark.less index f14835c50..a56fbf1a2 100644 --- a/src/style/theme/dark.less +++ b/src/style/theme/dark.less @@ -77,6 +77,7 @@ --text-color-link: var(--brand-blue6-color); --text-color-error: var(--function-red6-color); --icon-color-normal: rgba(255, 255, 255, 0.65); + --icon-color-normal-2: var(--neutral-grey6-color); --icon-color-focus: var(--brand-blue6-color); --icon-color-disable: rgba(255, 255, 255, 0.3); --icon-color-1: var(--icon-blue-color); diff --git a/src/style/theme/white.less b/src/style/theme/white.less index e4eefadcf..1633ce858 100644 --- a/src/style/theme/white.less +++ b/src/style/theme/white.less @@ -85,6 +85,7 @@ --text-color-link: var(--brand-blue6-color); --text-color-error: var(--function-red6-color); --icon-color-normal: rgba(0, 0, 0, 0.65); + --icon-color-normal-2: var(--neutral-black45-color); --icon-color-focus: var(--brand-blue6-color); --icon-color-disable: rgba(0, 0, 0, 0.25); --icon-color-1: var(--icon-blue-color); From 4ed588efdfda392a376b7837326db6ec9e83bb6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=95=85=E6=99=9A?= Date: Tue, 9 Jul 2024 10:02:32 +0800 Subject: [PATCH 2/2] PullRequest: 466 fix/dev-4.3.1-2840 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Merge branch 'fix/dev-4.3.1-2840 of git@code.alipay.com:oceanbase/oceanbase-developer-center.git into dev-4.3.1 https://code.alipay.com/oceanbase/oceanbase-developer-center/pull_requests/466 Signed-off-by: 晓康 * Fixes oceanbase/odc#2804 * Fixes oceanbase/odc#2840 --- src/component/Toolbar/index.tsx | 2 +- .../components/ObjectList.tsx | 52 ++++++++++++------ .../components/DDLResultSet/index.tsx | 55 ++++++++++--------- .../components/SQLResultSet/index.tsx | 2 +- src/store/sessionManager/session.ts | 10 +--- src/util/versionUtils.ts | 2 +- 6 files changed, 67 insertions(+), 56 deletions(-) diff --git a/src/component/Toolbar/index.tsx b/src/component/Toolbar/index.tsx index aa3f188af..0747c9abf 100644 --- a/src/component/Toolbar/index.tsx +++ b/src/component/Toolbar/index.tsx @@ -150,7 +150,7 @@ function TButton({ if (tip) { return ( - + {content} diff --git a/src/page/Workspace/SideBar/ResourceTree/DatabaseSearchModal/components/ObjectList.tsx b/src/page/Workspace/SideBar/ResourceTree/DatabaseSearchModal/components/ObjectList.tsx index dafb20d0e..e18d3734c 100644 --- a/src/page/Workspace/SideBar/ResourceTree/DatabaseSearchModal/components/ObjectList.tsx +++ b/src/page/Workspace/SideBar/ResourceTree/DatabaseSearchModal/components/ObjectList.tsx @@ -211,7 +211,7 @@ const ObjectList = ({
{i.key === DbObjectType.database ? selectDbBtn(object) - : permissionBtn(object)} + : permissionBtn(object, i.key)}
); } @@ -232,14 +232,16 @@ const ObjectList = ({ ); }; - const applyTablePermission = (e, object) => { + const applyTablePermission = (e, object, type) => { e.stopPropagation(); + const dbObj = type === DbObjectType.table ? object : object?.dbObject; const params = { - projectId: object?.database?.project?.id, - databaseId: object?.database?.id, - tableName: object?.name, - tableId: object?.id, + projectId: dbObj?.database?.project?.id, + databaseId: dbObj?.database?.id, + tableName: dbObj?.name, + tableId: dbObj?.id, }; + // debugger modalStore.changeApplyTablePermissionModal(true, { ...params, }); @@ -253,28 +255,42 @@ const ObjectList = ({ ); }; - const permissionBtn = (object) => { + const permissionBtn = (object, type: DbObjectType) => { if (activeDatabase?.id !== object.id) return; if (hasPermission(object)) return; + const isTableColumn = + object?.dbObject?.type === DbObjectType.table || object?.type === DbObjectType.table; + if ([DbObjectType.column, DbObjectType.table].includes(type) && isTableColumn) { + return ( + + ); + } return ( ); }; - const applyDbPermission = (e, db: IDatabase) => { + const applyDbPermission = (e, db) => { e.stopPropagation(); + const dbObj = db?.dbObject?.database || db?.database || db; modalStore.changeApplyDatabasePermissionModal(true, { - projectId: db?.project?.id, - databaseId: db?.id, + projectId: dbObj?.project?.id, + databaseId: dbObj?.id, }); modalStore.changeDatabaseSearchModalVisible(false); }; @@ -375,7 +391,9 @@ const ObjectList = ({ {getSubTitle(object, type)}
- {isDatabasetab ? selectDbBtn(object) : permissionBtn(object)} + {isDatabasetab + ? selectDbBtn(object) + : permissionBtn(object, currentObjectList.key)}
); })} diff --git a/src/page/Workspace/components/DDLResultSet/index.tsx b/src/page/Workspace/components/DDLResultSet/index.tsx index a39c231b5..3b20a88f9 100644 --- a/src/page/Workspace/components/DDLResultSet/index.tsx +++ b/src/page/Workspace/components/DDLResultSet/index.tsx @@ -90,6 +90,7 @@ import useColumns, { isNumberType } from './hooks/useColumns'; import ResultContext from './ResultContext'; import StatusBar from './StatusBar'; import { copyToSQL, getColumnNameByColumnKey } from './util'; +import { OBCompare, ODC_TRACE_SUPPORT_VERSION } from '@/util/versionUtils'; // @ts-ignore const ToolbarButton = Toolbar.Button; @@ -676,7 +677,7 @@ const DDLResultSet: React.FC = function (props) { const executeGuideTipContent = () => { if (guideCacheStore?.[guideCacheStore.cacheEnum.executePlan]) return null; return ( -
+
{formatMessage({ id: 'src.page.Workspace.components.DDLResultSet.E32AB474', @@ -749,32 +750,32 @@ const DDLResultSet: React.FC = function (props) { /> ))} - - {showTrace ? ( - } - onClick={() => { - onShowTrace?.(); - }} - /> - ) : ( - } - onClick={() => { - onShowTrace?.(); - }} - /> - )} + {showTrace && + (isString(obVersion) && OBCompare(obVersion, ODC_TRACE_SUPPORT_VERSION, '>=') ? ( + } + onClick={() => { + onShowTrace?.(); + }} + /> + ) : ( + } + onClick={() => { + onShowTrace?.(); + }} + /> + ))} ); }; diff --git a/src/page/Workspace/components/SQLResultSet/index.tsx b/src/page/Workspace/components/SQLResultSet/index.tsx index 7d559f197..78692b85a 100644 --- a/src/page/Workspace/components/SQLResultSet/index.tsx +++ b/src/page/Workspace/components/SQLResultSet/index.tsx @@ -338,7 +338,7 @@ const SQLResultSet: React.FC = function (props) { ='); - this.supportFeature.enableSQLTrace = - this.supportFeature.enableSQLTrace && - isString(obVersion) && - OBCompare(obVersion, ODC_TRACE_SUPPORT_VERSION, '>='); }); } diff --git a/src/util/versionUtils.ts b/src/util/versionUtils.ts index 83eb5c2e4..c477eb4fd 100644 --- a/src/util/versionUtils.ts +++ b/src/util/versionUtils.ts @@ -16,7 +16,7 @@ import compareVersions, { compare } from 'compare-versions'; -export const ODC_TRACE_SUPPORT_VERSION = '4.2.0'; +export const ODC_TRACE_SUPPORT_VERSION = '4.1.0'; export const ODC_PROFILE_SUPPORT_VERSION = '4.2.4'; export const ODC_VERSION_SEP = '.';