Skip to content

Commit

Permalink
PullRequest: 487 fix/dev-4.3.1-3042
Browse files Browse the repository at this point in the history
Merge branch 'fix/dev-4.3.1-3042 of [email protected]:oceanbase/oceanbase-developer-center.git into dev-4.3.1

https://code.alipay.com/oceanbase/oceanbase-developer-center/pull_requests/487


Signed-off-by: 晓康 <[email protected]>


* Fixes oceanbase/odc#3042
* Fixes oceanbase/odc#2920
* Fixes oceanbase/odc#2956
* Fixes oceanbase/odc#3025
  • Loading branch information
yezaoshu committed Jul 30, 2024
1 parent 78650f9 commit eef4648
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 36 deletions.
9 changes: 9 additions & 0 deletions src/common/network/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@ export async function getProject(id: number): Promise<IProject> {
return res?.data;
}

export async function getProjectHistoryInfo(id: number): Promise<IProject> {
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<IProject> {
const res = await request.put(`/api/v2/collaboration/projects/${id}`, {
data: project,
Expand Down
6 changes: 3 additions & 3 deletions src/common/network/sql/preHandle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@ 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: {
invalid: true,
executeSuccess: false,
executeResult: [],
violatedRules: [],
unauthorizedDatabases,
unauthorizedDBResources,
unauthorizedSql: (params as IExecuteSQLParams)?.sql || (params as string),
},
lintResultSet: [],
Expand Down
17 changes: 5 additions & 12 deletions src/component/ProfileFlow/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand All @@ -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 (
<div className={styles.profileFlow}>
<CustomDetailBox
Expand All @@ -93,7 +87,6 @@ function Flow(props: Iprops) {
edges={edges}
onNodesChange={onNodesChange}
onEdgesChange={onEdgesChange}
onConnect={onConnect}
// @ts-ignore
edgeTypes={edgeTypes}
nodeTypes={nodeTypes}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ interface IProps {
flowId: number;
}
const MultipleSQLCheckNode: React.FC<IProps> = 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<boolean>(false);
Expand All @@ -26,7 +26,7 @@ const MultipleSQLCheckNode: React.FC<IProps> = 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);
Expand Down Expand Up @@ -152,7 +152,7 @@ const MultipleSQLCheckNode: React.FC<IProps> = function ({ node, flowId }) {
{
formatMessage(
{ id: 'src.component.Task.component.CommonDetailModal.Nodes.90FF76EB' },
{ unauthorizedDatabasesLength: unauthorizedDatabases?.length },
{ unauthorizedDatabasesLength: unauthorizedDBResources?.length },
) /*`存在${unauthorizedDatabases?.length}个问题`*/
}

Expand Down Expand Up @@ -222,7 +222,7 @@ const MultipleSQLCheckNode: React.FC<IProps> = function ({ node, flowId }) {
</Drawer>
<DBPermissionTableDrawer
visible={permissionResultVisible}
dataSource={unauthorizedDatabases}
dataSource={unauthorizedDBResources}
onClose={() => {
setPermissionResultVisible(false);
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ interface IProps {
flowId: number;
}
const SQLCheckNode: React.FC<IProps> = 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<ISQLLintReuslt[]>([]);
// 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) {
Expand Down Expand Up @@ -151,7 +151,7 @@ const SQLCheckNode: React.FC<IProps> = function ({ node, flowId }) {
{
formatMessage(
{ id: 'src.component.Task.component.CommonDetailModal.Nodes.90FF76EB' },
{ unauthorizedDatabasesLength: unauthorizedDatabases?.length },
{ unauthorizedDatabasesLength: unauthorizedDBResources?.length },
) /*`存在${unauthorizedDatabases?.length}个问题`*/
}
<a
Expand Down Expand Up @@ -183,7 +183,7 @@ const SQLCheckNode: React.FC<IProps> = function ({ node, flowId }) {
<LintDrawer visible={visible} closePage={() => setVisible(false)} data={data} />
<DBPermissionTableDrawer
visible={permissionResultVisible}
dataSource={unauthorizedDatabases}
dataSource={unauthorizedDBResources}
onClose={() => {
setPermissionResultVisible(false);
}}
Expand Down
7 changes: 1 addition & 6 deletions src/component/Task/helper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion src/d.ts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2919,7 +2919,7 @@ export interface ITaskFlowNode {
comment: string;
deadlineTime: number;
issueCount: number;
unauthorizedDatabases: IUnauthorizedDBResources[];
unauthorizedDBResources: IUnauthorizedDBResources[];
id?: number;
candidates: {
id: number;
Expand Down Expand Up @@ -3273,6 +3273,7 @@ export enum ODCErrorsCode {
SysTenantAccountNotSet = 'SysTenantAccountNotSet',
SysTenantAccountInvalid = 'SysTenantAccountInvalid',
PermissionChanged = 'PermissionChanged',
AccessDenied = 'AccessDenied',
}

export enum ConnectType {
Expand Down
5 changes: 3 additions & 2 deletions src/page/Datasource/Info/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,9 @@ const Info: React.FC<IProps> = ({ id, datasource }) => {
//最近一次同步时间
dataIndex: 'lastSyncTime',
width: 200,
render(v) {
return getLocalFormatDateTime(v);
render(v, record) {
const time = record?.lastSyncTime || record?.objectLastSyncTime;
return getLocalFormatDateTime(time);
},
},
{
Expand Down
5 changes: 3 additions & 2 deletions src/page/Project/Database/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,9 @@ const Database: React.FC<IProps> = ({ id, modalStore }) => {
//上一次同步时间
dataIndex: 'lastSyncTime',
width: 170,
render(v) {
return getLocalFormatDateTime(v);
render(v, record) {
const time = record?.lastSyncTime || record?.objectLastSyncTime;
return getLocalFormatDateTime(time);
},
},
{
Expand Down
4 changes: 2 additions & 2 deletions src/service/projectHistory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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');
}
Expand Down

0 comments on commit eef4648

Please sign in to comment.