diff --git a/src/forge/Component/EducoderAccount.jsx b/src/forge/Component/EducoderAccount.jsx index 59e2295f2..1b3fc42e8 100644 --- a/src/forge/Component/EducoderAccount.jsx +++ b/src/forge/Component/EducoderAccount.jsx @@ -1,15 +1,32 @@ import React , {forwardRef, useEffect} from 'react'; import { Modal , Form , Input , Button } from 'antd'; import './EAccount.scss'; +import axios from 'axios'; -function EducoderAccount({form , visible , onOk , email}){ +function EducoderAccount({form , visible , current_user}){ const { getFieldDecorator, validateFields , setFieldsValue } = form; useEffect(()=>{ - if(email){ - setFieldsValue({email}) + if(current_user && current_user.email){ + setFieldsValue({email:current_user.email}) } - },[email]) + },[current_user]) + + function onOk(values){ + let url = `/accounts/gitea_register.json`; + const { email , is_sync_pwd} = current_user; + if(email && !is_sync_pwd){ + url = `/users/change_password.json`; + } + axios.post(url,{ + login:current_user && current_user.login, + ...values + }).then(result=>{ + if(result && result.data && result.data.status === 0){ + window.location.reload(); + } + }).catch(error=>{}) + } function onSure(){ validateFields((error,values)=>{ @@ -27,7 +44,6 @@ function EducoderAccount({form , visible , onOk , email}){ visible={visible} title="提示" width="500px" - closable={false} footer={ } @@ -36,8 +52,8 @@ function EducoderAccount({form , visible , onOk , email}){

{ - email ? - `平台已检测到您已绑定邮箱${email},请您确认如下操作` + current_user && current_user.email ? + `平台已检测到您已绑定邮箱${current_user.email},请您确认如下操作` : "平台已检测到您未绑定邮箱,为不影响使用协同开发功能,请先绑定邮箱" } @@ -47,7 +63,7 @@ function EducoderAccount({form , visible , onOk , email}){ {getFieldDecorator("email",{ rules:[{required:true,message:"请输入邮箱账号"}] })( - + )} diff --git a/src/forge/Component/ProfileModal/Profile.jsx b/src/forge/Component/ProfileModal/Profile.jsx index e63c1286d..977c6de07 100644 --- a/src/forge/Component/ProfileModal/Profile.jsx +++ b/src/forge/Component/ProfileModal/Profile.jsx @@ -1,17 +1,36 @@ import React from 'react'; +import { useState } from 'react'; +import EducoderAccount from '../EducoderAccount'; -function Profile({children,sureFunc,showCompeleteDialog , completeProfile, className}) { - +function Profile({ + children, + sureFunc, + showCompeleteDialog , + completeProfile, + className , + current_user +}) { + const [ giteaVisible , setGiteaVisible ] = useState(false); + function checkProfile() { - if(!completeProfile){ - showCompeleteDialog && showCompeleteDialog(); - }else{ - sureFunc(); + if(current_user && current_user.login){ + if(!current_user.has_gitea_user || (current_user.has_gitea_user && !current_user.is_sync_pwd)){ + setGiteaVisible(true); + }else{ + if(!completeProfile){ + showCompeleteDialog && showCompeleteDialog(); + }else{ + sureFunc(); + } + } } } return( - {children} + + setGiteaVisible(false)} current_user={current_user}/> + {children} + ) } export default Profile; \ No newline at end of file diff --git a/src/forge/users/GeneralView/ConcentrateBox.jsx b/src/forge/users/GeneralView/ConcentrateBox.jsx index a66c9d797..f2e9a132b 100644 --- a/src/forge/users/GeneralView/ConcentrateBox.jsx +++ b/src/forge/users/GeneralView/ConcentrateBox.jsx @@ -6,7 +6,7 @@ import CheckProfile from '../../Component/ProfileModal/Profile'; const { Search } = Input; const limit = 20; -function ConcentrateBox({ visible , onCancel , onSure , username , choosed , history , showCompeleteDialog , completeProfile }) { +function ConcentrateBox({ visible , onCancel , onSure , username , choosed , history , showCompeleteDialog , completeProfile , current_user }) { const [ page , setPage ]= useState(1); const [ total , setTotal ]= useState(0); const [ pageSize , setPageSize ] = useState(false); @@ -171,6 +171,7 @@ function ConcentrateBox({ visible , onCancel , onSure , username , choosed , his (list && list.length === 0) && (copyList && copyList.length === 0) &&

您还没有公开的{search && `“${search}”`}项目,先去 {history.push(`/projects/deposit/new`)}} diff --git a/src/modules/tpm/TPMIndexHOC.js b/src/modules/tpm/TPMIndexHOC.js index bd5ef708a..736355ece 100644 --- a/src/modules/tpm/TPMIndexHOC.js +++ b/src/modules/tpm/TPMIndexHOC.js @@ -5,7 +5,6 @@ import axios from 'axios'; import { Spin } from 'antd'; import './TPMIndex.css'; import LoginDialog from '../login/LoginDialog'; -import EducoderAccount from '../../forge/Component/EducoderAccount'; import ProfileModal from '../../forge/Component/ProfileModal/Index'; // import AccountProfile from '../user/AccountProfile'; // import AccountPhoneemail from '../user/AccountPhoneemail'; @@ -26,11 +25,9 @@ export function TPMIndexHOC(WrappedComponent) { dataquerys: {}, isloginCancel: undefined, mygetHelmetapi: null, - giteaVisible:false, email:undefined, completeProfile:false, showCP:false, - is_sync_pwd:undefined } } @@ -163,32 +160,6 @@ export function TPMIndexHOC(WrappedComponent) { if (this.props.match.path === "/" && response.data.login) { this.props.history.push(`/${response.data.login}`); } - if(response.data && response.data.login){ - if(response.data.need_edit_info){ - this.setState({ - giteaVisible:true, - email:response.data.email - }) - } - } - if(response.data && response.data.login){ - if(!response.data.has_gitea_user || (response.data.has_gitea_user && !response.data.is_sync_pwd)){ - this.setState({ - giteaVisible:true, - email:response.data.email, - is_sync_pwd:response.data.is_sync_pwd - }) - } - } - if(response.data && response.data.login){ - if(!response.data.has_gitea_user || (response.data.has_gitea_user && !response.data.is_sync_pwd)){ - this.setState({ - giteaVisible:true, - email:response.data.email, - is_sync_pwd:response.data.is_sync_pwd - }) - } - } } }).catch((error) => { console.log(error) @@ -212,26 +183,6 @@ export function TPMIndexHOC(WrappedComponent) { return this.state.current_user && this.state.current_user.login != '' } - onOk =(values)=>{ - let url = `/accounts/gitea_register.json`; - const { email , current_user , is_sync_pwd } = this.state; - if(email && !is_sync_pwd){ - url = `/users/change_password.json`; - } - axios.post(url,{ - login:current_user && current_user.login, - ...values - }).then(result=>{ - if(result && result.data && result.data.status === 0){ - this.setState({ - giteaVisible:false, - email:undefined - }) - window.location.reload(); - } - }).catch(error=>{}) - } - showCompeleteDialog=()=>{ this.setState({ showCP:true @@ -239,7 +190,7 @@ export function TPMIndexHOC(WrappedComponent) { } render() { - let { isRender , current_user , giteaVisible , email , completeProfile , showCP } = this.state; + let { isRender , current_user , completeProfile , showCP } = this.state; const common = { showLoginDialog: this.showLoginDialog, checkIfLogin: this.checkIfLogin, @@ -248,7 +199,6 @@ export function TPMIndexHOC(WrappedComponent) { }; return (
- {this.setState({showCP:false})}}