This commit is contained in:
caishi 2021-01-13 14:21:12 +08:00
parent d8d464a332
commit c746e9e634
1 changed files with 23 additions and 17 deletions

View File

@ -40,6 +40,7 @@ class MessageCount extends Component {
SpinMerge: false,
edit_spin: false,
pr_status: undefined,
pull_request:undefined,
copyVisible:false,
};
@ -69,11 +70,12 @@ class MessageCount extends Component {
axios
.get(url)
.then((result) => {
if (result) {
if (result && result.data) {
this.setState({
data: result.data,
SpinFlag: false,
pr_status: result.data && result.data.pull_request && result.data.pull_request.status,
pr_status: result.data.pull_request && result.data.pull_request.status,
pull_request:result.data.pull_request
});
} else {
this.setState({ SpinFlag: false });
@ -120,12 +122,12 @@ class MessageCount extends Component {
SpinMerge: true,
});
const { projectsId , owner } = this.props.match.params;
const { data, title, body, mergekey, pr_status } = this.state;
const url = `/${owner}/${projectsId}/pulls/${data.pull_request.id}/pr_merge.json`;
const { title, body, mergekey, pull_request } = this.state;
const url = `/${owner}/${projectsId}/pulls/${pull_request.id}/pr_merge.json`;
axios
.post(url, {
project_id: projectsId,
id: data.pull_request.id,
id: pull_request.id,
do: mergekey,
body: body,
title: title,
@ -249,9 +251,15 @@ class MessageCount extends Component {
isSpin,
ismesrge,
SpinFlag,
copyVisible
copyVisible,
pull_request
} = this.state;
const { current_user, projectDetail } = this.props;
const permission = projectDetail && (projectDetail.permission === "Admin" || projectDetail.permission === "Owner");
const userLogin = current_user && current_user.login && (pull_request && pull_request.create_user === current_user.login);
const operate = current_user && projectDetail && pr_status === 0 && (permission || userLogin);
const menu = (
<Menu onClick={(e) => this.getOption(e)}>
<Menu.Item key={"merge"} value="合并请求">
@ -280,13 +288,13 @@ class MessageCount extends Component {
<div className="ver-middle">
<span className="mr10 ver-middle">
<span className="font-18 fwb">
{data.issue.subject}
{ data.issue && data.issue.subject}
</span>
</span>
{data.pull_request && (
{pull_request && (
<Tag
className={`pr_tags_${data.pull_request.pull_request_staus}`}
className={`pr_tags_${pull_request.pull_request_staus}`}
>
{pr_status === 1
? "已合并"
@ -300,10 +308,10 @@ class MessageCount extends Component {
<div className="mt15">
<Tag className="pr-branch-tag">
<Link
to={`/projects/${owner}/${data.pull_request.is_original?data.pull_request.identifier:projectsId}/branch/${data.pull_request.head}`}
to={`/projects/${owner}/${pull_request.is_original?data.project_identifier:projectsId}/branch/${pull_request.head}`}
className="ver-middle"
>
{data.pull_request.is_original ? data.pull_request.fork_project_user : data.issue.project_author_name}:{data.pull_request.head}
{pull_request.is_original ? pull_request.fork_project_user : data.issue.project_author_name}:{pull_request.head}
</Link>
</Tag>
<span className="mr8 ver-middle">
@ -315,11 +323,11 @@ class MessageCount extends Component {
</span>
<Tag className="pr-branch-tag">
<Link
to={`/projects/${owner}/${projectsId}/branch/${data.pull_request.base}`}
to={`/projects/${owner}/${projectsId}/branch/${pull_request.base}`}
className="ver-middle"
>
{/* {data.pull_request.is_fork ? data.pull_request.base : `${data.pull_request.pull_request_user}:${data.pull_request.base}`} */}
{data.issue.project_author_name}:{data.pull_request.base}
{data.issue.project_author_name}:{pull_request.base}
</Link>
</Tag>
</div>
@ -401,9 +409,7 @@ class MessageCount extends Component {
</Dropdown>
<span>下载为<i className="iconfont icon-sanjiaoxing-down color-blue"></i></span>
</span> */}
{current_user && projectDetail &&
pr_status === 0 &&
projectDetail.permission !=="Reporter" && (
{operate && (
<Button
type="green"
ghost
@ -413,7 +419,7 @@ class MessageCount extends Component {
编辑
</Button>
)}
{projectDetail && projectDetail.permission !=="Reporter" && pr_status === 0 && (
{operate && (
<Button
type="danger"
ghost