From 45273782c5cd74d3d4dd7b47d71f144c228daefe Mon Sep 17 00:00:00 2001 From: caishi <1149225589@qq.com> Date: Mon, 28 Sep 2020 14:51:24 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B7=A5=E4=BD=9C=E6=B5=81=E6=B5=81=E7=A8=8B?= =?UTF-8?q?=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/AppConfig.js | 2 +- src/forge/DevOps/About.jsx | 10 +++--- src/forge/DevOps/Dispose.jsx | 2 +- src/forge/DevOps/Infos.jsx | 14 ++++++-- src/forge/DevOps/Structure.jsx | 23 ++++++++----- src/forge/Main/Detail.js | 2 +- src/forge/users/CIList.jsx | 62 ++++++++++++++++++++++++---------- src/forge/users/CIdispose.jsx | 6 ++-- 8 files changed, 82 insertions(+), 39 deletions(-) diff --git a/src/AppConfig.js b/src/AppConfig.js index 153780b3..a6200dbb 100644 --- a/src/AppConfig.js +++ b/src/AppConfig.js @@ -65,7 +65,7 @@ export function initAxiosInterceptors(props) { // TODO 避免重复的请求 https://github.com/axios/axios#cancellation var // proxy = "http://localhost:3000" - proxy = "https://forgeplus.trustie.net" + proxy = "https://testforgeplus.trustie.net" const requestMap = {}; window.setfalseInRequestMap = function (keyName) { diff --git a/src/forge/DevOps/About.jsx b/src/forge/DevOps/About.jsx index d8e62e89..64f60aef 100644 --- a/src/forge/DevOps/About.jsx +++ b/src/forge/DevOps/About.jsx @@ -98,7 +98,7 @@ function About(props, ref) { // 开始激活 function startActive(){ setIsSpining(true); - const url = `/${owner}/${projectsId}/cloud_accounts/${cloudAccount && cloudAccount.id}/activate.json`; + const url = `/${owner}/${projectsId}/activate.json`; axios.post(url).then(result=>{ setIsSpining(false); if(result && result.data.status === 0){ @@ -157,15 +157,15 @@ function About(props, ref) { 下一步 :""} - {step >= 1 &&( + {step >= 1 &&
- { + {/* { step === 1 && current_user && !current_user.ci_certification &&

初始化配置已完成,请前往:
{redirectUrl} 进入认证

- } + } */} 开始激活
- )} + } :"" } diff --git a/src/forge/DevOps/Dispose.jsx b/src/forge/DevOps/Dispose.jsx index f26cd760..b0349287 100644 --- a/src/forge/DevOps/Dispose.jsx +++ b/src/forge/DevOps/Dispose.jsx @@ -104,7 +104,7 @@ function Dispose(props){

{info}

{ const [ menu , setMenu ] = useState(false); + const childRef = useRef(); const path = props.location.pathname; const owner = props.match.params.owner; @@ -23,14 +24,23 @@ export default ((props)=>{ setMenu(false); } },[path]) + + const updateChildState = () => { + // changeVal就是子组件暴露给父组件的方法 + if (childRef.current) { + childRef.current.changeVal(); + } + } + return(
工作流配置 构建列表 + { menu===true && 刷新}
- { menu === true && } + { menu === true && childRef.current = form} ref={childRef}/> } { menu === false && }
diff --git a/src/forge/DevOps/Structure.jsx b/src/forge/DevOps/Structure.jsx index c782cc55..89ba01ca 100644 --- a/src/forge/DevOps/Structure.jsx +++ b/src/forge/DevOps/Structure.jsx @@ -1,9 +1,8 @@ -import React, { useState, useEffect } from "react"; -import { FlexAJ, AlignCenter, Blueback } from "../Component/layout"; +import React, { useState, useEffect , useImperativeHandle ,forwardRef } from "react"; +import { FlexAJ, AlignCenter } from "../Component/layout"; import { Table, Pagination, Popconfirm } from "antd"; import { truncateCommitId } from "../common/util"; import {getUrl} from 'educoder'; -import styled from "styled-components"; import axios from "axios"; const STATUS = [ @@ -14,7 +13,7 @@ const STATUS = [ { name: "已完成", value: "success" }, ]; const LIMIT = 15; -export default (props) => { +function Structure(props,ref){ const [status, setStatus] = useState(undefined); const [page, setPage] = useState(1); const [total, setTotal] = useState(0); @@ -24,6 +23,12 @@ export default (props) => { let projectsId = props.match.params.projectsId; let owner = props.match.params.owner; + useImperativeHandle(ref, () => ({ + changeVal: () => { + setTableLoading(true); + Init(); + } + })) useEffect(() => { if (projectsId) { Init(); @@ -290,7 +295,7 @@ export default (props) => { pagination={false} loading={tableLoading} > - {total > LIMIT ? ( + {total > LIMIT ?
{ pageSize={LIMIT} onChange={ChangePage} > -
- ) : ( - "" - )} + + : + "" } ); }; +export default forwardRef(Structure); diff --git a/src/forge/Main/Detail.js b/src/forge/Main/Detail.js index 9d12a23d..9d66e475 100644 --- a/src/forge/Main/Detail.js +++ b/src/forge/Main/Detail.js @@ -488,7 +488,7 @@ class Detail extends Component { }
  • - + 工作流 {projectDetail && projectDetail.ops_count ? {projectDetail.ops_count} : ""} diff --git a/src/forge/users/CIList.jsx b/src/forge/users/CIList.jsx index 7f48f6d1..7d678b93 100644 --- a/src/forge/users/CIList.jsx +++ b/src/forge/users/CIList.jsx @@ -1,5 +1,5 @@ import React , { useEffect , useState } from 'react'; -import { Button ,Spin , Pagination } from 'antd'; +import { Button ,Spin , Pagination , Popconfirm } from 'antd'; import { Link } from 'react-router-dom'; import Nodata from '../Nodata'; import axios from 'axios'; @@ -15,26 +15,43 @@ function CIList(props){ useEffect(()=>{ setIsSpining(true); if(user && user.login){ - const url = `/users/${user.login}/projects.json`; - axios.get(url,{ - params:{ - limit , page , category:"manage" - } - }).then(result=>{ - if(result && result.data){ - setList(result.data.projects); - setTotal(result.data.count); - setIsSpining(false); - } - }).catch(error=>{ - console.log(error); - }) + getInfo(); } },[user,page]) + function getInfo(){ + const url = `/users/${user.login}/projects.json`; + axios.get(url,{ + params:{ + limit , page , category:"manage" + } + }).then(result=>{ + if(result && result.data){ + setList(result.data.projects); + setTotal(result.data.count); + setIsSpining(false); + } + }).catch(error=>{ + console.log(error); + }) + } + function changePage(page){ setPage(page); } + + // 取消激活 + function cancelActivate(author,identifier){ + setIsSpining(true); + const url =`/${author && author.login}/${identifier}/deactivate.json`; + axios.delete(url).then(result=>{ + if(result){ + getInfo(); + }else{ + setIsSpining(false); + } + }).catch(error=>{setIsSpining(false);}) + } return(
    @@ -45,14 +62,25 @@ function CIList(props){ return(
  • - {item.name} + {item.name} { item.open_devops ? 已激活 : 未激活 } - { !item.open_devops && } + { item.open_devops ? + cancelActivate(item.author,item.identifier)} + okText="确定" + cancelText="取消" + > + + + : + + }
  • ) })} diff --git a/src/forge/users/CIdispose.jsx b/src/forge/users/CIdispose.jsx index bfd604e9..8e87ace3 100644 --- a/src/forge/users/CIdispose.jsx +++ b/src/forge/users/CIdispose.jsx @@ -54,7 +54,7 @@ function CIdispose(props){ getInit(); } }).catch(error=>{ - console.log(error); + setBindVisible(false); }) } @@ -141,12 +141,12 @@ function CIdispose(props){ CI服务器地址 {CIData && step >= 1 && {CIData.ip}} { step === 0 && 未绑定 } - { !ci_certification && 未认证 } + { step > 0 && !ci_certification && 未认证 } { ci_certification && 已认证 } { step === 0 && } - { !ci_certification && } + { step > 0 && !ci_certification && } { step >= 1 && }