Skip to content

Commit

Permalink
Merge branch 'dev-4.2.3' of code.alipay.com:oceanbase/oceanbase-devel…
Browse files Browse the repository at this point in the history
…oper-center into dev-4.2.3
  • Loading branch information
HSunboy committed Nov 20, 2023
2 parents 317ee93 + a90f400 commit 2ca2350
Show file tree
Hide file tree
Showing 20 changed files with 255 additions and 52 deletions.
8 changes: 5 additions & 3 deletions src/component/Task/ApplyPermission/CreateModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { Button, Drawer, Form, Modal, Select, Space, Input, message } from 'antd
import { inject, observer } from 'mobx-react';
import React, { useEffect, useState } from 'react';
import styles from './index.less';
import { projectRoleTextMap } from '@/page/Project/User';

interface IProps {
sqlStore?: SQLStore;
Expand All @@ -47,7 +48,8 @@ const CreateModal: React.FC<IProps> = (props) => {
value: id,
}));
const rolesOptions = roles?.map(({ roleName, id }) => ({
label: roleName,
label: projectRoleTextMap?.[roleName],
name: roleName,
value: id,
}));

Expand Down Expand Up @@ -100,8 +102,8 @@ const CreateModal: React.FC<IProps> = (props) => {
const project = projectOptions?.find(({ value }) => value === projectId);
const resourceRoles = rolesOptions
?.filter(({ value }) => resourceRoleIds?.includes(value))
?.map(({ value, label }) => ({
name: label,
?.map(({ value, name }) => ({
name: name,
id: value,
}));
const parameters = {
Expand Down
43 changes: 38 additions & 5 deletions src/component/Task/Content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ import DetailModal from './DetailModal';
import { isCycleTaskPage } from './helper';
import styles from './index.less';
import tracert from '@/util/tracert';
import { getProject } from '@/common/network/project';
import { ProjectRole } from '@/d.ts/project';

interface IProps {
taskStore?: TaskStore;
Expand All @@ -46,6 +48,7 @@ interface IProps {
tabHeight?: number;
projectId?: number;
isMultiPage?: boolean;
inProject?: boolean;
}

interface IState {
Expand All @@ -54,6 +57,7 @@ interface IState {
detailVisible: boolean;
partitionPlan: IConnectionPartitionPlan;
status: TaskStatus;
disabledOpt: boolean;
tasks: IResponseData<TaskRecord<TaskRecordParameters>>;
cycleTasks: IResponseData<ICycleTaskRecord<ISqlPlayJobParameters | IDataArchiveJobParameters>>;
}
Expand All @@ -67,6 +71,7 @@ class TaskManaerContent extends React.Component<IProps, IState> {
detailId: props.taskStore?.defaultOpenTaskId,
detailType: props.taskStore?.defauleOpenTaskType,
detailVisible: !!props.taskStore?.defaultOpenTaskId,
disabledOpt: null,
partitionPlan: null,
tasks: null,
cycleTasks: null,
Expand Down Expand Up @@ -103,13 +108,13 @@ class TaskManaerContent extends React.Component<IProps, IState> {
TaskPageType.CREATED_BY_CURRENT_USER,
TaskPageType.APPROVE_BY_CURRENT_USER,
].includes(taskTabType);

const isAll = taskTabType === TaskPageType.ALL;
if (!pageSize) {
return;
}
const params = {
fuzzySearchKeyword: id ? id : undefined,
taskType: isAllScope ? taskTabType : undefined,
taskType: isAllScope ? (isAll ? undefined : taskTabType) : undefined,
projectId,
status,
startTime: executeDate?.[0]?.valueOf() ?? getPreTime(7),
Expand All @@ -126,6 +131,7 @@ class TaskManaerContent extends React.Component<IProps, IState> {
approveByCurrentUser: isAllScope
? true
: taskTabType === TaskPageType.APPROVE_BY_CURRENT_USER,
containsAll: isAll || isAllScope,
};

if (executeTime !== 'custom' && typeof executeTime === 'number') {
Expand Down Expand Up @@ -154,13 +160,13 @@ class TaskManaerContent extends React.Component<IProps, IState> {
TaskPageType.CREATED_BY_CURRENT_USER,
TaskPageType.APPROVE_BY_CURRENT_USER,
].includes(taskTabType);

const isAll = taskTabType === TaskPageType.ALL;
if (!pageSize) {
return;
}
const params = {
id: id ? id : undefined,
type: isAllScope ? taskTabType : undefined,
type: isAllScope ? (isAll ? undefined : taskTabType) : undefined,
projectId,
status,
candidateApprovers,
Expand All @@ -172,6 +178,7 @@ class TaskManaerContent extends React.Component<IProps, IState> {
sort: column?.dataIndex,
page: current,
size: pageSize,
containsAll: isAll || isAllScope,
};

if (executeTime !== 'custom' && typeof executeTime === 'number') {
Expand Down Expand Up @@ -258,6 +265,23 @@ class TaskManaerContent extends React.Component<IProps, IState> {
default:
}
};
async fetchProject(projectId: number) {
const data = await getProject(projectId);
const currentUserResourceRoles = data?.currentUserResourceRoles || [];
const disabled =
currentUserResourceRoles?.filter((roles) =>
[ProjectRole.DBA, ProjectRole.OWNER, ProjectRole.DEVELOPER]?.includes(roles),
)?.length === 0;
this.setState({
disabledOpt: disabled,
});
}
componentDidMount(): void {
const { inProject, projectId } = this.props;
if (inProject && projectId) {
this.fetchProject(projectId);
}
}

private hasCreate = (key: string) => {
const taskTypes = Object.values(TaskType);
Expand All @@ -266,13 +290,22 @@ class TaskManaerContent extends React.Component<IProps, IState> {

render() {
const { pageKey, taskStore, isMultiPage = false } = this.props;
const { detailId, detailType, detailVisible, partitionPlan, cycleTasks, tasks } = this.state;
const {
detailId,
detailType,
detailVisible,
partitionPlan,
cycleTasks,
tasks,
disabledOpt,
} = this.state;
const taskTabType = pageKey || taskStore?.taskPageType;
const taskList = isCycleTaskPage(taskTabType) ? cycleTasks : tasks;
return (
<>
<div className={styles.content}>
<TaskTable
disabledOpt={disabledOpt}
tableRef={this.tableRef}
taskTabType={taskTabType}
taskList={taskList}
Expand Down
13 changes: 12 additions & 1 deletion src/component/Task/component/TaskTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ interface IProps {
| ICycleTaskRecord<ISqlPlayJobParameters | IDataArchiveJobParameters>
>;
isMultiPage?: boolean;
disabledOpt?: boolean;
getTaskList: (args: ITableLoadOptions, executeDate: [Moment, Moment]) => Promise<any>;
onReloadList: () => void;
onDetailVisible: (task: TaskRecord<TaskRecordParameters>, visible: boolean) => void;
Expand All @@ -155,7 +156,15 @@ const TaskTable: React.FC<IProps> = inject(
'pageStore',
)(
observer((props) => {
const { taskStore, pageStore, taskTabType, tableRef, taskList, isMultiPage } = props;
const {
taskStore,
pageStore,
taskTabType,
tableRef,
taskList,
isMultiPage,
disabledOpt,
} = props;
const { taskPageScope } = taskStore;
const taskStatusFilters = getStatusFilters(isCycleTaskPage(taskTabType) ? cycleStatus : status);
const currentTask = taskList;
Expand Down Expand Up @@ -403,6 +412,7 @@ const TaskTable: React.FC<IProps> = inject(
loadData(listParams);
};
const isAll = [
TaskPageType.ALL,
TaskPageType.APPROVE_BY_CURRENT_USER,
TaskPageType.CREATED_BY_CURRENT_USER,
].includes(taskTabType);
Expand All @@ -429,6 +439,7 @@ const TaskTable: React.FC<IProps> = inject(
<DownOutlined />
</Button>
),
disabled: disabledOpt,
overlay: (
<Menu
onClick={({ key }) => {
Expand Down
5 changes: 5 additions & 0 deletions src/component/Task/helper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ export const getTaskGroupLabels: () => ITaskGroupLabel[] = () => {
{
groupName: '',
group: [
{
label: '所有工单',
value: TaskPageType.ALL,
enabled: !isClient(),
},
{
label: formatMessage({
id: 'odc.component.TaskPopover.IInitiated',
Expand Down
4 changes: 2 additions & 2 deletions src/component/Task/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@ interface IProps {
projectId?: number;
}
const TaskManaerPage = (props) => {
const { projectId } = props;
const { projectId, inProject } = props;
return (
<>
<div className={styles.task}>
<div className={styles.sider}>
<Sider />
</div>
<Content projectId={projectId} />
<Content projectId={projectId} inProject={inProject} />
<CreateModals projectId={projectId} theme="white" />
</div>
</>
Expand Down
2 changes: 2 additions & 0 deletions src/component/helpDoc/doc.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,8 @@ export default {
}
</p>
),
projectSA: <p>只允许管理项目的敏感列和参与审批</p>,
participant: <p>只允许参与审批</p>,
dataArchiveTimeDoc: (
<p>
{
Expand Down
2 changes: 2 additions & 0 deletions src/d.ts/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ export enum ProjectRole {
DEVELOPER = 'DEVELOPER',
DBA = 'DBA',
OWNER = 'OWNER',
SECURITY_ADMINISTRATOR = 'SECURITY_ADMINISTRATOR',
PARTICIPANT = 'PARTICIPANT',
}

export interface ProjectUser {
Expand Down
3 changes: 2 additions & 1 deletion src/page/Auth/Autoauth/component/FormModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import ConditionSelect from './conditionSelect';
import styles from './index.less';
import ProjectRoleSelect from './projectRoleSelect';
import tracert from '@/util/tracert';
import { projectRoleTextMap } from '@/page/Project/User';
interface IProps {
visible: boolean;
editId?: number;
Expand All @@ -72,7 +73,7 @@ const FormModal: React.FC<IProps> = (props) => {
const [events, setEvents] = useState([]);
const [variableExpression, setVariableExpression] = useState<VariableExpression>({});
const projectRoleOptions = projectRoles?.map((item) => ({
label: item.roleName,
label: projectRoleTextMap?.[item?.roleName],
value: item.id,
}));
const projectOptions = projects?.map((item) => ({
Expand Down
16 changes: 13 additions & 3 deletions src/page/Project/Database/AddDataBaseButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ import RiskLevelLabel from '@/component/RiskLevelLabel';
import { formatMessage } from '@/util/intl';
import { useRequest } from 'ahooks';
import { Button, Col, Form, message, Modal, Row, Select, Space, Tag } from 'antd';
import { useState } from 'react';
import { useContext, useState } from 'react';
import Icon from '@ant-design/icons';
import { getDataSourceStyle, getDataSourceStyleByConnectType } from '@/common/datasource';
import ProjectContext from '../../ProjectContext';
import { ProjectRole } from '@/d.ts/project';

interface IProps {
projectId: number;
Expand All @@ -31,6 +33,7 @@ interface IProps {

export default function AddDataBaseButton({ projectId, onSuccess }: IProps) {
const [open, setOpen] = useState<boolean>(false);
const { project } = useContext(ProjectContext);
const [form] = Form.useForm<{ databaseIds: number[] }>();
const { run, loading } = useRequest(updateDataBase, {
manual: true,
Expand Down Expand Up @@ -73,10 +76,17 @@ export default function AddDataBaseButton({ projectId, onSuccess }: IProps) {
onSuccess();
}
}

return (
<>
<Button onClick={() => setOpen(true)} type="primary">
<Button
onClick={() => setOpen(true)}
type="primary"
disabled={
project?.currentUserResourceRoles?.filter((roles) =>
[ProjectRole.DBA, ProjectRole.OWNER]?.includes(roles),
)?.length === 0
}
>
{formatMessage({ id: 'odc.Database.AddDataBaseButton.AddDatabase' }) /*添加数据库*/}
</Button>
<Modal
Expand Down
8 changes: 8 additions & 0 deletions src/page/Project/Database/index.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.disable {
cursor: not-allowed;
color: var(--mask-color);
&:hover {
cursor: not-allowed;
color: var(--mask-color);
}
}
Loading

0 comments on commit 2ca2350

Please sign in to comment.