forked from Gitlink/forgeplus-react
合并develop
This commit is contained in:
parent
df438212c1
commit
a22b5b3701
|
@ -16,11 +16,12 @@ function Dispose(props){
|
|||
const [ spining , setSpining ] = useState(true);
|
||||
const [ updateInfo , setUpdateInfo ] = useState(undefined);
|
||||
const [ list , setList ] = useState(undefined);
|
||||
const [ permission , setPermission ] = useState("");
|
||||
const [ permission , setPermission ] = useState(undefined);
|
||||
const [ visible , setVisible ] = useState(false);
|
||||
|
||||
|
||||
const projectDetail = props.projectDetail;
|
||||
const current_user = props.current_user;
|
||||
let projectsId = props.match.params.projectsId;
|
||||
let owner = props.match.params.owner;
|
||||
|
||||
|
@ -109,6 +110,7 @@ function Dispose(props){
|
|||
}).catch(error=>{})
|
||||
}
|
||||
|
||||
const operate = current_user && (permission && permission !== "Reporter");
|
||||
|
||||
return(
|
||||
<Spin spinning={spining}>
|
||||
|
@ -116,9 +118,9 @@ function Dispose(props){
|
|||
<div className="disposePanel">
|
||||
<Head />
|
||||
<Div>
|
||||
{ permission !=="Reporter" && (!list ||(list && list.length === 0)) && <Blueback onClick={()=>addNew(undefined,undefined)}>新增流水线</Blueback> }
|
||||
{ operate && (!list ||(list && list.length === 0)) && <Blueback onClick={()=>addNew(undefined,undefined)}>新增流水线</Blueback> }
|
||||
<div className="mt20 disposeList">
|
||||
<List list={list} permission={permission} projectsId={projectsId} owner={owner} showModal={addNew} deleteFunc={deleteFunc}/>
|
||||
<List list={list} operate={operate} projectsId={projectsId} owner={owner} showModal={addNew} deleteFunc={deleteFunc}/>
|
||||
</div>
|
||||
</Div>
|
||||
</div>
|
||||
|
|
|
@ -17,21 +17,23 @@ function Choosen({ chooseFunc, temp , templateId , category }){
|
|||
setCate(category);
|
||||
}
|
||||
},[category])
|
||||
|
||||
|
||||
useEffect(()=>{
|
||||
if(temp && temp.length > 0){
|
||||
if(temp[0].category !== "初始化"){
|
||||
setCategories(temp)
|
||||
setCategories(temp);
|
||||
}else{
|
||||
setCategories(undefined);
|
||||
}
|
||||
setTemplates(temp[0].templates);
|
||||
setCate(temp[0].category);
|
||||
if(category && temp[0].category !== "初始化" && category !== "初始化"){
|
||||
let c = temp.filter(item=>item.category === category);
|
||||
let t = c && c.length > 0 && c[0].templates;
|
||||
setTemplates(t);
|
||||
setCate(category);
|
||||
}else{
|
||||
setTemplates(temp[0].templates);
|
||||
setCate(temp[0].category);
|
||||
}
|
||||
}else{
|
||||
setTemplates(undefined);
|
||||
|
@ -44,10 +46,15 @@ function Choosen({ chooseFunc, temp , templateId , category }){
|
|||
function changeCate(cate){
|
||||
setCate(cate);
|
||||
let c = categories && categories.filter(item=>item.category === cate);
|
||||
setTemplates(c && c[0].templates);
|
||||
chooseFunc && chooseFunc(undefined,undefined,cate);
|
||||
let t = c && c[0].templates;
|
||||
setTemplates(t);
|
||||
let m_t_id = t && t.length>0 && t[0].id;
|
||||
let m_t_content = t && t.length>0 && t[0].content;
|
||||
setTemId(m_t_id);
|
||||
chooseFunc && chooseFunc(m_t_content,m_t_id,cate);
|
||||
}
|
||||
|
||||
|
||||
// 选择模板
|
||||
function chooseOption(id){
|
||||
let item = templates.filter(item=>item.id === id);
|
||||
|
|
|
@ -2,7 +2,7 @@ import React from 'react';
|
|||
import { Table , Popconfirm } from 'antd';
|
||||
import { Link } from 'react-router-dom';
|
||||
|
||||
function List({ list, permission , projectsId , owner , showModal , deleteFunc }){
|
||||
function List({ list, operate , projectsId , owner , showModal , deleteFunc }){
|
||||
|
||||
const columns = [
|
||||
{
|
||||
|
@ -26,7 +26,7 @@ function List({ list, permission , projectsId , owner , showModal , deleteFunc }
|
|||
ellipsis:true
|
||||
},
|
||||
{
|
||||
title:"时间",
|
||||
title:"创建时间",
|
||||
dataIndex:"created_at",
|
||||
key:1,
|
||||
width:"18%",
|
||||
|
@ -40,13 +40,16 @@ function List({ list, permission , projectsId , owner , showModal , deleteFunc }
|
|||
render:(txt,item)=>{
|
||||
return(
|
||||
<span>
|
||||
{ permission !=="Reporter" && <Link to={`/projects/${owner}/${projectsId}/devops/dispose/${item.id}`} className="color-grey-6"><i className="iconfont iconzaibianji font-13 mr3"></i>编辑</Link> }
|
||||
{ permission !=="Reporter" &&
|
||||
<Popconfirm title={"确定要删除此流水线?"} onConfirm={()=>deleteFunc(item.id)} okText="确定" cancelText={"取消"}>
|
||||
<a className="ml10 color-grey-6"><i className="iconfont iconlajitong font-13 mr3"></i>删除</a>
|
||||
</Popconfirm>
|
||||
{ operate ?
|
||||
<Link to={`/projects/${owner}/${projectsId}/devops/dispose/${item.id}`} className="mr10 color-grey-6">
|
||||
<i className="iconfont iconzaibianji font-13 mr3"></i>编辑</Link> :""
|
||||
}
|
||||
<Link to={`/projects/${owner}/${projectsId}/devops/list`} className="ml10 color-grey-6"><i className="iconfont iconyunhang font-13 mr3"></i>查看运行记录</Link>
|
||||
{ operate ?
|
||||
<Popconfirm title={"确定要删除此流水线?"} onConfirm={()=>deleteFunc(item.id)} okText="确定" cancelText={"取消"}>
|
||||
<a className="mr10 color-grey-6"><i className="iconfont iconlajitong font-13 mr3"></i>删除</a>
|
||||
</Popconfirm>:""
|
||||
}
|
||||
<Link to={`/projects/${owner}/${projectsId}/devops/list`} className="color-grey-6"><i className="iconfont iconyunhang font-13 mr3"></i>查看运行记录</Link>
|
||||
</span>
|
||||
)
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ import { Modal , Input } from 'antd';
|
|||
function PipelineName({visible,onCancel,onOk,value}){
|
||||
const [ name , setName ] = useState(undefined);
|
||||
|
||||
console.log(value);
|
||||
useEffect(()=>{
|
||||
if(value){
|
||||
setName(value.pipeline_name);
|
||||
|
|
|
@ -9,14 +9,12 @@ function Stage({
|
|||
saveDatas ,
|
||||
saveFunc ,
|
||||
stepName ,
|
||||
showNotification ,
|
||||
deleteStep ,
|
||||
deleteFunc ,
|
||||
deleteFlag
|
||||
}){
|
||||
const [ stepList , setStepList ] = useState(undefined);
|
||||
const [ temp , setTemp ] = useState(undefined);
|
||||
const [ saveFlag , setSaveFlag ] = useState(true);
|
||||
|
||||
useEffect(()=>{
|
||||
if(templates && templates.length > 0){
|
||||
|
@ -32,30 +30,27 @@ function Stage({
|
|||
let list = [];
|
||||
setStepList(list);
|
||||
}
|
||||
setSaveFlag(true);
|
||||
}
|
||||
},[datas])
|
||||
|
||||
// 添加步骤
|
||||
function addFunc(){
|
||||
if(saveFlag){
|
||||
let list = stepList;
|
||||
let length = list ? list.length : 0;
|
||||
let step =
|
||||
{
|
||||
"category":undefined,
|
||||
"step_name": stepName+`${length + 1}`,
|
||||
"show_index": length + 1,
|
||||
"content":undefined,
|
||||
"template_id":undefined,
|
||||
"hide":false
|
||||
}
|
||||
list.push(step);
|
||||
saveDatas(list);
|
||||
setSaveFlag(false);
|
||||
}else{
|
||||
showNotification(`请先选择模板!`);
|
||||
let list = stepList;
|
||||
let length = list ? list.length : 0;
|
||||
let pre = temp && temp.length > 0 && temp[0];
|
||||
let c = pre && pre.category;
|
||||
let child = pre && pre.templates && pre.templates.length > 0 && pre.templates[0];
|
||||
let step =
|
||||
{
|
||||
"category":c,
|
||||
"step_name": stepName+`${length + 1}`,
|
||||
"show_index": length + 1,
|
||||
"content":child.content,
|
||||
"template_id":child.id,
|
||||
"hide":false
|
||||
}
|
||||
list.push(step);
|
||||
saveDatas(list);
|
||||
}
|
||||
|
||||
// 将修改的对应项保存在数组中
|
||||
|
@ -65,7 +60,6 @@ function Stage({
|
|||
item[key].template_id = id;
|
||||
item[key].category = cate;
|
||||
saveDatas([...item]);
|
||||
setSaveFlag((id && content) ? true:false);
|
||||
}
|
||||
|
||||
function slideItems(key,hide){
|
||||
|
@ -76,7 +70,6 @@ function Stage({
|
|||
}
|
||||
|
||||
function deleteItem(id,key){
|
||||
setSaveFlag(true);
|
||||
deleteStep(id,key);
|
||||
}
|
||||
// 点击下一步时
|
||||
|
|
|
@ -33,7 +33,7 @@ function StageItem({item, templates,saveItems,k, slideItems , deleteStep}){
|
|||
</FlexAJ>
|
||||
<div className={(!item.hide || item.hide === false) ? "stepsBody active" : "stepsBody"}>
|
||||
<Choosen chooseFunc={chooseFunc} category={item.category} templateId={item.template_id} temp={templates}/>
|
||||
<Editors value={item.content} onChange={onChangevalue} theme="vs-dark" height="120px" />
|
||||
<Editors value={item.content} onChange={onChangevalue} theme="vs-dark" height="180px" />
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
|
|
@ -2,13 +2,17 @@ import React ,{useEffect , useState} from 'react';
|
|||
import { Button } from 'antd';
|
||||
import Editors from './Editors';
|
||||
|
||||
function Sure({datas , name , saveFunc , sureSubmit}){
|
||||
function Sure({datas , name , saveFunc , sureSubmit , loading}){
|
||||
const [ value , setValue ] = useState(undefined);
|
||||
useEffect(()=>{
|
||||
if(datas && datas.content){
|
||||
setValue(datas.content)
|
||||
}
|
||||
},[datas])
|
||||
},[datas]);
|
||||
|
||||
function sure(){
|
||||
sureSubmit();
|
||||
}
|
||||
|
||||
return(
|
||||
<div>
|
||||
|
@ -20,7 +24,7 @@ function Sure({datas , name , saveFunc , sureSubmit}){
|
|||
</div>
|
||||
<div className="mt20">
|
||||
<Button type={"primary"} onClick={()=>saveFunc(undefined,undefined,undefined,undefined,"last")}>上一步</Button>
|
||||
{ value && <Button type={"primary"} className="ml20" onClick={sureSubmit}>确定提交</Button> }
|
||||
{ value && <Button type={"primary"} loading={loading} className="ml20" onClick={sure}>确定提交</Button> }
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
|
|
@ -19,6 +19,7 @@ function disposePipeline(props){
|
|||
const [ datas , setDatas ] = useState(undefined);
|
||||
const [ templates , setTemplates] = useState(undefined);
|
||||
const [ datasUpdataFlag , setDatasUpdataFlag ] = useState(false);
|
||||
const [ loading ,setLoading ] = useState(false);
|
||||
|
||||
const { disposeId } = props.match.params;
|
||||
let projectsId = props.match.params.projectsId;
|
||||
|
@ -259,6 +260,7 @@ function disposePipeline(props){
|
|||
|
||||
// 确认提交
|
||||
function sureSubmit(){
|
||||
setLoading(true);
|
||||
let sync = datas.sync || 0;
|
||||
let url = '';
|
||||
const { defaultBranch } = props;
|
||||
|
@ -280,8 +282,10 @@ function disposePipeline(props){
|
|||
if(result){
|
||||
props.history.push(`/projects/${owner}/${projectsId}/devops/dispose`);
|
||||
}
|
||||
setLoading(false);
|
||||
}).catch(error=>{
|
||||
console.log(error);
|
||||
setLoading(false);
|
||||
})
|
||||
}else{
|
||||
url = `/ci/pipelines/${disposeId}/create_trustie_pipeline.json`;
|
||||
|
@ -289,8 +293,10 @@ function disposePipeline(props){
|
|||
if(result){
|
||||
props.history.push(`/projects/${owner}/${projectsId}/devops/dispose`);
|
||||
}
|
||||
setLoading(false);
|
||||
}).catch(error=>{
|
||||
console.log(error);
|
||||
setLoading(false);
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -305,7 +311,7 @@ function disposePipeline(props){
|
|||
{
|
||||
stageType === "init" ? <Init stage_type={stageType} templates={templates} datas={datas} saveDatas={saveDatas} saveFunc={saveFunc}/>
|
||||
:
|
||||
stageType === "confirm" ? <Sure sureSubmit={sureSubmit} name={pipeLineName} datas={datas} saveFunc={saveFunc}/>
|
||||
stageType === "confirm" ? <Sure sureSubmit={sureSubmit} name={pipeLineName} datas={datas} saveFunc={saveFunc} loading={loading}/>
|
||||
:
|
||||
<Stage {...props}
|
||||
stepName={stepName}
|
||||
|
|
|
@ -49,7 +49,6 @@ export default Form.create()(
|
|||
setOptions(enable_push);
|
||||
setMergeOptions(protected_branch.enable_merge_whitelist);
|
||||
setApproveOptions(protected_branch.enable_approvals_whitelist);
|
||||
console.log("111",getFieldsValue("enable_status_check"));
|
||||
}
|
||||
}
|
||||
}).catch(error=>{});
|
||||
|
|
Loading…
Reference in New Issue