forgeplus-react/src/forge/DevOps/Dispose/List.jsx

138 lines
3.7 KiB
React
Raw Normal View History

2021-01-19 18:11:38 +08:00
import React from 'react';
import { Table , Popconfirm } from 'antd';
2021-01-11 17:18:12 +08:00
import { Link } from 'react-router-dom';
2021-01-06 16:03:50 +08:00
2021-03-05 18:35:54 +08:00
// const STATUS = {
// running:"运行中",
// failure:"未通过",
// error:"未通过",
// success:"已通过",
// killed:"已撤销",
// pending:"准备中"
// }
function turnbar(str){
if(str && str.length>0 && str.indexOf("/")>-1){
return str.replaceAll('/','%2F');
}
return str;
}
2021-03-05 09:56:07 +08:00
function renderTableStatus(status) {
switch (status) {
case "running":
return (
<span className="statusTag running">
<i className="iconfont icon-yunhangzhong"></i>运行中
</span>
);
case "failure": case 'error':
return (
<span className="statusTag failed">
<i className="iconfont icon-weitongguo"></i>未通过
</span>
);
case "success":
return (
<span className="statusTag pass">
<i className="iconfont icon-yitongguo"></i>已通过
</span>
);
case 'killed':
return (
<span className="statusTag killed">
<i className="iconfont icon-weitongguo"></i>已撤销
</span>
);
2021-03-05 18:35:54 +08:00
default :
2021-03-05 09:56:07 +08:00
return (
<span className="statusTag Preparing">
<i className="iconfont icon-zhunbeizhong"></i>准备中
</span>
);
}
}
2021-01-20 15:22:37 +08:00
function List({ list, operate , projectsId , owner , showModal , deleteFunc }){
2021-03-05 09:56:07 +08:00
2021-01-06 16:03:50 +08:00
const columns = [
{
title:"流水线名称",
2021-01-13 15:46:17 +08:00
dataIndex:"pipeline_name",
2021-01-06 16:03:50 +08:00
key:1,
2021-01-19 18:11:38 +08:00
ellipsis:true,
render:(txt,item)=>{
return(
2021-01-29 14:17:49 +08:00
<span onDoubleClick={()=>showModal(txt,item.id,item.branch,item.event)} style={{display:"block",cursor:"pointer"}}>{txt}</span>
2021-01-19 18:11:38 +08:00
)
}
2021-01-06 16:03:50 +08:00
},
{
title:"文件名称",
2021-01-13 15:46:17 +08:00
dataIndex:"file_name",
2021-01-06 16:03:50 +08:00
key:1,
2021-01-29 14:17:49 +08:00
width:"15%",
2021-02-01 15:28:24 +08:00
ellipsis:true,
render:(value,item)=>{
let v = turnbar(item.branch);
2021-02-01 15:28:24 +08:00
return(
<Link to={`/projects/${owner}/${projectsId}/tree/${v}/${value}`} className="color-blue">{value}</Link>
2021-02-01 15:28:24 +08:00
)
}
2021-01-06 16:03:50 +08:00
},
{
2021-02-01 11:10:51 +08:00
title:"触发分支",
dataIndex:"branch",
2021-01-06 16:03:50 +08:00
key:1,
2021-02-01 11:10:51 +08:00
width:"10%",
ellipsis:true
},
{
title:"触发事件",
dataIndex:"event",
key:1,
width:"10%",
2021-01-29 14:17:49 +08:00
ellipsis:true
},
{
title:"最近构建时间",
dataIndex:"last_build_time",
key:1,
width:"15%",
2021-01-06 16:03:50 +08:00
ellipsis:true
},
2021-01-29 14:17:49 +08:00
{
title:"最近构建状态",
dataIndex:"pipeline_status",
key:1,
2021-03-05 09:56:07 +08:00
width:"12%",
2021-01-29 14:17:49 +08:00
ellipsis:true,
render:(txt)=>{
2021-03-05 09:56:07 +08:00
return renderTableStatus(txt)
2021-01-29 14:17:49 +08:00
}
},
2021-01-06 16:03:50 +08:00
{
title:"操作",
dataIndex:"operation",
key:1,
2021-01-29 14:17:49 +08:00
width:"21%",
2021-01-06 16:03:50 +08:00
render:(txt,item)=>{
return(
<span>
2021-01-20 15:22:37 +08:00
{ operate ?
<Link to={`/projects/${owner}/${projectsId}/devops/dispose/${item.id}`} className="mr10 color-grey-6">
2021-01-20 20:14:39 +08:00
<i className="iconfont icon-zaibianji font-13 mr3"></i>编辑</Link> :""
2021-01-20 15:22:37 +08:00
}
{ operate ?
2021-01-19 18:11:38 +08:00
<Popconfirm title={"确定要删除此流水线?"} onConfirm={()=>deleteFunc(item.id)} okText="确定" cancelText={"取消"}>
2021-01-20 20:14:39 +08:00
<a className="mr10 color-grey-6"><i className="iconfont icon-lajitong font-13 mr3"></i>删除</a>
2021-01-20 15:22:37 +08:00
</Popconfirm>:""
2021-01-19 18:11:38 +08:00
}
2021-01-29 14:17:49 +08:00
<Link to={`/projects/${owner}/${projectsId}/devops/list/${item.branch}`} className="color-grey-6"><i className="iconfont icon-yunhang font-13 mr3"></i>查看运行记录</Link>
2021-01-06 16:03:50 +08:00
</span>
)
}
}
]
return(
2021-01-11 17:18:12 +08:00
<Table size="small" columns={columns} dataSource={list} rowKey={(row)=>row.id} pagination={false}></Table>
2021-01-06 16:03:50 +08:00
)
}
export default List;