Skip to content

Commit e818f14

Browse files
committed
Merge branch 'dev-4.3.1' of https://code.alipay.com/oceanbase/oceanbase-developer-center into dev-4.3.1
2 parents 93ff388 + d7addf8 commit e818f14

File tree

14 files changed

+153
-68
lines changed

14 files changed

+153
-68
lines changed

src/component/CommonTable/index.tsx

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -276,12 +276,11 @@ const CommonTable: <RecordType extends object = any>(
276276
}
277277

278278
function handleRowKeyChange(selected: boolean, changeKeys: number[]) {
279-
const keys = [...selectedRowKeys];
279+
let keys = [...selectedRowKeys];
280280
if (selected) {
281281
keys.push(...changeKeys);
282282
} else {
283-
const firstKeyIndex = keys.indexOf(changeKeys[0]);
284-
keys.splice(firstKeyIndex, changeKeys.length);
283+
keys = keys.filter((item) => !changeKeys.includes(item));
285284
}
286285
setSelectedRowKeys(keys);
287286
}
@@ -461,12 +460,17 @@ const CommonTable: <RecordType extends object = any>(
461460
}
462461
onChange={handleChange}
463462
rowSelection={
464-
rowSelecter && {
465-
...rowSelecter,
466-
selectedRowKeys,
467-
onSelect: handleRowKeySelect,
468-
onSelectAll: handleSelectAll,
469-
}
463+
rowSelecter
464+
? {
465+
...tableProps?.rowSelection,
466+
...rowSelecter,
467+
selectedRowKeys,
468+
onSelect: handleRowKeySelect,
469+
onSelectAll: handleSelectAll,
470+
}
471+
: {
472+
...tableProps?.rowSelection,
473+
}
470474
}
471475
pagination={{
472476
...tableProps?.pagination,

src/component/ExecuteSqlDetailModal/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ const ExecuteSQLDetailModal: React.FC<IProps> = ({ modalStore }: IProps) => {
325325
id: 'src.component.ExecuteSqlDetailModal.A944EAD1',
326326
defaultMessage: '执行计划详情',
327327
}),
328-
sql: modalStore?.executeSqlDetailData?.sql,
328+
sql: modalStore?.executeSqlDetailData?.selectedSQL,
329329
session: modalStore?.executeSqlDetailData?.session,
330330
traceId: modalStore?.executeSqlDetailData?.traceId,
331331
getDetail: getPlanDetail,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ const CreateModal: React.FC<IProps> = (props) => {
198198
const projectId = Form.useWatch('projectId', form);
199199

200200
const disabledDate = (current) => {
201-
return current && current < moment().endOf('day');
201+
return current && current < moment().subtract(1, 'days').endOf('day');
202202
};
203203

204204
useEffect(() => {

src/component/Task/component/TableSelecter/index.less

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,16 @@
7171
}
7272
}
7373
}
74+
75+
.env {
76+
position: absolute;
77+
top: 0px;
78+
right: 8px;
79+
bottom: 0px;
80+
align-items: center;
81+
:global {
82+
.ant-badge-status-dot {
83+
border-radius: 0px;
84+
}
85+
}
86+
}

src/component/Task/component/TableSelecter/index.tsx

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import { IDatabase } from '@/d.ts/database';
2323
import { TablePermissionType } from '@/d.ts/table';
2424
import { ReactComponent as TableSvg } from '@/svgr/menuTable.svg';
2525
import Icon, { DeleteOutlined } from '@ant-design/icons';
26-
import { Checkbox, Empty, Popconfirm, Space, Spin, Tree, Typography } from 'antd';
26+
import { Badge, Empty, Popconfirm, Space, Spin, Tree, Typography } from 'antd';
2727
import { DataNode, EventDataNode, TreeProps } from 'antd/lib/tree';
2828
import classnames from 'classnames';
2929
import React, {
@@ -36,6 +36,7 @@ import React, {
3636
} from 'react';
3737
import { isNumber } from 'lodash';
3838
import styles from './index.less';
39+
import { EnvColorMap } from '@/constant';
3940

4041
export type TableItem = { databaseId: number; tableName: string; tableId?: number };
4142

@@ -133,14 +134,27 @@ export const flatTableByGroupedParams = (
133134
});
134135
return result;
135136
};
137+
138+
function envRender(environment) {
139+
if (!environment) {
140+
return null;
141+
}
142+
return (
143+
<Badge
144+
className={styles.env}
145+
color={EnvColorMap[environment?.style?.toUpperCase()]?.tipColor}
146+
/>
147+
);
148+
}
149+
136150
/**
137151
* 将原始的IDataBaseWithTable数据转成TreeData格式
138152
* @param validTableList
139153
* @returns
140154
*/
141-
const getTreeData = (validTableList: IDataBaseWithTable[]) => {
155+
const getTreeData = (validTableList: IDataBaseWithTable[], isSourceTree = false) => {
142156
const allTreeData = validTableList?.map((database) => {
143-
const { id, name, tableList, dataSource, hasGetTableList } = database;
157+
const { id, name, tableList, dataSource, hasGetTableList, environment } = database;
144158
const children = tableList.map((tableItem) => ({
145159
title: (
146160
<Space>
@@ -165,8 +179,9 @@ const getTreeData = (validTableList: IDataBaseWithTable[]) => {
165179
{dataSource?.name}
166180
</Text>
167181
<Text type="secondary" ellipsis>
168-
{hasGetTableList ? `(${tableList.length})` : ''}
182+
{hasGetTableList && isSourceTree ? `(${tableList.length})` : ''}
169183
</Text>
184+
{isSourceTree ? envRender(environment) : null}
170185
</Space>
171186
),
172187

@@ -229,7 +244,7 @@ const TableSelecter: React.ForwardRefRenderFunction<TableSelecterRef, IProps> =
229244
*/
230245
const allTreeData = useMemo(() => {
231246
if (!sourceSearchValue?.length) {
232-
return getTreeData(databaseWithTableList);
247+
return getTreeData(databaseWithTableList, true);
233248
}
234249
const filtedDataSource = [];
235250
for (const datasource of databaseWithTableList) {
@@ -246,7 +261,7 @@ const TableSelecter: React.ForwardRefRenderFunction<TableSelecterRef, IProps> =
246261
}
247262
}
248263
}
249-
return getTreeData(filtedDataSource);
264+
return getTreeData(filtedDataSource, true);
250265
}, [sourceSearchValue, databaseWithTableList]);
251266

252267
/**
@@ -458,21 +473,12 @@ const TableSelecter: React.ForwardRefRenderFunction<TableSelecterRef, IProps> =
458473
<ExportCard
459474
title={
460475
<Space size={4}>
461-
<Checkbox
462-
indeterminate={indeterminate}
463-
checked={checkAll}
464-
style={{ marginRight: '8px' }}
465-
/>
466-
467476
<span>
468477
{formatMessage({
469478
id: 'src.component.Task.component.TableSelecter.E836E630',
470479
defaultMessage: '选择表',
471480
})}
472481
</span>
473-
<Text type="secondary">
474-
({selectedTreeDataCount}/{allTreeDataCount})
475-
</Text>
476482
</Space>
477483
}
478484
onSearch={setSourceSearchValue}

src/page/Project/Database/index.tsx

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ import StatusName from './StatusName';
5050
import ChangeOwnerModal from '@/page/Project/Database/ChangeOwnerModal';
5151
import { ProjectRole } from '@/d.ts/project';
5252
import MutipleAsyncTask from '@/component/Task/MutipleAsyncTask';
53+
import { databasePermissionTypeMap } from '@/page/Project/User/ManageModal/Database';
5354
interface IProps {
5455
id: string;
5556
modalStore?: ModalStore;
@@ -130,6 +131,15 @@ const Database: React.FC<IProps> = ({ id, modalStore }) => {
130131
</span>
131132
);
132133
};
134+
135+
const getAuthString = (authList: DatabasePermissionType[]) => {
136+
if (authList?.length === 0) return '无权限';
137+
return authList
138+
?.map((i) => databasePermissionTypeMap[i]?.text || '')
139+
?.filter(Boolean)
140+
?.join(',');
141+
};
142+
133143
const clearSelectedRowKeys = () => {
134144
setSelectedRowKeys([]);
135145
};
@@ -345,6 +355,14 @@ const Database: React.FC<IProps> = ({ id, modalStore }) => {
345355
ellipsis: true,
346356
render: (collationName) => collationName || '-',
347357
},
358+
{
359+
title: '权限',
360+
dataIndex: 'authorizedPermissionTypes',
361+
width: 130,
362+
render(v) {
363+
return getAuthString(v);
364+
},
365+
},
348366
{
349367
title: formatMessage({
350368
id: 'odc.Project.Database.LastSynchronizationTime',
@@ -378,6 +396,8 @@ const Database: React.FC<IProps> = ({ id, modalStore }) => {
378396
const hasQueryAuth = record.authorizedPermissionTypes?.includes(
379397
DatabasePermissionType.QUERY,
380398
);
399+
const hasNoDBAuth = record.authorizedPermissionTypes?.length === 0;
400+
381401
const curRoles = project?.currentUserResourceRoles || [];
382402
const hasChangeOwnerAuth = curRoles.some((role) =>
383403
[ProjectRole.OWNER, ProjectRole.DBA].includes(role),
@@ -425,6 +445,18 @@ const Database: React.FC<IProps> = ({ id, modalStore }) => {
425445
}
426446
return (
427447
<Action.Group size={3}>
448+
{hasNoDBAuth ? (
449+
<Action.Link
450+
key={'applyDBAuth'}
451+
onClick={() => {
452+
modalStore.changeApplyDatabasePermissionModal(true, {
453+
databaseId: record?.id,
454+
});
455+
}}
456+
>
457+
库权限申请
458+
</Action.Link>
459+
) : null}
428460
{config?.features?.task?.includes(TaskType.EXPORT) && setting.enableDBExport && (
429461
<Action.Link
430462
key={'export'}

src/page/Project/User/ManageModal/Database/index.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ export const databasePermissionTypeMap = {
4343
text: formatMessage({ id: 'src.page.Project.User.ManageModal.2DDCB471' }), //'变更'
4444
value: DatabasePermissionType.CHANGE,
4545
},
46+
[DatabasePermissionType.ACCESS]: {
47+
text: '访问',
48+
value: DatabasePermissionType.ACCESS,
49+
},
4650
};
4751

4852
export const databasePermissionTypeFilters = Object.values(databasePermissionTypeMap);
@@ -100,7 +104,9 @@ const ManageModal: React.FC<IProps> = (props) => {
100104
};
101105

102106
const handleReload = () => {
103-
tableRef.current?.reload();
107+
const param = { ...params, pagination: { ...params?.pagination, current: 1 } };
108+
setParams(param);
109+
loadData(param);
104110
};
105111

106112
const handleReclaim = async (ids: number[]) => {

src/page/Project/User/ManageModal/Table/CreateAuth/index.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import TableSelecter, {
2828
import { Button, Checkbox, DatePicker, Drawer, Form, Modal, Select, Space, message } from 'antd';
2929
import React, { useState } from 'react';
3030
import styles from './index.less';
31+
import moment from 'moment';
3132

3233
const CheckboxGroup = Checkbox.Group;
3334

@@ -75,6 +76,10 @@ const CreateModal: React.FC<IProps> = (props) => {
7576
}
7677
};
7778

79+
const disabledDate = (current) => {
80+
return current && current < moment().subtract(1, 'days').endOf('day');
81+
};
82+
7883
const handleSubmit = () => {
7984
form
8085
.validateFields()
@@ -237,7 +242,7 @@ const CreateModal: React.FC<IProps> = (props) => {
237242
},
238243
]}
239244
>
240-
<DatePicker style={{ width: '327px' }} />
245+
<DatePicker style={{ width: '327px' }} disabledDate={disabledDate} />
241246
</Form.Item>
242247
)
243248
);

src/page/Project/User/ManageModal/Table/TaskApplyList/index.tsx

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,20 @@ const getColumns = (params: {
4646
const { filters } = params.paramOptions ?? {};
4747
return [
4848
{
49-
dataIndex: 'databaseName',
49+
dataIndex: 'tableName',
5050
title: formatMessage({
51-
id: 'src.page.Project.User.ManageModal.Table.TaskApplyList.F9701758',
52-
defaultMessage: '数据库',
51+
id: 'src.page.Project.User.ManageModal.Table.TaskApplyList.8F13E12E',
52+
defaultMessage: '',
5353
}),
54+
width: 140,
5455
ellipsis: true,
5556
filterDropdown: (props) => {
5657
return (
5758
<SearchFilter
5859
{...props}
59-
selectedKeys={filters?.databaseName}
60+
selectedKeys={filters?.tableName}
6061
placeholder={formatMessage({
61-
id: 'src.page.Project.User.ManageModal.Table.TaskApplyList.88257A65',
62+
id: 'src.page.Project.User.ManageModal.Table.TaskApplyList.F38F822F',
6263
defaultMessage: '请输入',
6364
})}
6465
/>
@@ -72,23 +73,21 @@ const getColumns = (params: {
7273
/>
7374
),
7475

75-
filteredValue: filters?.databaseName || null,
76+
filteredValue: filters?.tableName || null,
7677
filters: [],
7778
},
7879
{
79-
dataIndex: 'tableName',
80-
title: formatMessage({
81-
id: 'src.page.Project.User.ManageModal.Table.TaskApplyList.8F13E12E',
82-
defaultMessage: '表',
83-
}),
80+
dataIndex: 'databaseName',
81+
title: '所属数据库',
8482
ellipsis: true,
83+
width: 208,
8584
filterDropdown: (props) => {
8685
return (
8786
<SearchFilter
8887
{...props}
89-
selectedKeys={filters?.tableName}
88+
selectedKeys={filters?.databaseName}
9089
placeholder={formatMessage({
91-
id: 'src.page.Project.User.ManageModal.Table.TaskApplyList.F38F822F',
90+
id: 'src.page.Project.User.ManageModal.Table.TaskApplyList.88257A65',
9291
defaultMessage: '请输入',
9392
})}
9493
/>
@@ -102,7 +101,7 @@ const getColumns = (params: {
102101
/>
103102
),
104103

105-
filteredValue: filters?.tableName || null,
104+
filteredValue: filters?.databaseName || null,
106105
filters: [],
107106
},
108107
{

0 commit comments

Comments
 (0)