Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
db8572a
添加删除操作确认弹窗
Faberiii Jun 8, 2022
de3ec13
只显示未禁用的项目
Faberiii Jun 8, 2022
5e2a4da
添加删除团队功能
Faberiii Jun 8, 2022
b56a914
添加删除团队项目功能
Faberiii Jun 8, 2022
6540d62
只显示未禁用项目的代码库
Faberiii Jun 8, 2022
676d9aa
添加删除代码库功能
Faberiii Jun 8, 2022
8071eb8
添加删除分支项目功能
Faberiii Jun 9, 2022
5c6cac5
后台管理添加团队管理和项目管理
Faberiii Jun 9, 2022
6780616
优化显示样式及文字描述
Faberiii Jun 9, 2022
2eb21e7
置顶用户管理
Faberiii Jun 9, 2022
00bd80d
Merge pull request #23 from Faberiii/feature/logical-deletion
nickcdon Jun 9, 2022
3bd7398
Merge branch 'Tencent:main' into main
nickcdon Jun 10, 2022
3270830
代码库登记与展示补充信息
Faberiii Jun 14, 2022
01a9183
Merge pull request #24 from Faberiii/feature/more-info
nickcdon Jun 14, 2022
dabdd71
Merge branch 'Tencent:main' into main
nickcdon Jun 14, 2022
c1ffe1d
优化删除操作
Faberiii Jun 15, 2022
77b2b6b
Merge pull request #25 from Faberiii/feature/more-info
nickcdon Jun 15, 2022
707f4fa
Merge branch 'Tencent:main' into main
nickcdon Jun 15, 2022
703df10
修正仓库信息编辑表单
Faberiii Jun 16, 2022
d7c3fc0
Merge pull request #26 from Faberiii/feature/more-info
nickcdon Jun 16, 2022
fbbf791
Merge remote-tracking branch 'upstream/main'
Jun 17, 2022
762a308
调整表格、表单显示
Faberiii Jun 17, 2022
f7cd531
Merge pull request #27 from Faberiii/feature/more-info
nickcdon Jun 17, 2022
34ca0ca
:bento: web 打包构建资源
Jun 17, 2022
dead6ae
Merge branch 'Tencent:main' into main
nickcdon Jun 17, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 106 additions & 0 deletions web/packages/tca-analysis/src/components/delete-modal/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
// Copyright (c) 2021-2022 THL A29 Limited
//
// This source code file is made available under MIT License
// See LICENSE for details
// ==============================================================================

/**
* 确认删除操作弹框
*/

import React, { useEffect, useState } from 'react';
import { Modal, Form, Input, message, Button } from 'coding-oa-uikit';
import { t } from '@src/i18n/i18next';

import s from './style.scss';

interface DeleteModalProps {
actionType: string;
objectType: string;
confirmName: string;
visible: boolean;
addtionInfo?: string;
onCancel: () => void;
onOk: () => void;
}

const DeleteModal = ({ actionType, objectType, confirmName, addtionInfo='', visible, onCancel, onOk }: DeleteModalProps) => {
const [form] = Form.useForm();
const [confirmed, setConfirmed] = useState<boolean>(true);

useEffect(() => {
visible && form.resetFields();
visible && setConfirmed(false);
}, [visible]);

/**
* 表单提交操作
* @param formData 参数
*/
const onSubmitHandle = () => {
form.validateFields().then((formData) => {
if (formData?.confirm === confirmName) {
onOk();
} else {
message.error(t('验证失败,请重新输入'));
}
});
};

const checkConfirm = (changedValues: any) => {
if (changedValues?.confirm === confirmName) {
setConfirmed(true);
} else {
setConfirmed(false);
}
};

return (
<Modal
title={`${actionType}${objectType}`}
visible={visible}
onCancel={onCancel}
className={s.deleteModal}
footer={[
<Button
key="submit"
type="primary"
disabled={!confirmed}
danger
onClick={onSubmitHandle}
>
{t('确认')}{actionType}
</Button>,
<Button
key="back"
className="cancle-btn"
onClick={onCancel}
>
{t('取消')}
</Button>,
]}
>
<p className={s.warningMessage}>
{t('您正在')}{actionType}{objectType} <span className={s.confirmText}>{confirmName}</span>{' '}<br/>
</p>
{addtionInfo && <p className={s.warningMessage}>{addtionInfo}</p>}
<p className={s.confirmMessage}>{t(`为确认${actionType}操作,请输入您要${actionType}的`)}{objectType}</p>
<Form
layout="vertical"
form={form}
onValuesChange={checkConfirm}
>
<Form.Item
label=''
name="confirm"
rules={[{ required: true, message: t('必须输入确认信息!') }]}
className={s.confirmInput}
>
<Input placeholder={confirmName} />
</Form.Item>
</Form>
</Modal>
);
};

