diff --git a/src/forge/DevOps/Dispose.jsx b/src/forge/DevOps/Dispose.jsx index 358bbc7f..8290190a 100644 --- a/src/forge/DevOps/Dispose.jsx +++ b/src/forge/DevOps/Dispose.jsx @@ -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( @@ -116,9 +118,9 @@ function Dispose(props){
- { permission !=="Reporter" && (!list ||(list && list.length === 0)) && addNew(undefined,undefined)}>新增流水线 } + { operate && (!list ||(list && list.length === 0)) && addNew(undefined,undefined)}>新增流水线 }
- +
diff --git a/src/forge/DevOps/Dispose/Choosen.jsx b/src/forge/DevOps/Dispose/Choosen.jsx index e65a9b82..7cbef52b 100644 --- a/src/forge/DevOps/Dispose/Choosen.jsx +++ b/src/forge/DevOps/Dispose/Choosen.jsx @@ -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); diff --git a/src/forge/DevOps/Dispose/List.jsx b/src/forge/DevOps/Dispose/List.jsx index 76896b63..6ecdc566 100644 --- a/src/forge/DevOps/Dispose/List.jsx +++ b/src/forge/DevOps/Dispose/List.jsx @@ -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( - { permission !=="Reporter" && 编辑 } - { permission !=="Reporter" && - deleteFunc(item.id)} okText="确定" cancelText={"取消"}> - 删除 - + { operate ? + + 编辑 :"" } - 查看运行记录 + { operate ? + deleteFunc(item.id)} okText="确定" cancelText={"取消"}> + 删除 + :"" + } + 查看运行记录 ) } diff --git a/src/forge/DevOps/Dispose/PipelineName.jsx b/src/forge/DevOps/Dispose/PipelineName.jsx index 0f92f75a..be840621 100644 --- a/src/forge/DevOps/Dispose/PipelineName.jsx +++ b/src/forge/DevOps/Dispose/PipelineName.jsx @@ -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); diff --git a/src/forge/DevOps/Dispose/Stage.jsx b/src/forge/DevOps/Dispose/Stage.jsx index ab94001f..b24a76df 100644 --- a/src/forge/DevOps/Dispose/Stage.jsx +++ b/src/forge/DevOps/Dispose/Stage.jsx @@ -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); } // 点击下一步时 diff --git a/src/forge/DevOps/Dispose/StageItem.jsx b/src/forge/DevOps/Dispose/StageItem.jsx index 6a85d601..7317ee4c 100644 --- a/src/forge/DevOps/Dispose/StageItem.jsx +++ b/src/forge/DevOps/Dispose/StageItem.jsx @@ -33,7 +33,7 @@ function StageItem({item, templates,saveItems,k, slideItems , deleteStep}){
- +
) diff --git a/src/forge/DevOps/Dispose/Sure.jsx b/src/forge/DevOps/Dispose/Sure.jsx index 9de65c79..1195e1bd 100644 --- a/src/forge/DevOps/Dispose/Sure.jsx +++ b/src/forge/DevOps/Dispose/Sure.jsx @@ -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(
@@ -20,7 +24,7 @@ function Sure({datas , name , saveFunc , sureSubmit}){
- { value && } + { value && }
) diff --git a/src/forge/DevOps/disposePipeline.jsx b/src/forge/DevOps/disposePipeline.jsx index 0f644c2e..36fa0976 100644 --- a/src/forge/DevOps/disposePipeline.jsx +++ b/src/forge/DevOps/disposePipeline.jsx @@ -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" ? : - stageType === "confirm" ? + stageType === "confirm" ? : {});