From 30b46922730f35094b545fdbfb7e2f510153c73a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=95=85=E6=99=9A?= Date: Mon, 29 Jul 2024 15:52:12 +0800 Subject: [PATCH] PullRequest: 485 fix/dev-4.3.1-table-roles MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Merge branch 'fix/dev-4.3.1-table-roles 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/485 Signed-off-by: 晓康 * fix: change database select permission function to adapt to table roles * fix: use 'type' field to control btn when sql execute error --- src/component/Task/helper.tsx | 12 ++++++++---- src/d.ts/table.ts | 6 ++++++ .../components/SQLResultSet/DBPermissionTable.tsx | 13 ++++++++++--- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src/component/Task/helper.tsx b/src/component/Task/helper.tsx index a2161b6e6..37f0b5952 100644 --- a/src/component/Task/helper.tsx +++ b/src/component/Task/helper.tsx @@ -27,14 +27,18 @@ export { TaskTypeMap } from '@/component/Task/component/TaskTable'; export const ENABLED_SYS_FROM_ITEM = false; export const hasPermission = (taskType: TaskType, permissions: DatabasePermissionType[]) => { + /* 如果有ACCESS(没有库权限, 只有库下的某个表权限), 则先全部粗颗粒放开 */ + if (permissions.includes(DatabasePermissionType.ACCESS)) { + return permissions?.length > 0; // 考虑有表没有库权限的情况 + } let _permissions = []; switch (taskType) { case TaskType.EXPORT: - return permissions?.length > 0; // 考虑有表没有库权限的情况 + _permissions = [DatabasePermissionType.EXPORT]; + break; case TaskType.EXPORT_RESULT_SET: - return permissions?.length > 0; // 考虑有表没有库权限的情况 - case TaskType.ASYNC: - return permissions?.length > 0; // 考虑有表没有库权限的情况 + _permissions = [DatabasePermissionType.EXPORT, DatabasePermissionType.QUERY]; + break; default: _permissions = [DatabasePermissionType.CHANGE]; } diff --git a/src/d.ts/table.ts b/src/d.ts/table.ts index 0ee76c084..fd9708e1f 100644 --- a/src/d.ts/table.ts +++ b/src/d.ts/table.ts @@ -210,6 +210,11 @@ export enum TablePermissionType { EXPORT = 'EXPORT', } +export enum UnauthorizedPermissionTypeInSQLExecute { + ODC_TABLE = 'ODC_TABLE', + ODC_DATABASE = 'ODC_DATABASE', +} + export interface IUnauthorizedDBResources { unauthorizedPermissionTypes: (DatabasePermissionType & TablePermissionType)[]; dataSourceId: number; @@ -220,6 +225,7 @@ export interface IUnauthorizedDBResources { tableName: string; tableId: number; applicable: boolean; + type: UnauthorizedPermissionTypeInSQLExecute; } export interface IColumnStoreServerType { allColumns?: boolean; diff --git a/src/page/Workspace/components/SQLResultSet/DBPermissionTable.tsx b/src/page/Workspace/components/SQLResultSet/DBPermissionTable.tsx index 043118f24..86d863ff7 100644 --- a/src/page/Workspace/components/SQLResultSet/DBPermissionTable.tsx +++ b/src/page/Workspace/components/SQLResultSet/DBPermissionTable.tsx @@ -20,7 +20,11 @@ import { CloseCircleFilled } from '@ant-design/icons'; import { ModalStore } from '@/store/modal'; import DisplayTable from '@/component/DisplayTable'; import { DatabasePermissionType } from '@/d.ts/database'; -import { IUnauthorizedDBResources, TablePermissionType } from '@/d.ts/table'; +import { + IUnauthorizedDBResources, + TablePermissionType, + UnauthorizedPermissionTypeInSQLExecute, +} from '@/d.ts/table'; import Action from '@/component/Action'; import { permissionOptionsMap } from '@/component/Task/ApplyDatabasePermission'; import MultiLineOverflowText from '@/component/MultiLineOverflowText'; @@ -76,6 +80,9 @@ const getColumns = ( ellipsis: true, render: (action, _) => { const dbDisabled = !_.applicable; + const isTablePermissionError = _.type === UnauthorizedPermissionTypeInSQLExecute.ODC_TABLE; + const isDatabasePermissionError = + _.type === UnauthorizedPermissionTypeInSQLExecute.ODC_DATABASE; let dbTooltip = null, tableTooltip = null; if (dbDisabled) { @@ -99,7 +106,7 @@ const getColumns = ( return ( { @@ -114,7 +121,7 @@ const getColumns = ( { { applyTableTask?.(