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

65 lines
2.0 KiB
React
Raw Normal View History

2021-01-13 15:46:17 +08:00
import React , { useEffect , useState } from 'react';
2021-01-29 14:17:49 +08:00
import { Modal , Input , Select } from 'antd';
const { Option }= Select;
2021-01-13 15:46:17 +08:00
2021-01-29 14:17:49 +08:00
const EVENT = ["push","pull_request","tag","cron","custom","promote","rollback"]
function PipelineName({visible,onCancel,onOk,value ,branchList}){
2021-01-13 15:46:17 +08:00
const [ name , setName ] = useState(undefined);
2021-01-29 14:17:49 +08:00
const [ branchValue , setBranchValue ] = useState(undefined);
const [ eventValue , setEventValue ] = useState(EVENT[0]);
useEffect(()=>{
if(branchList && branchList.length>0){
setBranchValue(branchList[0].name);
}
},[branchList])
2021-01-13 15:46:17 +08:00
2021-01-19 18:11:38 +08:00
useEffect(()=>{
if(value){
setName(value.pipeline_name);
2021-01-29 14:17:49 +08:00
setBranchValue(value.branch);
setEventValue(value.event);
2021-01-19 18:11:38 +08:00
}
},[value])
2021-01-13 15:46:17 +08:00
function onSure(){
2021-01-29 14:17:49 +08:00
onOk(name,value && value.id,branchValue,eventValue);
2021-01-13 15:46:17 +08:00
}
return(
<Modal
visible={visible}
title="流水线名称"
width={"500px"}
onCancel={onCancel}
onOk={onSure}
centered={true}
>
<div className="choosenList">
<span>流水线名称:</span>
<Input value={name} onChange={(e)=>setName(e.target.value)} placeholder="请输入名称" style={{width:"340px",margin:"6px 0px"}}/>
</div>
2021-01-29 14:17:49 +08:00
<div className="choosenList mt20">
<span>触发条件:</span>
2021-02-01 11:10:51 +08:00
<Select value={branchValue} style={{width:"150px"}} onChange={(e)=>setBranchValue(e)}>
2021-01-29 14:17:49 +08:00
{
branchList && branchList.length>0 && branchList.map((item,key)=>{
return(
<Option value={item.name} key={key}>{item.name}</Option>
)
})
}
</Select>
2021-02-01 11:10:51 +08:00
<Select mode="multiple" allowClear value={eventValue} style={{width:"180px",marginLeft:"10px"}} onChange={(e)=>{console.log(e);setEventValue(e)}}>
2021-01-29 14:17:49 +08:00
{
EVENT.map((item,key)=>{
return(
<Option value={item} key={key}>{item}</Option>
)
})
}
</Select>
</div>
2021-01-13 15:46:17 +08:00
</Modal>
)
}
export default PipelineName;