From 05080e79483972652e00f142d5245534094cff82 Mon Sep 17 00:00:00 2001
From: caishi <1149225589@qq.com>
Date: Thu, 31 Dec 2020 13:58:44 +0800
Subject: [PATCH 1/4] =?UTF-8?q?=E5=B7=A5=E4=BD=9C=E6=B5=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/AppConfig.js | 2 +-
src/forge/Component/Handbook.jsx | 2 +-
src/forge/DevOps/About.jsx | 184 +++++++++++++++++++++---------
src/forge/DevOps/ServiceModal.jsx | 21 ++++
src/forge/users/CIdispose.jsx | 30 ++++-
src/forge/users/Service.jsx | 15 +++
6 files changed, 192 insertions(+), 62 deletions(-)
create mode 100644 src/forge/DevOps/ServiceModal.jsx
create mode 100644 src/forge/users/Service.jsx
diff --git a/src/AppConfig.js b/src/AppConfig.js
index a369d843..a212448f 100644
--- a/src/AppConfig.js
+++ b/src/AppConfig.js
@@ -27,7 +27,7 @@ if (isDev) {
}
debugType = window.location.search.indexOf('debug=t') !== -1 ? 'teacher' :
window.location.search.indexOf('debug=s') !== -1 ? 'student' :
- window.location.search.indexOf('debug=a') !== -1 ? 'admin' : parsed.debug || 'admin'
+ window.location.search.indexOf('debug=a') !== -1 ? 'admin' : parsed.debug || 'student'
}
function clearAllCookie() {
cookie.remove('_educoder_session', { path: '/' });
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 ?
-
-
-
- 下一步
-
- :""}
- {step > 1 &&
+ {
+ step === 0 && !typeFlag ?
+
+ :""
+ }
+ { typeFlag ?
+
+
+
+
+ { !disabled && }
+ 下一步
+
+
+ :""
+ }
+ {
+ step === 1 ?
+
+
+ 密码:
+
+
setAuthorityVal(e.target.value)} style={{width:"220px"}}>
+
您已保存相关服务器信息,请输入密码,
确认授权DevOps应用
+
+
+
+ 下一步
+
+
:""
+ }
+ { step === 2 ?
开始激活
-
+ :""
}
:""
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/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
From bbe3766a40087d20865eae02ca4be31b33e9ebf3 Mon Sep 17 00:00:00 2001
From: caishi <1149225589@qq.com>
Date: Tue, 5 Jan 2021 10:32:50 +0800
Subject: [PATCH 2/4] =?UTF-8?q?=E5=B7=A5=E4=BD=9C=E6=B5=81=E5=B7=B2?=
=?UTF-8?q?=E5=BC=80=E5=90=AF=E5=92=8C=E6=9C=AA=E5=BC=80=E5=90=AF=E4=B8=A4?=
=?UTF-8?q?=E7=A7=8D=E7=8A=B6=E6=80=81=E9=93=BE=E6=8E=A5=E8=B7=B3=E8=BD=AC?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/forge/DevOps/Index.jsx | 16 +++++++++++++++-
src/forge/Main/Detail.js | 11 -----------
2 files changed, 15 insertions(+), 12 deletions(-)
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/Main/Detail.js b/src/forge/Main/Detail.js
index 920db676..ad0f709e 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 --------");
// 是镜像项目,且未完成迁移
From 05ded946624a39e54e95f7bda2da8384c216766d Mon Sep 17 00:00:00 2001
From: caishi <1149225589@qq.com>
Date: Tue, 5 Jan 2021 14:27:35 +0800
Subject: [PATCH 3/4] save
---
src/AppConfig.js | 9 ++++-----
src/forge/Settings/Index.js | 16 ++++++++--------
2 files changed, 12 insertions(+), 13 deletions(-)
diff --git a/src/AppConfig.js b/src/AppConfig.js
index a212448f..1aaa2371 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) {
@@ -27,7 +27,7 @@ if (isDev) {
}
debugType = window.location.search.indexOf('debug=t') !== -1 ? 'teacher' :
window.location.search.indexOf('debug=s') !== -1 ? 'student' :
- window.location.search.indexOf('debug=a') !== -1 ? 'admin' : parsed.debug || 'student'
+ window.location.search.indexOf('debug=a') !== -1 ? 'admin' : parsed.debug || 'admin'
}
function clearAllCookie() {
cookie.remove('_educoder_session', { path: '/' });
@@ -54,8 +54,7 @@ setpostcookie();
window._debugType = debugType;
export function initAxiosInterceptors(props) {
- initOnlineOfflineListener()
- // TODO 避免重复的请求 https://github.com/axios/axios#cancellation
+ initOnlineOfflineListener();
var
proxy = "http://localhost:3000";
proxy = "https://testforgeplus.trustie.net";
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 (
-
+
+
+
);
}
}
From 502dfde9a21cf8b739072de0c6214d307aa47c4f Mon Sep 17 00:00:00 2001
From: caishi <1149225589@qq.com>
Date: Tue, 5 Jan 2021 15:31:26 +0800
Subject: [PATCH 4/4] =?UTF-8?q?=E8=AF=A6=E6=83=85=E9=A1=B6=E9=83=A8-?=
=?UTF-8?q?=E4=B8=BA0=E6=97=B6=E4=B8=8D=E6=98=BE=E7=A4=BA?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/AppConfig.js | 3 +--
src/forge/Main/Detail.js | 9 +++++++--
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/src/AppConfig.js b/src/AppConfig.js
index 1aaa2371..a5a063b0 100644
--- a/src/AppConfig.js
+++ b/src/AppConfig.js
@@ -55,8 +55,7 @@ setpostcookie();
window._debugType = debugType;
export function initAxiosInterceptors(props) {
initOnlineOfflineListener();
- var
- proxy = "http://localhost:3000";
+ var proxy = "http://localhost:3000";
proxy = "https://testforgeplus.trustie.net";
const requestMap = {};
diff --git a/src/forge/Main/Detail.js b/src/forge/Main/Detail.js
index ad0f709e..baa6169d 100644
--- a/src/forge/Main/Detail.js
+++ b/src/forge/Main/Detail.js
@@ -448,14 +448,15 @@ class Detail extends Component {
{watched ? '取消关注' : '关注'}
{
+ watchers_count > 0 ?
platform ?
{watchers_count}
:
{watchers_count}
+ :""
}
-
this.pariseFunc(praised)}>
@@ -463,11 +464,13 @@ class Detail extends Component {
{praised ? '取消点赞' : '点赞'}
{
+ praises_count > 0 ?
platform ?
{praises_count}
:
{praises_count}
+ :""
}
@@ -475,12 +478,14 @@ class Detail extends Component {
复刻 (Fork)
{
+ forked_count > 0 ?
platform ?
{forked_count}
:
- {praises_count}
+ {forked_count}
+ :""
}