Skip to content

Commit fa46ccd

Browse files
committed
PullRequest: 848 434bp3
Merge branch 'feat/434bp3 of git@code.alipay.com:oceanbase/oceanbase-developer-center.git into dev-4.3.4 https://code.alipay.com/oceanbase/oceanbase-developer-center/pull_requests/848 Reviewed-by: 之瑛 <lijunying.ljy@digital-engine.com> * feat: support enableWorkbench * feat: support showResultSets in async task * fix: rename function name * fix: replace allowShowResultSets name
1 parent 747a6bc commit fa46ccd

File tree

21 files changed

+792
-405
lines changed

21 files changed

+792
-405
lines changed

config/routes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ module.exports = [
3131
{ path: '/auth/:page', component: '@/page/Auth', spmBPos: 'b64007' },
3232
{ path: '/secure/:page', component: '@/page/Secure', spmBPos: 'b64008' },
3333
{ path: '/externalIntegration/:page', component: '@/page/ExternalIntegration', spmBPos: 'b64009' },
34-
{ path: '/', redirect: '/console'},
34+
{ path: '/', component: '@/layout/DefaultRedirect'},
3535
],
3636
},
3737
{

src/component/CommonIDE/index.tsx

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,10 @@ interface ICommonIDEProps {
8282
*/
8383
bordered?: boolean;
8484
session?: SessionStore;
85-
85+
/**
86+
* 是否显示运行结果
87+
*/
88+
showLog?: boolean;
8689
/**
8790
* 创建后监听事件
8891
*/
@@ -193,16 +196,19 @@ class CommonIDE extends React.PureComponent<ICommonIDEProps, ICommonIDEState> {
193196
<Tabs
194197
className={styles.tabs}
195198
animated={false}
196-
items={[
197-
{
198-
key: ITabType.LOG as string,
199-
label: formatMessage({
200-
id: 'odc.component.CommonIDE.Result',
201-
defaultMessage: '运行结果',
202-
}),
203-
children: log,
204-
},
205-
]
199+
items={(this.props.showLog
200+
? [
201+
{
202+
key: ITabType.LOG as string,
203+
label: formatMessage({
204+
id: 'odc.component.CommonIDE.Result',
205+
defaultMessage: '运行结果',
206+
}),
207+
children: log,
208+
},
209+
]
210+
: []
211+
)
206212
.concat(
207213
resultSets?.map((set, i) => {
208214
return {
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import React, { useState } from 'react';
2+
import { Checkbox } from 'antd';
3+
4+
interface CheckboxOption {
5+
label: string;
6+
value: string;
7+
}
8+
9+
interface CheckboxItemProps {
10+
options: CheckboxOption[];
11+
value?: string[];
12+
onChange?: (value: string[]) => Promise<void>;
13+
}
14+
15+
export default function CheckboxItem(props: CheckboxItemProps) {
16+
const [loading, setLoading] = useState(false);
17+
18+
const handleChange = async (checkedValues: string[]) => {
19+
if (props.onChange) {
20+
setLoading(true);
21+
try {
22+
await props.onChange(checkedValues);
23+
} finally {
24+
setLoading(false);
25+
}
26+
}
27+
};
28+
29+
return (
30+
<Checkbox.Group
31+
options={props.options}
32+
value={props.value || []}
33+
disabled={loading}
34+
onChange={handleChange}
35+
/>
36+
);
37+
}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import CheckboxItem from '../Item/CheckboxItem';
2+
import RadioItem from '../Item/RadioItem';
3+
import { ODCSettingGroup } from '../config';
4+
import { resultSetsGroup } from '../utils/configHelper';
5+
6+
export const getExecutionStrategyConfig = (taskGroup: ODCSettingGroup) => {
7+
return [
8+
{
9+
label: '数据库变更默认执行方式',
10+
key: 'odc.task.databaseChange.executionStrategy',
11+
locationKey: 'executionStrategy',
12+
group: taskGroup,
13+
storeType: 'server' as const,
14+
render: (value, onChange) => {
15+
return (
16+
<RadioItem
17+
options={[
18+
{
19+
label: '立即执行',
20+
value: 'AUTO',
21+
},
22+
{
23+
label: '定时执行',
24+
value: 'TIMER',
25+
},
26+
{
27+
label: '手动执行',
28+
value: 'MANUAL',
29+
},
30+
]}
31+
value={value}
32+
onChange={onChange}
33+
/>
34+
);
35+
},
36+
},
37+
];
38+
};
39+
40+
export const getDatabaseChangeResultSetsConfig = (taskGroup: ODCSettingGroup) => {
41+
return [
42+
{
43+
label: '支持查看查询结果',
44+
key: 'odc.task.databaseChange.allowShowResultSets',
45+
locationKey: 'allowShowResultSets',
46+
group: taskGroup,
47+
storeType: 'server' as const,
48+
hidden: true,
49+
render: () => null,
50+
},
51+
{
52+
label: '支持下载查询结果',
53+
key: 'odc.task.databaseChange.allowDownloadResultSets',
54+
locationKey: 'allowDownloadResultSets',
55+
group: taskGroup,
56+
storeType: 'server' as const,
57+
hidden: true,
58+
render: () => null,
59+
},
60+
{
61+
label: '数据库变更查询结果',
62+
key: 'databaseChangeResultSets',
63+
locationKey: 'databaseChangeResultSets',
64+
group: taskGroup,
65+
storeType: 'server' as const,
66+
render: (value, onChange) => {
67+
return <CheckboxItem value={value} options={resultSetsGroup} onChange={onChange} />;
68+
},
69+
},
70+
];
71+
};

src/component/ODCSetting/config/group/task.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { formatMessage } from '@/util/intl';
1717
import { IODCSetting, ODCSettingGroup } from '../../config';
1818
import RadioItem from '../../Item/RadioItem';
1919
import TextAreaItem from '../../Item/TextItem';
20+
import { getExecutionStrategyConfig, getDatabaseChangeResultSetsConfig } from '../common';
2021

2122
const taskGroup: ODCSettingGroup = {
2223
label: formatMessage({
@@ -157,6 +158,8 @@ const taskSetting: IODCSetting[] = [
157158
);
158159
},
159160
},
161+
...getDatabaseChangeResultSetsConfig(taskGroup),
162+
...getExecutionStrategyConfig(taskGroup),
160163
{
161164
label: formatMessage({
162165
id: 'src.component.ODCSetting.config.group.0ACF68C5',

src/component/ODCSetting/config/personal/personalTask.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { formatMessage } from '@/util/intl';
1616
*/
1717
import { IODCSetting, ODCSettingGroup } from '../../config';
1818
import RadioItem from '../../Item/RadioItem';
19+
import { getExecutionStrategyConfig, getDatabaseChangeResultSetsConfig } from '../common';
1920

2021
const taskGroup: ODCSettingGroup = {
2122
label: formatMessage({
@@ -60,6 +61,8 @@ const personalTaskSetting: IODCSetting[] = [
6061
);
6162
},
6263
},
64+
...getDatabaseChangeResultSetsConfig(taskGroup),
65+
...getExecutionStrategyConfig(taskGroup),
6366
];
6467

6568
export default personalTaskSetting;

src/component/ODCSetting/index.tsx

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ import { inject, observer } from 'mobx-react';
4747
import styles from './index.less';
4848
import odc from '@/plugins/odc';
4949
import login from '@/store/login';
50+
import { ConfigHelper } from './utils/configHelper';
5051

5152
interface IProps {
5253
modalStore?: ModalStore;
@@ -289,10 +290,13 @@ const ODCSetting: React.FC<IProps> = ({ modalStore }) => {
289290
const clientData = safeParseJson(await getODCSetting(), {});
290291
data = { ...data, ...clientData };
291292
}
292-
formRef.setFieldsValue(data);
293+
const transformedData = ConfigHelper.transformLoadData(data);
294+
formRef.setFieldsValue(transformedData);
293295

294296
let spaceData = (await setting.getSpaceConfig()) || {};
295-
spaceFormRef.setFieldsValue(spaceData);
297+
298+
const transformedSpaceData = ConfigHelper.transformLoadData(spaceData);
299+
spaceFormRef.setFieldsValue(transformedSpaceData);
296300
}
297301

298302
useEffect(() => {
@@ -313,33 +317,42 @@ const ODCSetting: React.FC<IProps> = ({ modalStore }) => {
313317
const serverData: Record<string, string> = {},
314318
localData = {};
315319
const spaceServerData: Record<string, string> = {};
316-
Object.keys(values).forEach((key) => {
320+
321+
const expandedValues = ConfigHelper.transformSaveData(values);
322+
const expandedSpaceValues = ConfigHelper.transformSaveData(spaceValues);
323+
324+
Object.keys(expandedValues).forEach((key) => {
317325
const info = odcSettingMap[key];
326+
if (!info) return;
327+
318328
switch (info.storeType) {
319329
case 'server': {
320-
serverData[key] = values[key] || '';
330+
serverData[key] = expandedValues[key] || '';
321331
break;
322332
}
323333
case 'local': {
324-
localData[key] = values[key];
334+
localData[key] = expandedValues[key];
325335
break;
326336
}
327337
}
328338
});
329339

330-
Object.keys(spaceValues).forEach((key) => {
340+
Object.keys(expandedSpaceValues).forEach((key) => {
331341
const info = odcSettingMap[key];
342+
if (!info) return;
343+
332344
switch (info.storeType) {
333345
case 'server': {
334-
spaceServerData[key] = spaceValues[key];
346+
spaceServerData[key] = expandedSpaceValues[key];
335347
break;
336348
}
337349
case 'local': {
338-
localData[key] = spaceValues[key];
350+
localData[key] = expandedSpaceValues[key];
339351
break;
340352
}
341353
}
342354
});
355+
343356
if (
344357
serverData['odc.editor.shortcut.executeStatement'] ===
345358
serverData['odc.editor.shortcut.executeCurrentStatement']
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
// 聚合配置项定义
2+
interface AggregateConfig {
3+
key: string; // 聚合配置的 key
4+
subKeys: string[]; // 包含的子配置项 keys
5+
}
6+
7+
// 定义聚合配置映射
8+
const AGGREGATE_CONFIGS: AggregateConfig[] = [
9+
{
10+
key: 'databaseChangeResultSets',
11+
subKeys: [
12+
'odc.task.databaseChange.allowShowResultSets',
13+
'odc.task.databaseChange.allowDownloadResultSets',
14+
],
15+
},
16+
];
17+
18+
export const resultSetsGroup = [
19+
{
20+
label: '支持查看查询结果',
21+
value: 'odc.task.databaseChange.allowShowResultSets',
22+
},
23+
{
24+
label: '支持下载查询结果',
25+
value: 'odc.task.databaseChange.allowDownloadResultSets',
26+
},
27+
];
28+
29+
export class ConfigHelper {
30+
/**
31+
* 将原始配置数据转换为包含聚合配置的数据
32+
*/
33+
static transformLoadData(rawData: Record<string, any>): Record<string, any> {
34+
const transformedData = { ...rawData };
35+
36+
AGGREGATE_CONFIGS.forEach((config) => {
37+
// 将子配置项聚合成数组
38+
const aggregateValue = config.subKeys.filter(
39+
(subKey) => rawData[subKey] === 'true' || rawData[subKey] === true,
40+
);
41+
transformedData[config.key] = aggregateValue;
42+
});
43+
44+
return transformedData;
45+
}
46+
47+
/**
48+
* 将包含聚合配置的数据展开为原始配置数据
49+
*/
50+
static transformSaveData(formData: Record<string, any>): Record<string, any> {
51+
const expandedData = { ...formData };
52+
53+
AGGREGATE_CONFIGS.forEach((config) => {
54+
const aggregateValue = formData[config.key];
55+
56+
if (Array.isArray(aggregateValue)) {
57+
// 展开聚合配置
58+
config.subKeys.forEach((subKey) => {
59+
expandedData[subKey] = aggregateValue.includes(subKey) ? 'true' : 'false';
60+
});
61+
62+
// 删除聚合配置项
63+
delete expandedData[config.key];
64+
}
65+
});
66+
67+
return expandedData;
68+
}
69+
}

src/component/ProfileFlow/customComponents/index.less

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
.customDetailBox {
44
position: absolute;
55
right: 16px;
6-
width: 336px;
6+
width: 360px;
77
background-color: var(--profile-secondry-background-color);
88
border: 1px solid var(--profile-border-color);
99
border-left: none;
10-
height: calc(100% - 151px);
10+
height: calc(100% - 175px);
1111
overflow-y: auto;
1212
padding: 12px 8px;
1313
.value {

src/component/Task/AsyncTask/CreateModal/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,7 @@ const CreateModal: React.FC<IProps> = (props) => {
483483
queryLimit: Number(setting.getSpaceConfigByKey('odc.sqlexecute.default.queryLimit')),
484484
generateRollbackPlan:
485485
setting.getSpaceConfigByKey('odc.task.default.rollbackPlanEnabled') === 'true',
486+
executionStrategy: setting.getSpaceConfigByKey('odc.task.databaseChange.executionStrategy'),
486487
};
487488
form.setFieldsValue(initialFormData);
488489
};
@@ -562,7 +563,6 @@ const CreateModal: React.FC<IProps> = (props) => {
562563
<Form
563564
name="basic"
564565
initialValues={{
565-
executionStrategy: TaskExecStrategy.MANUAL,
566566
databaseId: asyncTaskData?.databaseId,
567567
retryTimes: 0,
568568
}}

0 commit comments

Comments
 (0)