Skip to content

Commit

Permalink
PullRequest: 529 fix/dev-4.3.2-3217
Browse files Browse the repository at this point in the history
Merge branch 'fix/dev-4.3.2-3216 of git@code.alipay.com:oceanbase/oceanbase-developer-center.git into dev-4.3.2

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


Signed-off-by: 晓康 <xxk268858@oceanbase.com>


* Fixes oceanbase/odc#3217
* Fixes oceanbase/odc#3346
* Fixes oceanbase/odc#3349
* Fixes oceanbase/odc#3217
* Fixes oceanbase/odc#3350
* Fixes oceanbase/odc#3359
* Fixes oceanbase/odc#3370
* Fixes oceanbase/odc#3363
  • Loading branch information
yezaoshu committed Sep 13, 2024
1 parent 66bd0a2 commit 6c75e27
Show file tree
Hide file tree
Showing 13 changed files with 99 additions and 36 deletions.
1 change: 1 addition & 0 deletions src/common/datasource/mysql/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ const items: Record<ConnectType.MYSQL, IDataSourceModeConfig> = {
TaskType.EXPORT_RESULT_SET,
TaskType.STRUCTURE_COMPARISON,
TaskType.MULTIPLE_ASYNC,
TaskType.LOGICAL_DATABASE_CHANGE,
],
obclient: true,
recycleBin: false,
Expand Down
15 changes: 13 additions & 2 deletions src/common/datasource/oceanbase/oboracle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,12 @@ const items: Record<ConnectType.CLOUD_OB_ORACLE | ConnectType.OB_ORACLE, IDataSo
},
features: {
task: Object.values(TaskType).filter(
(type) => ![TaskType.SHADOW, TaskType.ONLINE_SCHEMA_CHANGE].includes(type),
(type) =>
![
TaskType.SHADOW,
TaskType.ONLINE_SCHEMA_CHANGE,
TaskType.LOGICAL_DATABASE_CHANGE,
].includes(type),
),
obclient: true,
recycleBin: true,
Expand Down Expand Up @@ -104,7 +109,13 @@ const items: Record<ConnectType.CLOUD_OB_ORACLE | ConnectType.OB_ORACLE, IDataSo
},
features: {
task: Object.values(TaskType).filter(
(type) => ![TaskType.SHADOW, TaskType.DATA_ARCHIVE, TaskType.DATA_DELETE].includes(type),
(type) =>
![
TaskType.SHADOW,
TaskType.DATA_ARCHIVE,
TaskType.DATA_DELETE,
TaskType.LOGICAL_DATABASE_CHANGE,
].includes(type),
),
obclient: true,
recycleBin: true,
Expand Down
4 changes: 2 additions & 2 deletions src/common/network/logicalDatabase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export async function getLogicalTableDetail(
export async function previewLogicalTableTopologies(
logicalDatabaseId: number,
expression: string,
): Promise<ITopology[] | false> {
): Promise<ITopology[] | string> {
const res = await request.post(
`/api/v2/connect/logicaldatabase/logicalDatabases/${logicalDatabaseId}/previewLogicalTableTopologies?expression=${encodeURIComponent(
expression,
Expand All @@ -109,7 +109,7 @@ export async function previewLogicalTableTopologies(
PreviewLogicalTableTopologiesErrorEnum.LogicalTableExpressionRangeStartGreaterThanEnd,
].includes(res.errCode)
) {
return false;
return res?.errMsg;
}
return res?.data?.contents;
}
Expand Down
6 changes: 5 additions & 1 deletion src/component/ScriptPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,11 @@ export default class ScriptPage extends PureComponent<IProps> {
<Content style={{ position: 'relative' }}>
{toolbar && <EditorToolBar {...toolbar} ctx={ctx} />}
{showSessionSelect && (
<SessionSelect dialectTypes={dialectTypes} readonly={sessionSelectReadonly} />
<SessionSelect
dialectTypes={dialectTypes}
readonly={sessionSelectReadonly}
isIncludeLogicalDb={false}
/>
)}

{isShowDebugStackBar ? (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import {
Radio,
Space,
Tooltip,
message,
} from 'antd';
import { inject, observer } from 'mobx-react';
import moment from 'moment';
Expand Down Expand Up @@ -172,6 +173,7 @@ const CreateModal: React.FC<IProps> = (props) => {
await createTask(data);
handleCancel(false);
setConfirmLoading(false);
message.success('创建成功');
})
.catch((errorInfo) => {
console.error(JSON.stringify(errorInfo));
Expand Down
45 changes: 28 additions & 17 deletions src/component/Task/component/ActionBar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
} from '@/common/network/task';
import Action from '@/component/Action';
import { TaskTypeMap } from '@/component/Task/component/TaskTable';
import type { ICycleTaskRecord } from '@/d.ts';
import type { ICycleTaskRecord, ILogicalDatabaseAsyncTaskParams } from '@/d.ts';
import {
IApplyDatabasePermissionTaskParams,
IApplyTablePermissionTaskParams,
Expand Down Expand Up @@ -267,27 +267,32 @@ const ActionBar: React.FC<IProps> = inject(
id: task?.id,
type: 'RETRY',
});
break;
}
case TaskType.LOGICAL_DATABASE_CHANGE: {
modalStore.changeLogicialDatabaseModal(true, {
task: task,
});
return;
break;
}
case TaskType.DATA_DELETE: {
props.modalStore.changeDataClearModal(true, {
id: task?.id,
type: 'RETRY',
});
break;
}
}
};

const disableCycleTask = async () => {
const {
database: { id: databaseId },
id,
} = task;
let databaseId;
if (task.database) {
databaseId = task.database?.id;
} else {
databaseId = (task as ICycleTaskRecord<ILogicalDatabaseAsyncTaskParams>).jobParameters
?.databaseId;
}
Modal.confirm({
title: formatMessage(
{
Expand Down Expand Up @@ -332,7 +337,7 @@ const ActionBar: React.FC<IProps> = inject(
databaseId,
taskType: TaskType.ALTER_SCHEDULE,
parameters: {
taskId: id,
taskId: task.id,
operationType: 'PAUSE',
},
});
Expand All @@ -342,10 +347,13 @@ const ActionBar: React.FC<IProps> = inject(
};

const enableCycleTask = async () => {
const {
database: { id: databaseId },
id,
} = task;
let databaseId;
if (task.database) {
databaseId = task.database?.id;
} else {
databaseId = (task as ICycleTaskRecord<ILogicalDatabaseAsyncTaskParams>).jobParameters
?.databaseId;
}
Modal.confirm({
title: formatMessage({
id: 'odc.TaskManagePage.component.TaskTools.AreYouSureYouWant.2',
Expand Down Expand Up @@ -386,7 +394,7 @@ const ActionBar: React.FC<IProps> = inject(
databaseId,
taskType: TaskType.ALTER_SCHEDULE,
parameters: {
taskId: id,
taskId: task?.id,
operationType: 'RESUME',
},
});
Expand All @@ -396,15 +404,18 @@ const ActionBar: React.FC<IProps> = inject(
};

const stopCycleTask = async () => {
const {
database: { id: databaseId },
id,
} = task;
let databaseId;
if (task.database) {
databaseId = task.database?.id;
} else {
databaseId = (task as ICycleTaskRecord<ILogicalDatabaseAsyncTaskParams>).jobParameters
?.databaseId;
}
await createTask({
databaseId,
taskType: TaskType.ALTER_SCHEDULE,
parameters: {
taskId: id,
taskId: task?.id,
operationType: 'TERMINATION',
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ const TaskExecuteRecord: React.FC<IProps> = (props) => {
onReload?.();
};

const handleLogicalDatabaseTaskSkip = async () => {
const handleLogicalDatabaseTaskSkip = async (detailId: number) => {
await stopPhysicalSqlExecute(flowList?.contents?.[0]?.id, detailId);
onReload?.();
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import {
import { useForm, useWatch } from 'antd/lib/form/Form';
import { DefaultOptionType } from 'antd/lib/select';
import React, { useEffect, useState } from 'react';
import { getDataSourceModeConfig } from '@/common/datasource';
import { TaskType } from '@/d.ts';

const ProjectDatabaseSelector: React.FC<{
width?: number | string;
Expand Down Expand Up @@ -153,6 +155,10 @@ const CreateLogicialDatabase: React.FC<{
if (cur.type === 'LOGICAL') {
return pre;
}
const config = getDataSourceModeConfig(cur?.dataSource?.type);
if (!config?.features?.task?.includes(TaskType.LOGICAL_DATABASE_CHANGE)) {
return pre;
}
const icon = getDataSourceStyleByConnectType(cur?.dataSource?.type);
pre.push({
label: (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,17 @@ import { ReactComponent as NewOpenSvg } from '@/svgr/newopen.svg';
import { isLogicalDatabase } from '@/util/database';
import { gotoSQLWorkspace } from '@/util/route';
import Icon, { ExclamationCircleFilled } from '@ant-design/icons';
import { Button, ConfigProvider, Descriptions, Drawer, Empty, message, Space, Tooltip } from 'antd';
import {
Button,
ConfigProvider,
Descriptions,
Drawer,
Empty,
message,
Space,
Tooltip,
Modal,
} from 'antd';
import React, { useEffect, useRef, useState } from 'react';

const getColumns = ({ logicalDatabaseId, reload }) => {
Expand Down Expand Up @@ -88,13 +98,17 @@ const getColumns = ({ logicalDatabaseId, reload }) => {
<Action.Link
key={'delete'}
onClick={async () => {
const successful = await deleteLogicalTable(logicalDatabaseId, record.id);
if (successful) {
message.success('删除成功');
reload?.();
return;
}
message.error('删除失败');
Modal.confirm({
title: `确认要移除逻辑表${record?.name}?`,
onOk: async () => {
const successful = await deleteLogicalTable(logicalDatabaseId, record.id);
if (successful) {
message.success('移除成功');
reload?.();
return;
}
},
});
}}
disabled={record.physicalTableCount === 0}
tooltip={record.physicalTableCount === 0 ? '存在物理表,暂不可移除' : ''}
Expand Down
5 changes: 4 additions & 1 deletion src/page/Project/Database/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ const Database: React.FC<IProps> = ({ id, modalStore }) => {
dataIndex: 'name',
fixed: 'left',
ellipsis: true,
width: 250,
render: (name, record) => {
const hasChangeAuth = record.authorizedPermissionTypes?.includes(
DatabasePermissionType.CHANGE,
Expand Down Expand Up @@ -318,7 +319,9 @@ const Database: React.FC<IProps> = ({ id, modalStore }) => {
);
}}
/>
<Typography.Text type="secondary">{record?.alias}</Typography.Text>
<Typography.Text type="secondary" title={record?.alias}>
{record?.alias}
</Typography.Text>
</Space>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@ const LogicTableBaseInfo = ({
}
const dbId = session?.odcDatabase?.id;
const res = await previewLogicalTableTopologies(dbId, form.getFieldValue('tableName'));
if (res) {
if (Array.isArray(res)) {
setPreviewTopologiesList(res);
} else {
setPreviewTopologiesList([]);
form.setFields([
{
name: 'tableName',
errors: ['语法错误'],
errors: [res || '语法错误'],
},
]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export interface ISessionDropdownFiltersProps {
dialectTypes?: ConnectionMode[];
dataSourceId?: number;
feature?: keyof IDataSourceModeConfig['features'];
isIncludeLogicalDb?: boolean;
}
interface IProps {
dialectTypes?: ConnectionMode[];
Expand Down Expand Up @@ -120,6 +121,7 @@ const SessionDropdown: React.FC<IProps> = function ({
filters?.dialectTypes && Array.isArray(filters?.dialectTypes) && filters?.dialectTypes?.length;
const hasProjectIdFilter = !!filters?.projectId;
const hasFeature = !!filters?.feature;
const isIncludeLogicalDb = !!filters?.isIncludeLogicalDb;
const {
data,
run,
Expand Down Expand Up @@ -149,7 +151,14 @@ const SessionDropdown: React.FC<IProps> = function ({
allDatasources: IDatasource[] = [];
data?.contents?.forEach((db) => {
let { project, dataSource } = db;
if (context?.isLogicalDatabase ? db.type !== 'LOGICAL' : db.type !== 'PHYSICAL') {
if (!context?.isLogicalDatabase && db.type === 'LOGICAL' && !isIncludeLogicalDb) {
return;
}
if (
context?.isLogicalDatabase
? db.type !== 'LOGICAL'
: db.type !== 'PHYSICAL' && !isIncludeLogicalDb
) {
return;
}
if (dataSource) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,13 @@ export default function SessionSelect({
readonly,
feature,
supportLocation,
isIncludeLogicalDb = true,
}: {
readonly?: boolean;
dialectTypes?: ConnectionMode[];
feature?: keyof IDataSourceModeConfig['features'];
supportLocation?: boolean;
isIncludeLogicalDb?: boolean;
}) {
const context = useContext(SessionContext);
const resourceTreeContext = useContext(ResourceTreeContext);
Expand Down Expand Up @@ -153,7 +155,7 @@ export default function SessionSelect({
return (
<div className={styles.content}>
{renderEnv()}
<SessionDropdown filters={{ feature }}>
<SessionDropdown filters={{ feature, isIncludeLogicalDb }}>
<div>{databaseItem}</div>
</SessionDropdown>
<div>{aimItem}</div>
Expand Down

0 comments on commit 6c75e27

Please sign in to comment.