Skip to content

Commit

Permalink
PullRequest: 588 feat: 删除项目
Browse files Browse the repository at this point in the history
Merge branch 'feat/deleteProject of [email protected]:oceanbase/oceanbase-developer-center.git into dev-4.3.3

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


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


* feat: 删除项目
* feat: 增加验证值传参
* feat:添加未完成工单的列表
* feat: 对接接口
  • Loading branch information
liyi711 committed Dec 6, 2024
1 parent fb6ae38 commit 4aca0f1
Show file tree
Hide file tree
Showing 27 changed files with 725 additions and 205 deletions.
7 changes: 7 additions & 0 deletions src/common/network/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,3 +272,10 @@ export async function addTablePermissions(params: {
);
return !!res?.data;
}

export async function batchDeleteProject(projectId: number[]): Promise<boolean> {
const res = await request.post('/api/v2/collaboration/projects/batchDelete', {
data: projectId,
});
return !!res?.data;
}
9 changes: 9 additions & 0 deletions src/common/network/task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import {
IPartitionPlanTable,
IPartitionTablePreviewConfig,
IResponseData,
UnfinishedTickets,
ISubTaskRecords,
ITaskResult,
Operation,
Expand Down Expand Up @@ -155,6 +156,14 @@ export async function getTaskList<T>(params: {
return res?.data;
}

/**
* 查询未完成的任务列表
*/
export async function getUnfinishedTickets(projectId: number): Promise<UnfinishedTickets> {
const res = await request.get(`/api/v2/collaboration/projects/${projectId}/unfinishedTickets`);
return res.data;
}

/**
* 查询周期任务列表
*/
Expand Down
1 change: 1 addition & 0 deletions src/component/CommonTable/Toolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export const Toolbar: React.FC<IProps> = (props) => {
} = props;
return (
<Space className={classNames(styles.toolBar, 'odc-commontable-toolbar')}>
{operationContent?.isNeedOccupyElement && <div></div>}
{operationContent && <OperationContent {...operationContent} onClick={onOperationClick} />}
{titleContent && <TitleContent {...titleContent} onTabChange={onTabChange} />}
<Space split={isSplit ? '|' : null} size={16}>
Expand Down
2 changes: 2 additions & 0 deletions src/component/CommonTable/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ export interface IOperationOption {
}
export interface IOperationContent {
options: IOperationOption[];
/** 是否需要占位 */
isNeedOccupyElement?: boolean;
}
export interface IRowSelecter<T> extends TableRowSelection<T> {
options: {
Expand Down
3 changes: 2 additions & 1 deletion src/component/DisplayTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ export default class DisplayTable extends React.Component<
showSizeChanger = true,
showQuickJumper = true,
enableResize,
scroll,
...rest
} = this.props;
const { defaultPageSize, columnWidthMap } = this.state;
Expand Down Expand Up @@ -175,7 +176,7 @@ export default class DisplayTable extends React.Component<
}
}
components={enableResize ? this.components : null}
scroll={{ x: 'max-content' }}
scroll={scroll ? scroll : { x: 'max-content' }}
/>
</div>
);
Expand Down
22 changes: 15 additions & 7 deletions src/component/Empty/ProjectEmpty/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
import { formatMessage } from '@/util/intl';
import { Result } from 'antd';
import styles from './index.less';
import { ProjectTabType } from '@/d.ts/project';

export default function ProjectEmpty({ type, renderActionButton }) {
interface ProjectEmptyProps {
type: ProjectTabType;
renderActionButton: () => JSX.Element;
}

const ProjectEmpty: React.FC<ProjectEmptyProps> = ({ type, renderActionButton }) => {
const renderTitle = (type) => {
switch (type) {
case 'all':
case ProjectTabType.ALL:
return (
<div className={styles.title}>
{formatMessage({
Expand All @@ -14,7 +20,7 @@ export default function ProjectEmpty({ type, renderActionButton }) {
})}
</div>
);
case 'deleted':
case ProjectTabType.ARCHIVED:
return (
<div className={styles.title}>
{formatMessage({
Expand All @@ -30,7 +36,7 @@ export default function ProjectEmpty({ type, renderActionButton }) {

const renderSubTitle = (type) => {
switch (type) {
case 'all':
case ProjectTabType.ALL:
return (
<div className={styles.subTitle}>
<div>
Expand All @@ -48,7 +54,7 @@ export default function ProjectEmpty({ type, renderActionButton }) {
</div>
);

case 'deleted':
case ProjectTabType.ARCHIVED:
return (
<div className={styles.subTitle}>
<div>
Expand Down Expand Up @@ -79,7 +85,9 @@ export default function ProjectEmpty({ type, renderActionButton }) {
}
/>

{type === 'all' && renderActionButton()}
{type === ProjectTabType.ALL && renderActionButton()}
</>
);
}
};

export default ProjectEmpty;
13 changes: 11 additions & 2 deletions src/component/Table/MiniTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,33 @@ import styles from './index.less';
import classNames from 'classnames';
import { ResizeTitle } from '@/component/CommonTable/component/ResizeTitle';
import { DEFAULT_COLUMN_WIDTH } from '@/component/CommonTable/const';
import type { ColumnGroupType, ColumnType } from 'antd/es/table';

type IColumnsType<RecordType = unknown> = ((
| ColumnGroupType<RecordType>
| ColumnType<RecordType>
) & { hide?: boolean })[];

interface IProps<T> extends TableProps<T> {
isExpandedRowRender?: boolean;
loadData: (page: TablePaginationConfig, filters: Record<string, FilterValue>) => void;
// 是否启用 列宽可拖拽
enableResize?: boolean;
columns: IColumnsType<T>;
}

export default function MiniTable<T extends object>({
loadData,
isExpandedRowRender = false,
enableResize = false,
columns: PropColumns = [],
...restProps
}: IProps<T>) {
const [pageSize, setPageSize] = useState(0);
const [columnWidthMap, setColumnWidthMap] = useState(null);

const domRef = useRef<HTMLDivElement>();
const columns = PropColumns.filter((item) => !item.hide);

useLayoutEffect(() => {
if (domRef.current) {
Expand Down Expand Up @@ -114,7 +123,7 @@ export default function MiniTable<T extends object>({
}
columns={
enableResize
? restProps?.columns?.map((oriColumn) => {
? columns?.map((oriColumn) => {
return {
...oriColumn,
width:
Expand All @@ -127,7 +136,7 @@ export default function MiniTable<T extends object>({
} as React.HTMLAttributes<HTMLElement>),
};
})
: restProps?.columns || []
: columns || []
}
/>
</div>
Expand Down
122 changes: 67 additions & 55 deletions src/component/Task/component/TaskTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,13 @@ import { inject, observer } from 'mobx-react';
import type { Moment } from 'moment';
import moment from 'moment';
import type { FixedType } from 'rc-table/lib/interface';
import React, { useEffect, useRef, useState } from 'react';
import React, { useEffect, useRef, useState, useContext } from 'react';
import { getTaskGroupLabels, getTaskLabelByType, isCycleTaskPage } from '../../helper';
import styles from '../../index.less';
import TaskTools from '../ActionBar';
import { listProjects } from '@/common/network/project';
import ProjectContext from '@/page/Project/ProjectContext';
import { isProjectArchived } from '@/page/Project/helper';
import { useRequest } from 'ahooks';
const { RangePicker } = DatePicker;
const { Text, Link } = Typography;
Expand Down Expand Up @@ -226,7 +228,8 @@ const TaskTable: React.FC<IProps> = inject(
const [hoverInNewTaskMenuBtn, setHoverInNewTaskMenuBtn] = useState(false);
const [hoverInNewTaskMenu, setHoverInNewTaskMenu] = useState(false);
const [listParams, setListParams] = useState(null);

const { project } = useContext(ProjectContext) || {};
const projectArchived = isProjectArchived(project);
const loadParams = useRef(null);
const { activePageKey } = pageStore;
const columns = initColumns(listParams);
Expand Down Expand Up @@ -567,66 +570,75 @@ const TaskTable: React.FC<IProps> = inject(
);
};

const getOperationContentOption = () => {
if (projectArchived) return [];
if (isAll) {
return [
{
type: IOperationOptionType.custom,
render: () => (
<Popover
content={newTaskMenu}
placement="bottomLeft"
open={hoverInNewTaskMenuBtn || hoverInNewTaskMenu}
>
<Button
type="primary"
onMouseMove={() => setHoverInNewTaskMenu(true)}
onMouseLeave={() => {
setTimeout(() => {
setHoverInNewTaskMenu(false);
}, 500);
}}
>
{
formatMessage({
id: 'odc.component.TaskTable.NewWorkOrder',
defaultMessage: '新建工单',
}) /*新建工单*/
}

<DownOutlined />
</Button>
</Popover>
),
},
];
}
return [
{
type: IOperationOptionType.button,
content: [
TaskPageType.APPLY_PROJECT_PERMISSION,
TaskPageType.APPLY_DATABASE_PERMISSION,
TaskPageType.APPLY_TABLE_PERMISSION,
].includes(taskTabType)
? activeTaskLabel
: formatMessage(
{
id: 'odc.src.component.Task.component.TaskTable.NewActiveTasklabel',
defaultMessage: '新建{activeTaskLabel}',
},
{ activeTaskLabel },
),
//`新建${activeTaskLabel}`
isPrimary: true,
onClick: () => {
props.onMenuClick(taskTabType);
},
},
];
};

return (
<CommonTable
ref={tableRef}
mode={CommonTableMode.SMALL}
titleContent={null}
enableResize
operationContent={{
options: [
isAll
? {
type: IOperationOptionType.custom,
render: () => (
<Popover
content={newTaskMenu}
placement="bottomLeft"
open={hoverInNewTaskMenuBtn || hoverInNewTaskMenu}
>
<Button
type="primary"
onMouseMove={() => setHoverInNewTaskMenu(true)}
onMouseLeave={() => {
setTimeout(() => {
setHoverInNewTaskMenu(false);
}, 500);
}}
>
{
formatMessage({
id: 'odc.component.TaskTable.NewWorkOrder',
defaultMessage: '新建工单',
}) /*新建工单*/
}

<DownOutlined />
</Button>
</Popover>
),
}
: {
type: IOperationOptionType.button,
content: [
TaskPageType.APPLY_PROJECT_PERMISSION,
TaskPageType.APPLY_DATABASE_PERMISSION,
TaskPageType.APPLY_TABLE_PERMISSION,
].includes(taskTabType)
? activeTaskLabel
: formatMessage(
{
id: 'odc.src.component.Task.component.TaskTable.NewActiveTasklabel',
defaultMessage: '新建{activeTaskLabel}',
},
{ activeTaskLabel },
),
//`新建${activeTaskLabel}`
isPrimary: true,
onClick: () => {
props.onMenuClick(taskTabType);
},
},
],
options: getOperationContentOption(),
isNeedOccupyElement: projectArchived,
}}
filterContent={{
enabledSearch: false,
Expand Down
29 changes: 28 additions & 1 deletion src/d.ts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3941,7 +3941,7 @@ export interface AgainTaskRecord {
id: string | number;
}

// 无锁结构变更任务进度状态
/** 无锁结构变更任务进度状态 */
export enum ProgressOfLocklessStructureChangeTaskStatusMap {
CREATE_GHOST_TABLES = 'CREATE_GHOST_TABLES', //'创建影子表'
CREATE_DATA_TASK = 'CREATE_DATA_TASK', //'创建数据迁移任务'
Expand All @@ -3951,3 +3951,30 @@ export enum ProgressOfLocklessStructureChangeTaskStatusMap {
SWAP_TABLE = 'SWAP_TABLE', // '切换中'
CLEAR_RESOURCE = 'CLEAR_RESOURCE', // '释放迁移任务资源'
}

interface UnfinishedTaskType {
approvable: boolean;
approveInstanceId: number;
candidateApprovers: {
id: number;
name: string;
accountName: string;
}[];
createTime: number;
creator: {
id: number;
name: string;
accountName: string;
roleNames: string[];
};
description: string;
id: number;
project: IProject;
status: TaskStatus;
type: TaskType;
}

export type UnfinishedTickets = {
unfinishedFlowInstances: UnfinishedTaskType[];
unfinishedSchedules: UnfinishedTaskType[];
};
6 changes: 6 additions & 0 deletions src/d.ts/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@
import { TablePermissionType } from '@/d.ts/table';
import { DatabasePermissionType } from './database';

export enum ProjectTabType {
/** 全部项目 */
ALL = 'all',
/** 归档项目 */
ARCHIVED = 'archived',
}
export enum ProjectRole {
DEVELOPER = 'DEVELOPER',
DBA = 'DBA',
Expand Down
Loading

0 comments on commit 4aca0f1

Please sign in to comment.