export default DeleteModal;
21 changes: 21 additions & 0 deletions web/packages/tca-analysis/src/components/delete-modal/style.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.delete-modal {

.warning-message {
margin-bottom: 20px;
}

.confirm-message {
margin-bottom: 8px;
font-weight: 600;
}

.confirm-text {
background-color: #ebedf1;
font-weight: 500;
padding: 0 6px;
}

.confirm-input {
margin-bottom: 0px;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@
// ==============================================================================

import React, { useState, useEffect } from 'react';
import { useParams } from 'react-router-dom';
import { useParams, useHistory } from 'react-router-dom';
import { Form, Button, Input, message } from 'coding-oa-uikit';
import { pick } from 'lodash';
import { pick, get, find } from 'lodash';
import { useSelector } from 'react-redux';

// 项目内
import { getProjectListRouter, getProjectOverviewRouter } from '@src/utils/getRoutePath';
import { t } from '@src/i18n/i18next';
import { formatDateTime, getUserName } from '@src/utils';
import { getProjectTeam, putProjectTeam } from '@src/services/common';
import { getProjectTeam, putProjectTeam, disableProject} from '@src/services/common';
import DeleteModal from '@src/components/delete-modal';

const layout = {
labelCol: { span: 6 },
Expand All @@ -23,6 +26,14 @@ const Overview = () => {
const [team, setTeam] = useState<any>({});
const [edit, setEdit] = useState(false);
const { org_sid: orgSid, team_name: teamName }: any = useParams();
// 判断是否有权限删除团队项目
const history: any = useHistory();
const APP = useSelector((state: any) => state.APP);
const isSuperuser = get(APP, 'user.is_superuser', false); // 当前用户是否是超级管理员
const userName = get(APP, 'user.username', null);
const isAdmin = !!find(team?.admins, { username: userName }); // 当前用户是否是项目管理员
const deletable = isAdmin || isSuperuser; // 删除权限
const [deleteVisible, setDeleteVisible] = useState<boolean>(false);

// 重置
const onReset = () => {
Expand All @@ -39,6 +50,9 @@ const Overview = () => {
message.success(t('项目信息更新成功'));
setTeam(response);
onReset();
if (values.name !== teamName) {
history.replace(getProjectOverviewRouter(orgSid, values.name));
}
});
};

Expand All @@ -55,8 +69,28 @@ const Overview = () => {
}
}, [orgSid, teamName]);

const handleDeleteTeam = () => {
disableProject(orgSid, teamName, {status: 2}).then(() => {
message.success('项目已禁用');
history.push(getProjectListRouter(orgSid));
}).finally(() => setDeleteVisible(false));
};

const onDelete = () => {
setDeleteVisible(true);
};

return (
<div className="pa-lg">
<DeleteModal
actionType={t('禁用')}
objectType={t('项目')}
addtionInfo={t('后续如需恢复项目,请联系平台管理员在管理后台恢复')}
confirmName={teamName}
visible={deleteVisible}
onCancel={() => setDeleteVisible(false)}
onOk={handleDeleteTeam}
/>
<h3 className="mb-md">{t('项目概览')}</h3>
<Form
{...layout}
Expand All @@ -65,7 +99,10 @@ const Overview = () => {
initialValues={team}
onFinish={values => onFinish(values)}
>
<Form.Item label={t('项目唯一标识')} name="name">
<Form.Item
label={t('项目唯一标识')}
name="name"
>
<span>{team.name}</span>
</Form.Item>
<Form.Item
Expand Down Expand Up @@ -105,6 +142,9 @@ const Overview = () => {
{t('编辑')}
</Button>
)}
{deletable && <Button className="ml-12" htmlType="button" onClick={onDelete} danger type='primary'>
{t('禁用项目')}
</Button>}
</div>
</Form>
</div>
Expand Down
Loading