diff --git a/src/AppConfig.js b/src/AppConfig.js index a369d843..a5a063b0 100644 --- a/src/AppConfig.js +++ b/src/AppConfig.js @@ -4,10 +4,10 @@ import { broadcastChannelOnmessage, isDev, queryString } from 'educoder'; import { notification } from 'antd'; import cookie from 'react-cookies'; import './index.css'; -let message501 = false; +let message501 = false; broadcastChannelOnmessage('refreshPage', () => { - window.location.reload() + window.location.reload(); }) function locationurl(list) { @@ -54,10 +54,8 @@ setpostcookie(); window._debugType = debugType; export function initAxiosInterceptors(props) { - initOnlineOfflineListener() - // TODO 避免重复的请求 https://github.com/axios/axios#cancellation - var - proxy = "http://localhost:3000"; + initOnlineOfflineListener(); + var proxy = "http://localhost:3000"; proxy = "https://testforgeplus.trustie.net"; const requestMap = {}; diff --git a/src/forge/Component/Handbook.jsx b/src/forge/Component/Handbook.jsx index bcb38187..d26c0a8f 100644 --- a/src/forge/Component/Handbook.jsx +++ b/src/forge/Component/Handbook.jsx @@ -5,7 +5,7 @@ import './Component.scss'; export default (()=>{ return(
- +
diff --git a/src/forge/DevOps/About.jsx b/src/forge/DevOps/About.jsx index d3e5c184..ba4c7667 100644 --- a/src/forge/DevOps/About.jsx +++ b/src/forge/DevOps/About.jsx @@ -1,9 +1,10 @@ import React, { forwardRef, useCallback, useState , useEffect } from "react"; import activate from "../Images/activate.png"; -import { Blueback , AlignCenter } from "../Component/layout"; +import { AlignCenter, Blueback } from "../Component/layout"; import PasswordAuthority from "../Component/PasswordAuthority"; import styled from "styled-components"; -import { Form, Input , Spin , Modal } from "antd"; +import { Form, Input , Spin , Button } from "antd"; +import ServiceModal from './ServiceModal'; import axios from "axios"; const P = styled.p` @@ -20,15 +21,20 @@ const P = styled.p` function About(props, ref) { const { form: { getFieldDecorator, validateFields , setFieldsValue } } = props; const [isSpining, setIsSpining] = useState(true); - const [ authorityValBox , setAuthorityValBox ] = useState(false); + + // 认证密码 const [ authorityVal , setAuthorityVal ] = useState(undefined); const [ authorityValFlag , setAuthorityValFlag ] = useState(false); + //0: 标识未开启devops //1: 标识用户已填写了云服务器相关信息,但并未开启认证 - const [step, setStep] = useState(undefined); - // step大于1时:为true,不能再修改服务器信息 + const [step, setStep] = useState(0); + const owner = props.match.params.owner; + const { user } = props; const projectsId = props.match.params.projectsId; + const [ disabled, setDisabled ] = useState(false); + const [ typeFlag, setTypeFlag] = useState(false); const AuthorLogin = props.author && props.author.login; @@ -47,12 +53,17 @@ function About(props, ref) { method:`${type}`, url }).then(result=>{ + setIsSpining(false); if(result && result.data ){ - setIsSpining(false); setStep(result.data.step); - setFieldsValue({...result.data.cloud_account}); + // setStep(0); + // setFieldsValue({...result.data.cloud_account}); + // if(result.data.cloud_account){ + // setDisabled(true); + // } } }).catch(error=>{ + setIsSpining(false); console.log(error); }) } @@ -72,8 +83,8 @@ function About(props, ref) { function goStep() { validateFields((error, values) => { if (!error) { - if(step > 0){ - setAuthorityValBox(true); + if(disabled){ + setStep(1); }else{ setIsSpining(true); const url = `/${owner}/${projectsId}/cloud_accounts.json`; @@ -82,7 +93,6 @@ function About(props, ref) { if (result && result.data.redirect_url) { props.showNotification("服务器信息配置完成!"); setStep(1); - setAuthorityValBox(true); } }) .catch((error) => { @@ -94,6 +104,50 @@ function About(props, ref) { }); } + // 选择服务器后调用接口,点击下一步(1是自有服务器,2是trustie服务器) + function sureModal(type){ + if(type === 2){ + setTypeFlag(false); + setIsSpining(true); + const url = `/users/ci/cloud_account/trustie_bind.json`; + axios.post(url,{ + account:user && user.login + }).then(result=>{ + setIsSpining(false); + if(result && result.data){ + setStep(result.data.step); + } + }).catch(error=>{setIsSpining(false)}) + }else{ + setTypeFlag(true); + } + } + + // 上一步 + function goUpStep(step){ + setTypeFlag(false); + setStep(step); + } + + // 输入用户密码后下一步 + function authStep(){ + if(!authorityVal){ + setAuthorityValFlag(true); + return; + } + setAuthorityValFlag(false); + setIsSpining(true); + const url = `/users/ci/oauth_grant.json`; + axios.get(url,{ + params:{password:authorityVal} + }).then(result=>{ + setIsSpining(false); + if(result){ + setStep(result.data.step); + } + }).catch(error=>{setIsSpining(false)}); + } + // 开始激活 function startActive(){ setIsSpining(true); @@ -111,18 +165,10 @@ function About(props, ref) { setIsSpining(false); }) } - // 取消授权-登录密码的输入 - function cancelAuthority(){ - setAuthorityValBox(false); - } - // 确认授权 - function okAuthority(step){ - setAuthorityValBox(false); - setStep(step); - } + return ( - + {/* */}

定义DevOps工作流,帮助您检测bug、发布代码…

@@ -139,45 +185,69 @@ function About(props, ref) { { AuthorLogin === CurrentLogin ? - { step <=1 ? - - -
-

请仔细核对您的服务器信息,一旦确认提交将无法修改

- {helper( - "服务器IP地址:", - "ip", - [{ required: true, message: "请输入服务器IP地址" }], - 0} - />, - true - )} - {helper( - "服务器用户名:", - "account", - [{ required: true, message: "请输入服务器用户名" }], - 0}/>, - true - )} - {helper( - "服务器密码:", - "secret", - [{ required: true, message: "请输入服务器密码" }], - 0}/>, - true - )} - - 下一步 -
- :""} - {step > 1 && + { + step === 0 && !typeFlag ? + + :"" + } + { typeFlag ? + + +
+

请仔细核对您的服务器信息,一旦确认提交将无法修改

+ {helper( + "服务器IP地址:", + "ip", + [{ required: true, message: "请输入服务器IP地址" }], + , + true + )} + {helper( + "服务器用户名:", + "account", + [{ required: true, message: "请输入服务器用户名" }], + , + true + )} + {helper( + "服务器密码:", + "secret", + [{ required: true, message: "请输入服务器密码" }], + , + true + )} + + + { !disabled && } + 下一步 + +
+ :"" + } + { + step === 1 ? +
+ + 密码: +
+ setAuthorityVal(e.target.value)} style={{width:"220px"}}> +

您已保存相关服务器信息,请输入密码,
确认授权DevOps应用

+
+
+ + 下一步 + +
:"" + } + { step === 2 ?
开始激活 -
+
:"" } :"" diff --git a/src/forge/DevOps/Index.jsx b/src/forge/DevOps/Index.jsx index 77b82eb0..23e36d69 100644 --- a/src/forge/DevOps/Index.jsx +++ b/src/forge/DevOps/Index.jsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React , { useEffect } from 'react'; import { WhiteBack } from '../Component/layout'; import './ops.scss'; @@ -15,6 +15,20 @@ const Infos = Loadable({ loading: Loading, }) export default ((props)=>{ + const { projectsId , owner } = props.match.params; + const open_devops = props.projectDetail && props.projectDetail.open_devops; + + // 工作流:两种状态进入的链接不同 + useEffect(()=>{ + if(open_devops !== undefined){ + if(open_devops){ + props.history.replace(`/projects/${owner}/${projectsId}/devops/list`); + }else{ + props.history.replace(`/projects/${owner}/${projectsId}/devops`); + } + } + },[open_devops]) + return( diff --git a/src/forge/DevOps/ServiceModal.jsx b/src/forge/DevOps/ServiceModal.jsx new file mode 100644 index 00000000..3fac8bc9 --- /dev/null +++ b/src/forge/DevOps/ServiceModal.jsx @@ -0,0 +1,21 @@ +import React, { useState } from 'react'; +import { Radio , Button } from 'antd'; + +function ServiceModal({sureModal}){ + const [ type , setType ] = useState(1); + + function changeType(e){ + setType(e.target.value); + } + + return( +
+ + 自有服务器 + Trustie服务器 + +

+
+ ) +} +export default ServiceModal; \ No newline at end of file diff --git a/src/forge/Main/Detail.js b/src/forge/Main/Detail.js index 920db676..baa6169d 100644 --- a/src/forge/Main/Detail.js +++ b/src/forge/Main/Detail.js @@ -199,17 +199,6 @@ class Detail extends Component { platform:result.data.platform && result.data.platform !== 'educoder' }) - // 工作流:两种状态进入的链接不同 - const pathname = this.props.history.location.pathname; - let p = checkPathname(pathname); - if(p==="devops"){ - if(result.data.open_devops && pathname === `/projects/${owner}/${projectsId}/devops`){ - this.props.history.push(`/projects/${owner}/${projectsId}/devops/list`); - }else if(result.data.open_devops===false && pathname !== `/projects/${owner}/${projectsId}/devops`){ - this.props.history.push(`/projects/${owner}/${projectsId}/devops`); - } - } - if (result.data.type !== 0 && result.data.mirror_status === 1) { console.log("--------start channel --------"); // 是镜像项目,且未完成迁移 @@ -459,14 +448,15 @@ class Detail extends Component { {watched ? '取消关注' : '关注'} { + watchers_count > 0 ? platform ? {watchers_count} : {watchers_count} + :"" } - this.pariseFunc(praised)}> @@ -474,11 +464,13 @@ class Detail extends Component { {praised ? '取消点赞' : '点赞'} { + praises_count > 0 ? platform ? {praises_count} : {praises_count} + :"" } @@ -486,12 +478,14 @@ class Detail extends Component { 复刻 (Fork) { + forked_count > 0 ? platform ? {forked_count} : - {praises_count} + {forked_count} + :"" } diff --git a/src/forge/Settings/Index.js b/src/forge/Settings/Index.js index 4a22b3d3..1e294b35 100644 --- a/src/forge/Settings/Index.js +++ b/src/forge/Settings/Index.js @@ -43,8 +43,8 @@ class Index extends Component { const flag = pathname === `/projects/${owner}/${projectsId}/setting`; return ( -
-
+ +
  • @@ -101,9 +101,9 @@ class Index extends Component {

  • */}
-
-
-
+ + + {/* 协作者 */} -
-
-
+ + + ); } } diff --git a/src/forge/users/CIdispose.jsx b/src/forge/users/CIdispose.jsx index a0692de7..03c841f5 100644 --- a/src/forge/users/CIdispose.jsx +++ b/src/forge/users/CIdispose.jsx @@ -4,17 +4,20 @@ import { AlignCenter } from '../Component/layout'; import axios from 'axios'; import Modals from '../Component/Modal'; import PasswordAuthority from '../Component/PasswordAuthority'; +import Service from './Service'; const TIPS = "解除CI服务器绑定后,您所有的项目构建数据将被清空。确定解除绑定?"; function CIdispose(props){ const [ CIData , setCIData ] = useState(undefined); const [ step , setStep ] = useState(0); const [ visible, setVisible ] = useState(false); + const [ serviceVisible , setServiceVisible ] = useState(false); const [ bindVisible, setBindVisible ] = useState(false); const [ ci_certification, setCi_certification ] = useState(false); const [ btnLoading , setBtnLoading ] = useState(false); const [ authorityValBox , setAuthorityValBox] = useState(false); + const { user } = props; const { form: { getFieldDecorator, validateFields , setFieldsValue } } = props; const helper = useCallback( @@ -105,8 +108,28 @@ function CIdispose(props){ setAuthorityValBox(false); } + // 确认选择服务器 + function SureBtn(type){ + if(type === 1){ + setServiceVisible(false); + setBindVisible(true); + }else{ + const url = `/users/ci/cloud_account/trustie_bind.json`; + axios.post(url,{ + account:user && user.login + }).then(result=>{ + if(result && result.data){ + setServiceVisible(false); + setAuthorityValBox(true); + getInit(); + } + }).catch(error=>{setServiceVisible(false)}) + } + } + return(
+ {setServiceVisible(false)}}> @@ -155,12 +179,12 @@ function CIdispose(props){ CI服务器地址 {CIData && step >= 1 && {CIData.ip}} { step === 0 && 未绑定 } - { step > 0 && !ci_certification && 未认证 } + { step === 1 && !ci_certification && 未认证 } { ci_certification && 已认证 } - { step === 0 && } - { step > 0 && !ci_certification && } + { step === 0 && } + { step === 1 && !ci_certification && } { step >= 1 && }
diff --git a/src/forge/users/Service.jsx b/src/forge/users/Service.jsx new file mode 100644 index 00000000..a3a2fcc3 --- /dev/null +++ b/src/forge/users/Service.jsx @@ -0,0 +1,15 @@ +import React from 'react'; +import ServiceModal from '../DevOps/ServiceModal'; +import { Modal } from 'antd'; + +function Service ({visible, SureBtn , CancelBtn }){ + function SureModal(type){ + SureBtn(type); + } + return( + + + + ) +} +export default Service; \ No newline at end of file