Merge branch 'develop' into dev_orgnize

This commit is contained in:
caishi 2021-02-03 15:53:24 +08:00
commit 7a8cbac912
9 changed files with 93 additions and 33 deletions

View File

@ -39,7 +39,7 @@ function Dispose(props){
const url = `/ci/pipelines/list.json`;
axios.get(url,{
params:{
identifier:projectsId,
identifier:projectsId,owner,
page,limit
}
}).then(result=>{
@ -65,25 +65,33 @@ function Dispose(props){
}
},[owner,projectsId])
// 线
// /线
function addNew(pipeline_name,id,branch,event){
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);
}else{
setUpdateInfo(undefined);
}
}
function onOk(pipeline_name,updateId,branch,event){
if(pipeline_name){
let eventStr = "";
for(var i = 0;i<event.length;i++){
eventStr +=event[i]+",";
}
eventStr = 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:eventStr,owner
}).then(result=>{
setVisible(false);
if(result && result.data){
@ -97,7 +105,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:eventStr,owner
}).then(result=>{
if(result && result.data){
setVisible(false);
@ -126,7 +134,7 @@ function Dispose(props){
//
function toModalManage(){
props.history.push(`/projects/cxt/DevOps-mo/devops/mould`);
props.history.push(`/projects/${owner}/${projectsId}/devops/mould`);
}
const operate = current_user && (permission && permission !== "Reporter");

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(
@ -30,14 +29,25 @@ function List({ list, operate , projectsId , owner , showModal , deleteFunc }){
dataIndex:"file_name",
key:1,
width:"15%",
className:"color-blue",
ellipsis:true,
render:(value,item)=>{
return(
<Link to={`/projects/${owner}/${projectsId}/branch/${item.branch}?url=${value}`} className="color-blue">{value}</Link>
)
}
},
{
title:"触发分支",
dataIndex:"branch",
key:1,
width:"10%",
ellipsis:true
},
{
title:"创建时间",
dataIndex:"created_at",
title:"触发事件",
dataIndex:"event",
key:1,
width:"15%",
width:"10%",
ellipsis:true
},
{
@ -51,7 +61,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

@ -6,7 +6,7 @@ const EVENT = ["push","pull_request","tag","cron","custom","promote","rollback"]
function PipelineName({visible,onCancel,onOk,value ,branchList}){
const [ name , setName ] = useState(undefined);
const [ branchValue , setBranchValue ] = useState(undefined);
const [ eventValue , setEventValue ] = useState(EVENT[0]);
const [ eventValue , setEventValue ] = useState([EVENT[0]]);
useEffect(()=>{
if(branchList && branchList.length>0){
@ -19,6 +19,8 @@ function PipelineName({visible,onCancel,onOk,value ,branchList}){
setName(value.pipeline_name);
setBranchValue(value.branch);
setEventValue(value.event);
}else{
setName(undefined);
}
},[value])
@ -40,7 +42,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 +51,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])
@ -117,12 +120,14 @@ function Mould(props){
}
function onOk(){
Init(page,"all");
Init(page,stageType);
}
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,8 +12,9 @@ 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) => {
@ -21,9 +22,18 @@ function MouldNew({ form , visible , onCancel , onOk }, ref){
setFieldsValue({
...info
})
if(info.stage_type === "build"){
setBuildFlag(true);
setFieldsValue({
category:TYPE[0]
})
}else{
removeCate();
}
setValue(info.content);
setId(info.id);
}else{
removeCate();
clear();
setId(undefined);
}
@ -32,7 +42,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>
),
@ -58,7 +68,7 @@ function MouldNew({ form , visible , onCancel , onOk }, ref){
setIsSpin(true);
const url = `/ci/templates.json`;
axios.post(url,{
...values,id,content:value
...values,id,content:value,category:buildFlag ? values.category:""
}).then(result=>{
if(result && result.data){
setIsSpin(false);
@ -71,13 +81,31 @@ 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);
setFieldsValue({
category:TYPE[0]
})
}else{
removeCate();
}
}
function removeCate(){
setBuildFlag(false);
setFieldsValue({
category:""
})
}
return(
<Modal
visible={visible}
@ -93,24 +121,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 +146,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

@ -34,7 +34,7 @@ function disposePipeline(props){
function InitTemplates(){
const url = `/ci/templates/templates_by_stage.json`;
axios.get(url,{
params:{ stage_type:stageType }
params:{ stage_type:stageType, id:disposeId }
}).then(result=>{
if(result && result.data){
setTemplates(result.data);
@ -261,9 +261,8 @@ function disposePipeline(props){
//
function sureSubmit(){
setLoading(true);
const { defaultBranch } = props;
let params = {
branch: defaultBranch,
branch: datas.branch,
content:datas.content,
filepath:'.trustie-pipeline.yml',
message:'',

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;
}

View File

@ -87,7 +87,7 @@ export default (props) => {
</AlignCenter>
<Link
style={{ color: "#ddd" }}
to={`/projects/${owner}/${projectId}/devops/list`}
to={`/projects/${owner}/${projectId}/devops/dispose`}
>
<i className="iconfont icon-yiguanbi font-15 mr5"></i>退出
</Link>

View File

@ -62,7 +62,7 @@ function CIList(props){
return(
<li key={key}>
<span>
<Link to={`/projects/${item.author && item.author.login}/${item.identifier}${ item.open_devops ? "/devops/list":""}`}>{item.name}</Link>
<Link to={`/projects/${item.author && item.author.login}/${item.identifier}${ item.open_devops ? "/devops/dispose":""}`}>{item.name}</Link>
{ item.open_devops ?
<span className="authTag green ml20">已激活</span>
: