forked from Gitlink/forgeplus-react
转移项目-bug和修改需求
This commit is contained in:
parent
8d509f1473
commit
1474f5d3fe
|
@ -1,5 +1,6 @@
|
|||
import React ,{ forwardRef, useEffect, useState } from 'react';
|
||||
import { Modal , Form , Input , Radio , Select } from 'antd';
|
||||
import SearchUser from '../Component/SearchUser';
|
||||
import './Index.scss';
|
||||
import Axios from 'axios';
|
||||
|
||||
|
@ -31,13 +32,14 @@ function DivertModal({form , visible , onSuccess , onCancel,owner,repo}){
|
|||
// 确认转移
|
||||
function onOk(){
|
||||
validateFields((error,values)=>{
|
||||
console.log(...values);
|
||||
if(!error){
|
||||
const url = `/${owner}/${repo}/applied_transfer_projects.json`;
|
||||
Axios.post(url,{
|
||||
...values
|
||||
}).then(result=>{
|
||||
if(result){
|
||||
onSuccess();
|
||||
onSuccess(result.data && result.data.owner);
|
||||
}
|
||||
}).catch(error=>{})
|
||||
}
|
||||
|
@ -65,6 +67,12 @@ function DivertModal({form , visible , onSuccess , onCancel,owner,repo}){
|
|||
labelCol: { span: 5 },
|
||||
wrapperCol: { span: 18 },
|
||||
};
|
||||
|
||||
function getUser(id){
|
||||
setFieldsValue({
|
||||
owner_name:id
|
||||
})
|
||||
}
|
||||
return(
|
||||
<Modal
|
||||
width="620px"
|
||||
|
@ -108,7 +116,8 @@ function DivertModal({form , visible , onSuccess , onCancel,owner,repo}){
|
|||
{getFieldDecorator("owner_name",{
|
||||
rules:[{required:true,message:"请输入目标用户名"}]
|
||||
})(
|
||||
<Input placeholder="请输入目标用户" autoComplete={"off"}/>
|
||||
// <Input placeholder="请输入目标用户" autoComplete={"off"}/>
|
||||
<SearchUser getUser={getUser} width={"100%"} placeholder="请输入目标用户"/>
|
||||
)}
|
||||
</Form.Item>
|
||||
}
|
||||
|
@ -118,7 +127,7 @@ function DivertModal({form , visible , onSuccess , onCancel,owner,repo}){
|
|||
{getFieldDecorator("owner_name",
|
||||
{rules:[{required:true,message:"请选择目标组织"}]}
|
||||
)(
|
||||
<Select placeholder="请选择目标组织" >
|
||||
<Select placeholder="请选择目标组织" getPopupContainer={trigger => trigger.parentNode}>
|
||||
{
|
||||
organizations && organizations.length > 0 ?
|
||||
organizations.map((i,k)=>{
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import React, { useEffect, useState } from "react";
|
||||
import { Menu } from 'antd';
|
||||
import { Link } from 'react-router-dom';
|
||||
import './Index.scss';
|
||||
|
||||
|
@ -18,7 +17,18 @@ const UndoEvent = Loadable({
|
|||
function Index(props){
|
||||
const username = props.match.params.username;
|
||||
const pathname = props.history.location.pathname;
|
||||
const user = props.user;
|
||||
|
||||
const [ menu , setMenu ] = useState("notify");
|
||||
const [ undo_messages , setMessages ] = useState("notify");
|
||||
const [ undo_transfer_projects , setTransferProjects ] = useState("notify");
|
||||
|
||||
useEffect(()=>{
|
||||
if(user){
|
||||
setMessages(user.undo_messages);
|
||||
setTransferProjects(user.undo_transfer_projects);
|
||||
}
|
||||
},[user])
|
||||
|
||||
useEffect(()=>{
|
||||
if(pathname && username){
|
||||
|
@ -31,24 +41,41 @@ function Index(props){
|
|||
}
|
||||
},[pathname])
|
||||
|
||||
function fetchUser(){
|
||||
props && props.fetchUser();
|
||||
}
|
||||
|
||||
function changeNum(){
|
||||
fetchUser();
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Menu selectedKeys={[menu]} mode={"horizontal"} className="noticeMenu">
|
||||
<Menu.Item key="notify"><Link to={`/users/${username}/notice`}>通知</Link></Menu.Item>
|
||||
<Menu.Item key="undo"><Link to={`/users/${username}/notice/undo`}>接收仓库</Link></Menu.Item>
|
||||
</Menu>
|
||||
<ul className="noticeMenu">
|
||||
<li className={menu === "notify" ? "active":""}>
|
||||
<Link to={`/users/${username}/notice`} onClick={changeNum}>
|
||||
<span>通知</span>
|
||||
{undo_messages ? <span className="unNum">{undo_messages}</span>:""}
|
||||
</Link>
|
||||
</li>
|
||||
<li className={menu === "undo" ? "active":""}>
|
||||
<Link to={`/users/${username}/notice/undo`}>
|
||||
<span>接收仓库</span>
|
||||
{undo_transfer_projects ? <span className="unNum">{undo_transfer_projects}</span>:""}
|
||||
</Link>
|
||||
</li>
|
||||
</ul>
|
||||
<Switch>
|
||||
<Route
|
||||
path="/users/:username/notice/undo"
|
||||
render={(p) => {
|
||||
return <UndoEvent {...props} {...p} />;
|
||||
return <UndoEvent {...props} {...p} fetchUser={fetchUser}/>;
|
||||
}}
|
||||
></Route>
|
||||
<Route
|
||||
path="/users/:username/notice"
|
||||
render={(p) => {
|
||||
return <Notify {...props} {...p} />;
|
||||
return <Notify {...props} {...p} fetchUser={fetchUser}/>;
|
||||
}}
|
||||
></Route>
|
||||
</Switch>
|
||||
|
|
|
@ -1,11 +1,46 @@
|
|||
.noticeMenu{
|
||||
padding:0px 20px;
|
||||
.ant-menu-item{
|
||||
display: flex;
|
||||
border-bottom: 1px solid #eee;
|
||||
height: 54px;
|
||||
line-height: 54px;
|
||||
li{
|
||||
font-size: 16px;
|
||||
padding:0px;
|
||||
margin:0px 20px!important;
|
||||
margin:0px 30px 0px 20px!important;
|
||||
height: 54px;
|
||||
line-height: 54px;
|
||||
position: relative;
|
||||
transform: none;
|
||||
a{
|
||||
display: flex;
|
||||
&>span{
|
||||
position: relative;
|
||||
}
|
||||
}
|
||||
&.active a span:first-child::after{
|
||||
position: absolute;
|
||||
bottom: 0px;
|
||||
height: 2px;
|
||||
left: 0px;
|
||||
content: "";
|
||||
background-color: #1890ff;
|
||||
width: 100%;
|
||||
}
|
||||
.unNum{
|
||||
color: #d38900;
|
||||
font-size: 12px;
|
||||
border-radius: 13px;
|
||||
height: 16px;
|
||||
line-height: 16px;
|
||||
padding:0px 4px;
|
||||
min-width: 23px;
|
||||
text-align: center;
|
||||
background-color: #ffe4b3;
|
||||
margin-top: 19px;
|
||||
margin-left: 10px;
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
}
|
||||
.notifyList{
|
||||
|
|
|
@ -32,6 +32,25 @@ function Notify(props){
|
|||
}).catch(error=>{})
|
||||
}
|
||||
|
||||
function renderStatus(status,applied){
|
||||
let { project , owner} = applied
|
||||
if(status){
|
||||
switch(status){
|
||||
case 'canceled':
|
||||
return `取消转移【${project && project.name}】仓库`
|
||||
case 'common':
|
||||
return `正在将【${project && project.name}】仓库转移给【${owner && owner.name}】`
|
||||
case 'successed':
|
||||
return `【${project && project.name}】仓库成功转移给【${owner && owner.name}】`
|
||||
default:
|
||||
return `拒绝转移【${project && project.name}】仓库`
|
||||
}
|
||||
|
||||
}else{
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
return(
|
||||
<div>
|
||||
{
|
||||
|
@ -48,7 +67,7 @@ function Notify(props){
|
|||
<Link to={`/users/${i.applied_user && i.applied_user.login}`} className="font-15 mr20">{i.applied_user && i.applied_user.name}</Link>
|
||||
<span className="color-grey-9">{i.time_ago}</span>
|
||||
</p>
|
||||
<p>{i.name}</p>
|
||||
<p>{renderStatus(i.status,i.applied)}</p>
|
||||
</div>
|
||||
</li>
|
||||
)
|
||||
|
@ -59,7 +78,7 @@ function Notify(props){
|
|||
:
|
||||
""
|
||||
}
|
||||
{list && list.length === 0 && <Nodata _html="暂无数组" />}
|
||||
{list && list.length === 0 && <Nodata _html="暂无通知" />}
|
||||
{
|
||||
total > limit &&
|
||||
<div className="edu-txt-center pt20 pb20">
|
||||
|
|
|
@ -40,6 +40,7 @@ function UndoEvent(props){
|
|||
Axios.post(url).then(result=>{
|
||||
if(result && result.data){
|
||||
getList();
|
||||
props && props.fetchUser();
|
||||
}
|
||||
}).catch(error=>{})
|
||||
}
|
||||
|
@ -50,6 +51,7 @@ function UndoEvent(props){
|
|||
Axios.post(url).then(result=>{
|
||||
if(result && result.data){
|
||||
getList();
|
||||
props && props.fetchUser();
|
||||
}
|
||||
}).catch(error=>{})
|
||||
}
|
||||
|
@ -71,7 +73,8 @@ function UndoEvent(props){
|
|||
<span className="color-grey-9">{i.time_ago}</span>
|
||||
</p>
|
||||
<FlexAJ>
|
||||
<p className="color-grey-6">请求将仓库【{i.project && i.project.name}】转移给【{i.owner && i.owner.name}】,是否接受?</p>
|
||||
<p className="color-grey-6">请求将仓库【<Link to={`/projects/${i.project && i.project.owner && i.project.owner.login}/${i.project && i.project.identifier}`}>{i.project && i.project.name}</Link>】
|
||||
转移给【<Link to={`/users/${i.owner && i.owner.login}`}>{i.owner && i.owner.name}</Link>】,是否接受?</p>
|
||||
{
|
||||
i.status === "common" &&
|
||||
<span>
|
||||
|
@ -103,7 +106,7 @@ function UndoEvent(props){
|
|||
:
|
||||
""
|
||||
}
|
||||
{list && list.length === 0 && <Nodata _html="暂无数组" />}
|
||||
{list && list.length === 0 && <Nodata _html="暂无接收信息" />}
|
||||
{
|
||||
total > limit &&
|
||||
<div className="edu-txt-center pt20 pb20">
|
||||
|
|
|
@ -3,6 +3,7 @@ import { Form, Input, Checkbox, Select , Spin } from "antd";
|
|||
import Title from '../Component/Title';
|
||||
import {WhiteBack} from '../Component/layout';
|
||||
import DivertModal from '../Divert/DivertModal';
|
||||
import { Link } from 'react-router-dom';
|
||||
import axios from "axios";
|
||||
import "./setting.scss";
|
||||
const { TextArea } = Input;
|
||||
|
@ -77,6 +78,7 @@ class Setting extends Component {
|
|||
private_check: result.data.private,
|
||||
loading:false,
|
||||
project_units:units,
|
||||
transfer:result.data.transfer,
|
||||
is_transfering:result.data.is_transfering,
|
||||
});
|
||||
}
|
||||
|
@ -215,10 +217,11 @@ class Setting extends Component {
|
|||
|
||||
}
|
||||
// 确定转移仓库
|
||||
onSuccess=()=>{
|
||||
onSuccess=(owner)=>{
|
||||
this.setState({
|
||||
is_transfering:true,
|
||||
divertVisible:false
|
||||
divertVisible:false,
|
||||
transfer:owner
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -227,7 +230,8 @@ class Setting extends Component {
|
|||
const { projectsId , owner } = this.props.match.params;
|
||||
const { projectDetail } = this.props;
|
||||
|
||||
const { CategoryList, LanguageList, private_check ,loading , divertVisible , is_transfering } = this.state;
|
||||
const { CategoryList, LanguageList, private_check ,loading , divertVisible , is_transfering, transfer } = this.state;
|
||||
console.log(transfer);
|
||||
return (
|
||||
<div>
|
||||
<DivertModal
|
||||
|
@ -333,7 +337,14 @@ class Setting extends Component {
|
|||
<div>
|
||||
<p className="font-bd font-16">转移仓库</p>
|
||||
<p className="mt10">
|
||||
将此仓库转移给其他用户或组织
|
||||
{
|
||||
is_transfering ?
|
||||
<span>此仓库正在转移给【
|
||||
{transfer && <Link to={transfer.type="User"?`/users/${transfer.login}`:`/organize/${transfer.login}`}>{transfer.name}</Link>}
|
||||
】,请联系对方接收此仓库。</span>
|
||||
:
|
||||
`将此仓库转移给其他用户或组织`
|
||||
}
|
||||
</p>
|
||||
</div>
|
||||
{
|
||||
|
|
|
@ -52,7 +52,8 @@ class Infos extends Component {
|
|||
isSpin: false,
|
||||
user: undefined,
|
||||
project_type: undefined,
|
||||
route_type: undefined
|
||||
route_type: undefined,
|
||||
undo_events:0
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -73,14 +74,19 @@ class Infos extends Component {
|
|||
});
|
||||
const { current_user } = this.props;
|
||||
const { username } = this.props.match.params;
|
||||
const { pathname } = this.props.location;
|
||||
|
||||
let url = `/users/${username || (current_user && current_user.login)}.json`;
|
||||
axios
|
||||
.get(url)
|
||||
.then((result) => {
|
||||
let e = result.data && result.data.undo_events;
|
||||
let p = result.data && result.data.undo_messages;
|
||||
let notice = p !== 0 ? pathname === `/users/${username}/notice` :false;
|
||||
this.setState({
|
||||
user: result.data,
|
||||
isSpin: false,
|
||||
undo_events:notice ? (e-p) : e
|
||||
});
|
||||
})
|
||||
.catch((error) => {
|
||||
|
@ -142,7 +148,7 @@ class Infos extends Component {
|
|||
const { current_user, mygetHelmetapi } = this.props;
|
||||
const { username } = this.props.match.params;
|
||||
|
||||
const { user, isSpin, project_type, route_type } = this.state;
|
||||
const { user, isSpin, project_type, route_type , undo_events } = this.state;
|
||||
return (
|
||||
<div className="newMain clearfix">
|
||||
<Spin spinning={isSpin}>
|
||||
|
@ -223,7 +229,7 @@ class Infos extends Component {
|
|||
待办事项
|
||||
</span>
|
||||
<span className="text-yellow font-16">
|
||||
{user.undo_events}
|
||||
{undo_events}
|
||||
</span>
|
||||
</p>
|
||||
</li>
|
||||
|
@ -318,7 +324,7 @@ class Infos extends Component {
|
|||
<Route
|
||||
path="/users/:username/notice"
|
||||
render={() => {
|
||||
return <Notice {...this.props} {...this.state} />;
|
||||
return <Notice {...this.props} {...this.state} fetchUser={this.fetchUser}/>;
|
||||
}}
|
||||
></Route>
|
||||
<Route
|
||||
|
|
Loading…
Reference in New Issue