diff --git a/src/common/network/project.ts b/src/common/network/project.ts index fcf2d7274..df265c394 100644 --- a/src/common/network/project.ts +++ b/src/common/network/project.ts @@ -51,6 +51,15 @@ export async function getProject(id: number): Promise { return res?.data; } +export async function getProjectHistoryInfo(id: number): Promise { + const res = await request.get(`/api/v2/collaboration/projects/${id}`, { + params: { + ignoreError: true, + }, + }); + return res?.data; +} + export async function updateProject(id: number, project: IProject): Promise { const res = await request.put(`/api/v2/collaboration/projects/${id}`, { data: project, diff --git a/src/common/network/sql/preHandle.tsx b/src/common/network/sql/preHandle.tsx index d93b8f6e1..773a1e67a 100644 --- a/src/common/network/sql/preHandle.tsx +++ b/src/common/network/sql/preHandle.tsx @@ -28,9 +28,9 @@ export function executeSQLPreHandle( } return pre; }, []); - const unauthorizedDatabases = taskInfo?.unauthorizedDBResources; + const unauthorizedDBResources = taskInfo?.unauthorizedDBResources; const violatedRules = rootViolatedRules?.concat(taskInfo?.sqls); - if (unauthorizedDatabases?.length) { + if (unauthorizedDBResources?.length) { // 无权限库 return { data: { @@ -38,7 +38,7 @@ export function executeSQLPreHandle( executeSuccess: false, executeResult: [], violatedRules: [], - unauthorizedDatabases, + unauthorizedDBResources, unauthorizedSql: (params as IExecuteSQLParams)?.sql || (params as string), }, lintResultSet: [], diff --git a/src/component/ProfileFlow/index.tsx b/src/component/ProfileFlow/index.tsx index 6323d7cd0..a44f8895c 100644 --- a/src/component/ProfileFlow/index.tsx +++ b/src/component/ProfileFlow/index.tsx @@ -47,9 +47,11 @@ function Flow(props: Iprops) { // 初始化数据 useEffect(() => { - setNodes(initialNodes); - setEdges(initialEdges); - }, [JSON.stringify(dataSource)]); + setTimeout(() => { + setNodes(initialNodes); + setEdges(initialEdges); + }, 300); + }, [JSON.stringify(initialNodes)]); // 视图位置初始化 useEffect(() => { @@ -61,14 +63,6 @@ function Flow(props: Iprops) { handleSelectNode(setNodes, selectedNode?.id); }, [JSON.stringify(selectedNode?.id)]); - const onConnect = useCallback( - (connection) => { - const edge = { ...connection, type: 'CustomEdge' }; - setEdges((eds) => addEdge(edge, eds)); - }, - [setEdges], - ); - return (
= function ({ node, flowId }) { - const { status, nodeType, issueCount, unauthorizedDatabases, id, preCheckOverLimit } = node; + const { status, nodeType, issueCount, unauthorizedDBResources, id, preCheckOverLimit } = node; const [isLoading, setIsLoading] = useState(false); const [visible, setVisible] = useState(false); const [permissionResultVisible, setPermissionResultVisible] = useState(false); @@ -26,7 +26,7 @@ const MultipleSQLCheckNode: React.FC = function ({ node, flowId }) { }[] >([]); const showCount = typeof issueCount === 'number'; - const showUnauthorized = unauthorizedDatabases?.length > 0; + const showUnauthorized = unauthorizedDBResources?.length > 0; const showReslut = showCount || showUnauthorized || preCheckOverLimit; async function viewLintResult() { setVisible(true); @@ -152,7 +152,7 @@ const MultipleSQLCheckNode: React.FC = function ({ node, flowId }) { { formatMessage( { id: 'src.component.Task.component.CommonDetailModal.Nodes.90FF76EB' }, - { unauthorizedDatabasesLength: unauthorizedDatabases?.length }, + { unauthorizedDatabasesLength: unauthorizedDBResources?.length }, ) /*`存在${unauthorizedDatabases?.length}个问题`*/ } @@ -222,7 +222,7 @@ const MultipleSQLCheckNode: React.FC = function ({ node, flowId }) { { setPermissionResultVisible(false); }} diff --git a/src/component/Task/component/CommonDetailModal/Nodes/SQLCheckNode.tsx b/src/component/Task/component/CommonDetailModal/Nodes/SQLCheckNode.tsx index cd6ee92d4..00559be45 100644 --- a/src/component/Task/component/CommonDetailModal/Nodes/SQLCheckNode.tsx +++ b/src/component/Task/component/CommonDetailModal/Nodes/SQLCheckNode.tsx @@ -30,14 +30,14 @@ interface IProps { flowId: number; } const SQLCheckNode: React.FC = function ({ node, flowId }) { - const { status, nodeType, issueCount, unauthorizedDatabases, id, preCheckOverLimit } = node; + const { status, nodeType, issueCount, unauthorizedDBResources, id, preCheckOverLimit } = node; const [isLoading, setIsLoading] = useState(false); const [visible, setVisible] = useState(false); const [permissionResultVisible, setPermissionResultVisible] = useState(false); const [data, setData] = useState([]); // const [multipleData, setMultipleData] = useState const showCount = typeof issueCount === 'number'; - const showUnauthorized = unauthorizedDatabases?.length > 0; + const showUnauthorized = unauthorizedDBResources?.length > 0; const showReslut = showCount || showUnauthorized || preCheckOverLimit; async function viewLintResult() { if (isLoading) { @@ -151,7 +151,7 @@ const SQLCheckNode: React.FC = function ({ node, flowId }) { { formatMessage( { id: 'src.component.Task.component.CommonDetailModal.Nodes.90FF76EB' }, - { unauthorizedDatabasesLength: unauthorizedDatabases?.length }, + { unauthorizedDatabasesLength: unauthorizedDBResources?.length }, ) /*`存在${unauthorizedDatabases?.length}个问题`*/ } = function ({ node, flowId }) { setVisible(false)} data={data} /> { setPermissionResultVisible(false); }} diff --git a/src/component/Task/helper.tsx b/src/component/Task/helper.tsx index 37f0b5952..098e804df 100644 --- a/src/component/Task/helper.tsx +++ b/src/component/Task/helper.tsx @@ -27,15 +27,10 @@ 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: - _permissions = [DatabasePermissionType.EXPORT]; - break; + return permissions?.length > 0; // 考虑有表没有库权限的情况 case TaskType.EXPORT_RESULT_SET: _permissions = [DatabasePermissionType.EXPORT, DatabasePermissionType.QUERY]; break; diff --git a/src/d.ts/index.ts b/src/d.ts/index.ts index f27534a7f..dfb23e150 100644 --- a/src/d.ts/index.ts +++ b/src/d.ts/index.ts @@ -2919,7 +2919,7 @@ export interface ITaskFlowNode { comment: string; deadlineTime: number; issueCount: number; - unauthorizedDatabases: IUnauthorizedDBResources[]; + unauthorizedDBResources: IUnauthorizedDBResources[]; id?: number; candidates: { id: number; @@ -3273,6 +3273,7 @@ export enum ODCErrorsCode { SysTenantAccountNotSet = 'SysTenantAccountNotSet', SysTenantAccountInvalid = 'SysTenantAccountInvalid', PermissionChanged = 'PermissionChanged', + AccessDenied = 'AccessDenied', } export enum ConnectType { diff --git a/src/page/Datasource/Info/index.tsx b/src/page/Datasource/Info/index.tsx index ba368473b..38aad73aa 100644 --- a/src/page/Datasource/Info/index.tsx +++ b/src/page/Datasource/Info/index.tsx @@ -289,8 +289,9 @@ const Info: React.FC = ({ id, datasource }) => { //最近一次同步时间 dataIndex: 'lastSyncTime', width: 200, - render(v) { - return getLocalFormatDateTime(v); + render(v, record) { + const time = record?.lastSyncTime || record?.objectLastSyncTime; + return getLocalFormatDateTime(time); }, }, { diff --git a/src/page/Project/Database/index.tsx b/src/page/Project/Database/index.tsx index e07f924b3..f1513a82b 100644 --- a/src/page/Project/Database/index.tsx +++ b/src/page/Project/Database/index.tsx @@ -354,8 +354,9 @@ const Database: React.FC = ({ id, modalStore }) => { //上一次同步时间 dataIndex: 'lastSyncTime', width: 170, - render(v) { - return getLocalFormatDateTime(v); + render(v, record) { + const time = record?.lastSyncTime || record?.objectLastSyncTime; + return getLocalFormatDateTime(time); }, }, { diff --git a/src/service/projectHistory.ts b/src/service/projectHistory.ts index e5c2492ac..ff6b931d7 100644 --- a/src/service/projectHistory.ts +++ b/src/service/projectHistory.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { getProject } from '@/common/network/project'; +import { getProjectHistoryInfo } from '@/common/network/project'; import login from '@/store/login'; import logger from '@/util/logger'; import { safeParseJson } from '@/util/utils'; @@ -54,7 +54,7 @@ export async function toDefaultProjectPage() { if (!projectId) { history.push('/project'); } else { - const project = await getProject(projectId); + const project = await getProjectHistoryInfo(projectId); const isProjectAvailable = project && !project?.archived; isProjectAvailable ? history.push(`/project/${projectId}/database`) : history.push('/project'); }