This commit is contained in:
caishi 2021-02-01 11:10:51 +08:00
parent 5181d636d9
commit eee8d4659c
6 changed files with 68 additions and 21 deletions

View File

@ -70,20 +70,26 @@ function Dispose(props){
setVisible(true);
setUpdateInfo(undefined);
if(pipeline_name){
let l = {pipeline_name,id,branch,event}
let eventA = event.split(",");
let l = {pipeline_name,id,branch,event:eventA}
setUpdateInfo(l);
}
}
function onOk(pipeline_name,updateId,branch,event){
if(pipeline_name){
let eventStr = "";
for(var i = 0;i<event.length;i++){
eventStr +=event[i]+",";
}
let s = eventStr.substring(0,eventStr.length-1);
if(!updateId){
//
const url = `/ci/pipelines.json`;
axios.post(url,{
pipeline_name,
file_name:".trustie-pipeline.yml",
repo:projectsId,branch,event,owner
repo:projectsId,branch,event:s,owner
}).then(result=>{
setVisible(false);
if(result && result.data){
@ -97,7 +103,7 @@ function Dispose(props){
//
const url = `/ci/pipelines/${updateId}.json`;
axios.put(url,{
pipeline_name,repo:projectsId,branch,event,owner
pipeline_name,repo:projectsId,branch,event:s,owner
}).then(result=>{
if(result && result.data){
setVisible(false);

View File

@ -17,7 +17,6 @@ function List({ list, operate , projectsId , owner , showModal , deleteFunc }){
title:"流水线名称",
dataIndex:"pipeline_name",
key:1,
width:"19%",
ellipsis:true,
render:(txt,item)=>{
return(
@ -34,10 +33,17 @@ function List({ list, operate , projectsId , owner , showModal , deleteFunc }){
ellipsis:true
},
{
title:"创建时间",
dataIndex:"created_at",
title:"触发分支",
dataIndex:"branch",
key:1,
width:"15%",
width:"10%",
ellipsis:true
},
{
title:"触发事件",
dataIndex:"event",
key:1,
width:"10%",
ellipsis:true
},
{
@ -51,7 +57,7 @@ function List({ list, operate , projectsId , owner , showModal , deleteFunc }){
title:"最近构建状态",
dataIndex:"pipeline_status",
key:1,
width:"15%",
width:"10%",
ellipsis:true,
render:(txt)=>{
return(STATUS[txt])

View File

@ -40,7 +40,7 @@ function PipelineName({visible,onCancel,onOk,value ,branchList}){
</div>
<div className="choosenList mt20">
<span>触发条件:</span>
<Select value={branchValue} style={{width:"160px"}} onChange={(e)=>setBranchValue(e)}>
<Select value={branchValue} style={{width:"150px"}} onChange={(e)=>setBranchValue(e)}>
{
branchList && branchList.length>0 && branchList.map((item,key)=>{
return(
@ -49,7 +49,7 @@ function PipelineName({visible,onCancel,onOk,value ,branchList}){
})
}
</Select>
<Select value={eventValue} style={{width:"160px",marginLeft:"20px"}} onChange={(e)=>setEventValue(e)}>
<Select mode="multiple" allowClear value={eventValue} style={{width:"180px",marginLeft:"10px"}} onChange={(e)=>{console.log(e);setEventValue(e)}}>
{
EVENT.map((item,key)=>{
return(

View File

@ -1,6 +1,7 @@
import React , { useEffect , useState , useRef } from 'react';
import { Banner , Blueback , FlexAJ , Spin } from '../Component/layout';
import { Banner , Blueback , FlexAJ } from '../Component/layout';
import { Input , Table ,Pagination , Select , Popconfirm } from 'antd';
import { Link } from 'react-router-dom'
import styled from 'styled-components';
import axios from 'axios';
import New from './MouldNew';
@ -27,6 +28,8 @@ function Mould(props){
const [ stageType ,setStageType ] = useState("all");
const [ search ,setSearch ] = useState(undefined);
const childRef = useRef();
let projectsId = props.match.params.projectsId;
let owner = props.match.params.owner;
useEffect(()=>{
Init(page,stageType);
},[page,stageType])
@ -122,7 +125,9 @@ function Mould(props){
return(
<div>
<New wrappedComponentRef={(f) => childRef.current = f} ref={childRef} visible={visible} onCancel={()=>setVisible(false)} onOk={onOk}></New>
<Banner>工作流 - 模板管理</Banner>
<Banner>
<FlexAJ><span>工作流 - 模板管理</span><Link to={`/projects/${owner}/${projectsId}/devops/dispose`} className="font-14 color-grey-9">返回</Link></FlexAJ>
</Banner>
<Div className="disposeList">
<FlexAJ>
<Blueback onClick={newMouldFunc}>新建模板</Blueback>

View File

@ -12,18 +12,25 @@ function MouldNew({ form , visible , onCancel , onOk }, ref){
const [isSpin , setIsSpin ] = useState(false);
const [valueFlag , setValueFlag ] = useState(false);
const [ id , setId ] = useState(false);
const [ buildFlag , setBuildFlag ] = useState(false);
const { getFieldDecorator, validateFields , setFieldsValue , getFieldsValue } = form;
const { getFieldDecorator, validateFields , setFieldsValue } = form;
useImperativeHandle(ref, () => ({
setEditInfo: (info) => {
if(info){
if(info.stage_type === "build"){
setBuildFlag(true);
}else{
removeCate();
}
setFieldsValue({
...info
})
setValue(info.content);
setId(info.id);
}else{
removeCate();
clear();
setId(undefined);
}
@ -32,7 +39,7 @@ function MouldNew({ form , visible , onCancel , onOk }, ref){
const helper = useCallback(
(label, name, rules, widget, className, isRequired,flag) => (
<Form.Item label={label} >
<Form.Item label={label} className={className}>
{getFieldDecorator(name, { rules, validateFirst: true , valuePropName:flag ? "checked":"value" })(widget)}
</Form.Item>
),
@ -71,13 +78,28 @@ function MouldNew({ form , visible , onCancel , onOk }, ref){
}
function clear(){
setFieldsValue({
stage_type:"all",
stage_type:"init",
template_name:undefined,
category:"Java",
})
setValue("");
setValueFlag(false);
}
function changeStage(e){
if(e === "build"){
setBuildFlag(true);
}else{
removeCate();
}
}
function removeCate(){
setBuildFlag(false);
setFieldsValue({
category:""
})
}
return(
<Modal
visible={visible}
@ -93,24 +115,23 @@ function MouldNew({ form , visible , onCancel , onOk }, ref){
"所属阶段",
"stage_type",
[{required:true,message:"请选择所属阶段"}],
<Select placeholder="请选择所属阶段" style={{width:"350px"}}>
<Option value="all">所有</Option>
<Select placeholder="请选择所属阶段" style={{width:"350px"}} onChange={(e)=>{changeStage(e)}}>
<Option value="init">初始化</Option>
<Option value="build">编译构建</Option>
<Option value="deploy">部署</Option>
<Option value="customize">其他</Option>
</Select>,true
</Select>
)}
{helper(
"模板名称",
"template_name",
[{required:true,message:"请输入模板名称"}],
<Input placeholder="请输入模板名称" style={{width:"350px"}}/>,true
<Input placeholder="请输入模板名称" style={{width:"350px"}}/>
)}
{helper(
"模板分类",
"category",
[{required:true,message:"请选择模板分类"}],
[{required:buildFlag,message:"请选择模板分类"}],
<Select placeholder="请选择模板分类" style={{width:"350px"}}>
{
TYPE.map((item,key)=>{
@ -119,7 +140,7 @@ function MouldNew({ form , visible , onCancel , onOk }, ref){
)
})
}
</Select>,true
</Select>,buildFlag===true ? "" :"hide"
)}
<div style={{display:'flex',justifyContent:"flex-start"}}>
<span><span className="color-red">* </span>模板内容</span>

View File

@ -454,6 +454,12 @@
background-color: #1890FF;
}
}
.ant-select-selection.ant-select-selection--multiple{
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
height: 35px;
}
}
.addBtn{
display: block;
@ -500,4 +506,7 @@
width: 336px!important;
}
}
}
.hide{
display: none!important;
}