2020-08-09 22:39:58 +08:00
|
|
|
|
import React, { useEffect, useState } from "react";
|
2020-07-31 20:15:28 +08:00
|
|
|
|
import { FlexAJ, Blueline, AlignCenter } from "../Component/layout";
|
|
|
|
|
|
import styled from "styled-components";
|
2020-08-09 22:39:58 +08:00
|
|
|
|
import { Menu, Popconfirm } from "antd";
|
2020-07-31 20:15:28 +08:00
|
|
|
|
import { TagsLine } from "../Component/OpsStatus";
|
|
|
|
|
|
import { Time } from "../Utils/Time";
|
|
|
|
|
|
import { truncateCommitId } from "../common/util";
|
2022-01-14 17:33:25 +08:00
|
|
|
|
import { getImageUrl } from 'educoder';
|
2020-07-31 20:15:28 +08:00
|
|
|
|
|
2020-07-13 15:17:28 +08:00
|
|
|
|
const SubMenu = Menu.SubMenu;
|
2020-07-31 20:15:28 +08:00
|
|
|
|
const Img = styled.img`
|
|
|
|
|
|
{
|
|
|
|
|
|
width: 25px;
|
|
|
|
|
|
height: 25px;
|
|
|
|
|
|
border-radius: 50%;
|
|
|
|
|
|
margin-right: 10px;
|
|
|
|
|
|
}
|
|
|
|
|
|
`;
|
2020-08-26 16:09:27 +08:00
|
|
|
|
export default ({ data, repeatSet , chooseSteps }) => {
|
2020-08-09 22:39:58 +08:00
|
|
|
|
const [tamp, setTamp] = useState(undefined);
|
|
|
|
|
|
const [sha, setSha] = useState(undefined);
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
if (data && data.started) {
|
2020-07-31 20:15:28 +08:00
|
|
|
|
let t = parseInt(data.started) * 1000;
|
|
|
|
|
|
let time = Time(t);
|
|
|
|
|
|
setTamp(time);
|
|
|
|
|
|
}
|
2020-08-09 22:39:58 +08:00
|
|
|
|
if (data && data.after) {
|
2020-07-31 20:15:28 +08:00
|
|
|
|
setSha(truncateCommitId(data.after));
|
|
|
|
|
|
}
|
2020-08-09 22:39:58 +08:00
|
|
|
|
}, [data]);
|
|
|
|
|
|
|
2020-08-26 16:09:27 +08:00
|
|
|
|
function renderStatusBtn() {
|
|
|
|
|
|
let status = data && data.status;
|
|
|
|
|
|
let number = data && data.number;
|
|
|
|
|
|
if (status === "failure" || status === "error" || status === "success") {
|
|
|
|
|
|
return "";
|
|
|
|
|
|
}else if(status === "killed"){
|
|
|
|
|
|
return(
|
|
|
|
|
|
<Popconfirm
|
|
|
|
|
|
title="确认重新构建?"
|
|
|
|
|
|
onConfirm={(e) => repeatSet(e,'repeat',number)}
|
|
|
|
|
|
onCancel={(e)=>{e.stopPropagation()}}
|
|
|
|
|
|
cancelText="取消"
|
|
|
|
|
|
okText="确定"
|
|
|
|
|
|
>
|
|
|
|
|
|
<Blueline onClick={(e)=>{e.stopPropagation()}}>重新构建</Blueline>
|
|
|
|
|
|
</Popconfirm>
|
|
|
|
|
|
);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
return (
|
|
|
|
|
|
<Popconfirm
|
|
|
|
|
|
title="确认撤销构建?"
|
|
|
|
|
|
onConfirm={(e) => repeatSet(e,'cancel',number)}
|
|
|
|
|
|
onCancel={(e)=>{e.stopPropagation()}}
|
|
|
|
|
|
cancelText="取消"
|
|
|
|
|
|
okText="确定"
|
|
|
|
|
|
>
|
|
|
|
|
|
<Blueline onClick={(e)=>{e.stopPropagation()}}>撤销构建</Blueline>
|
|
|
|
|
|
</Popconfirm>
|
|
|
|
|
|
);
|
2020-08-09 22:39:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-08-27 15:15:03 +08:00
|
|
|
|
function clickSub(e,stageN,stepN){
|
|
|
|
|
|
chooseSteps(stageN,stepN);
|
2020-08-09 22:39:58 +08:00
|
|
|
|
}
|
2020-07-31 20:15:28 +08:00
|
|
|
|
|
|
|
|
|
|
return (
|
2020-07-13 15:17:28 +08:00
|
|
|
|
<div>
|
|
|
|
|
|
<FlexAJ className="leftheader">
|
|
|
|
|
|
<AlignCenter>
|
2022-01-14 17:33:25 +08:00
|
|
|
|
<Img src={getImageUrl(`/${data && data.author && data.author.image_url}`)} />
|
2020-09-11 17:35:05 +08:00
|
|
|
|
{data && data.started &&
|
2020-08-26 16:09:27 +08:00
|
|
|
|
<span className="nest">
|
|
|
|
|
|
开始时间:<span> {data.started}</span>
|
|
|
|
|
|
</span>
|
|
|
|
|
|
}
|
|
|
|
|
|
{
|
|
|
|
|
|
data && data.duration_time &&
|
2020-07-31 20:15:28 +08:00
|
|
|
|
<span className="nest">
|
2020-08-26 16:09:27 +08:00
|
|
|
|
运行时间:<span>{data.duration_time}</span>
|
2020-07-31 20:15:28 +08:00
|
|
|
|
</span>
|
2020-08-26 16:09:27 +08:00
|
|
|
|
}
|
2020-07-13 15:17:28 +08:00
|
|
|
|
</AlignCenter>
|
2020-08-26 16:09:27 +08:00
|
|
|
|
{renderStatusBtn()}
|
2020-07-13 15:17:28 +08:00
|
|
|
|
</FlexAJ>
|
|
|
|
|
|
<div className="leftMainContent">
|
|
|
|
|
|
<AlignCenter className="contentBranch">
|
|
|
|
|
|
<i className="iconfont icon-fenzhi1"></i>
|
|
|
|
|
|
<span>分支:</span>
|
2020-08-26 16:09:27 +08:00
|
|
|
|
<span className="branchname">{data && data.branch_target}</span>
|
|
|
|
|
|
<span className="branchsha">{data && truncateCommitId(data.build_after_sha)}</span>
|
2020-07-13 15:17:28 +08:00
|
|
|
|
</AlignCenter>
|
|
|
|
|
|
</div>
|
2020-09-10 09:47:09 +08:00
|
|
|
|
<Menu mode="inline" className="leftMenu" defaultOpenKeys={[`0`]} defaultSelectedKeys={[`0`]}>
|
2020-08-26 16:09:27 +08:00
|
|
|
|
{data && data.stages ? data.stages.map((item, key) => {
|
|
|
|
|
|
return item.steps && item.steps.length > 0 ?
|
|
|
|
|
|
<SubMenu
|
|
|
|
|
|
title={
|
|
|
|
|
|
<div>
|
|
|
|
|
|
<i className="iconfont icon-gongzuoliu font-14 mr4"></i>
|
|
|
|
|
|
<span>{item.name}</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
}
|
2020-09-09 16:50:48 +08:00
|
|
|
|
key={`${key}`}
|
2020-08-26 16:09:27 +08:00
|
|
|
|
>
|
|
|
|
|
|
{item.steps.map((i, k) => {
|
|
|
|
|
|
return (
|
2020-09-09 16:50:48 +08:00
|
|
|
|
<Menu.Item key={`${k}`} onClick={(e)=>clickSub(e,item.number,i.id)}>
|
2020-08-26 16:09:27 +08:00
|
|
|
|
<FlexAJ>
|
|
|
|
|
|
<span>
|
|
|
|
|
|
{i.name} {i.status ? TagsLine(i.status) : ""}
|
|
|
|
|
|
</span>
|
|
|
|
|
|
<span>{i.duration_time}</span>
|
|
|
|
|
|
</FlexAJ>
|
|
|
|
|
|
</Menu.Item>
|
|
|
|
|
|
);
|
|
|
|
|
|
})}
|
|
|
|
|
|
</SubMenu>
|
|
|
|
|
|
: "";
|
|
|
|
|
|
})
|
|
|
|
|
|
: ""}
|
2020-07-13 15:17:28 +08:00
|
|
|
|
</Menu>
|
|
|
|
|
|
</div>
|
2020-07-31 20:15:28 +08:00
|
|
|
|
);
|
|
|
|
|
|
};
|