diff --git a/src/forge/DevOps/Manage/Params.jsx b/src/forge/DevOps/Manage/Params.jsx index 616e1227..8570643e 100644 --- a/src/forge/DevOps/Manage/Params.jsx +++ b/src/forge/DevOps/Manage/Params.jsx @@ -13,8 +13,8 @@ const Div = styled.div`{ min-height:420px; }`; function Params(props){ - const [ search ,setSearch ] = useState(undefined); const [ list ,setList ] = useState(undefined); + const [ editList ,setEditList ] = useState(undefined); const [ visible ,setVisible ] = useState(false); let projectsId = props.match.params.projectsId; @@ -37,12 +37,6 @@ function Params(props){ }).catch(error=>{}) } - // 搜索 - function searchValue(){ - - } - - const columns=[ { title:"参数名", @@ -50,18 +44,6 @@ function Params(props){ key:1, ellipsis:true }, - { - title:"参数值", - dataIndex:"data", - key:2, - ellipsis:true - }, - { - title:"仓库", - dataIndex:"repo", - key:3, - ellipsis:true - }, { title:"操作", dataIndex:"operation", @@ -70,7 +52,7 @@ function Params(props){ return( editMouldFunc(item)}>编辑 - deleteMouldFunc(item.id)} okText="确定" cancelText={"取消"}> + deleteMouldFunc(item.id,item.name)} okText="确定" cancelText={"取消"}> 删除 @@ -81,16 +63,36 @@ function Params(props){ // 编辑 function editMouldFunc(item){ - + setEditList(item); + setVisible(true); } // 删除 - function deleteMouldFunc(id){ - + function deleteMouldFunc(id,name){ + if(id && name){ + const url = `/ci/secrets/${id}/${name}.json`; + axios.delete(url,{ + params:{owner,repo:projectsId} + }).then(result=>{ + if(result){ + Init(); + props.showNotification(`参数删除成功!`); + } + }).catch(error=>{}) + } } - function successFunc(){ - + function successFunc(values,id){ + const url = `/ci/secrets.json?owner=${owner}&repo=${projectsId}`; + axios.post(url,{ + ...values,id + }).then(result=>{ + if(result){ + CancelFunc(); + props.showNotification(`${id ? '参数编辑':"新增参数"}成功!`); + Init(); + } + }).catch(error=>{}) } function CancelFunc(){ @@ -99,7 +101,7 @@ function Params(props){ return(
- + 工作流 - 参数管理 diff --git a/src/forge/DevOps/Manage/ParamsNew.jsx b/src/forge/DevOps/Manage/ParamsNew.jsx index 19605c00..0464faaa 100644 --- a/src/forge/DevOps/Manage/ParamsNew.jsx +++ b/src/forge/DevOps/Manage/ParamsNew.jsx @@ -3,18 +3,32 @@ import { Modal , Input , Form } from 'antd'; const { TextArea } = Input; -function ParamsNew({ form , visble,successFunc,CancelFunc}){ +function ParamsNew({ form , visble,successFunc,CancelFunc ,editList }){ const { getFieldDecorator, validateFields , setFieldsValue } = form; const layout = { labelCol: { span: 5 }, wrapperCol: { span: 18 }, }; + useEffect(()=>{ + if(editList && editList.id){ + setFieldsValue({ + name:editList.name, + data:editList.data + }) + }else{ + setFieldsValue({ + name:undefined, + data:undefined + }) + } + },[editList]) + // 确定 function onConfirmFunc(){ validateFields((error,values)=>{ if(!error){ - successFunc(values); + successFunc(values,editList && editList.id); } }) } @@ -38,7 +52,7 @@ function ParamsNew({ form , visble,successFunc,CancelFunc}){ )} - {getFieldDecorator("value",{ + {getFieldDecorator("data",{ rules:[{required:true,message:"请输入参数值"}] })(