forked from Gitlink/forgeplus-react
通知-跳转
This commit is contained in:
parent
efaf0c29b5
commit
ae34240bfb
|
@ -18,17 +18,18 @@ function Index(props){
|
||||||
const username = props.match.params.username;
|
const username = props.match.params.username;
|
||||||
const pathname = props.history.location.pathname;
|
const pathname = props.history.location.pathname;
|
||||||
const user = props.user;
|
const user = props.user;
|
||||||
|
const undo_messages = props.undo_messages;
|
||||||
|
|
||||||
const [ menu , setMenu ] = useState("notify");
|
const [ menu , setMenu ] = useState("notify");
|
||||||
const [ undo_messages , setMessages ] = useState("notify");
|
const [ messages , setMessages ] = useState(0);
|
||||||
const [ undo_transfer_projects , setTransferProjects ] = useState("notify");
|
const [ transferProjects , setTransferProjects ] = useState(0);
|
||||||
|
|
||||||
useEffect(()=>{
|
useEffect(()=>{
|
||||||
if(user){
|
if(user && undo_messages){
|
||||||
setMessages(user.undo_messages);
|
setMessages(undo_messages);
|
||||||
setTransferProjects(user.undo_transfer_projects);
|
setTransferProjects(user.undo_transfer_projects);
|
||||||
}
|
}
|
||||||
},[user])
|
},[user,undo_messages])
|
||||||
|
|
||||||
useEffect(()=>{
|
useEffect(()=>{
|
||||||
if(pathname && username){
|
if(pathname && username){
|
||||||
|
@ -55,13 +56,13 @@ function Index(props){
|
||||||
<li className={menu === "notify" ? "active":""}>
|
<li className={menu === "notify" ? "active":""}>
|
||||||
<Link to={`/users/${username}/notice`} onClick={changeNum}>
|
<Link to={`/users/${username}/notice`} onClick={changeNum}>
|
||||||
<span>通知</span>
|
<span>通知</span>
|
||||||
{undo_messages ? <span className="unNum">{undo_messages}</span>:""}
|
{messages ? <span className="unNum">{messages}</span>:""}
|
||||||
</Link>
|
</Link>
|
||||||
</li>
|
</li>
|
||||||
<li className={menu === "undo" ? "active":""}>
|
<li className={menu === "undo" ? "active":""}>
|
||||||
<Link to={`/users/${username}/notice/undo`}>
|
<Link to={`/users/${username}/notice/undo`}>
|
||||||
<span>接收仓库</span>
|
<span>接收仓库</span>
|
||||||
{undo_transfer_projects ? <span className="unNum">{undo_transfer_projects}</span>:""}
|
{transferProjects ? <span className="unNum">{transferProjects}</span>:""}
|
||||||
</Link>
|
</Link>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -37,13 +37,13 @@ function Notify(props){
|
||||||
if(status){
|
if(status){
|
||||||
switch(status){
|
switch(status){
|
||||||
case 'canceled':
|
case 'canceled':
|
||||||
return `取消转移【${project && project.name}】仓库`
|
return <p>取消转移【<Link to={`/projects/${project && project.owner && project.owner.login}/${project && project.identifier}`}>{project && project.name}</Link>】仓库</p>
|
||||||
case 'common':
|
case 'common':
|
||||||
return `正在将【${project && project.name}】仓库转移给【${owner && owner.name}】`
|
return <p>正在将【<Link to={`/projects/${project && project.owner && project.owner.login}/${project && project.identifier}`}>{project && project.name}</Link>】仓库转移给【<Link to={`/users/${owner && owner.login}`}>{owner && owner.name}</Link>】</p>
|
||||||
case 'successed':
|
case 'successed':
|
||||||
return `【${project && project.name}】仓库成功转移给【${owner && owner.name}】`
|
return <p>【<Link to={`/projects/${project && project.owner && project.owner.login}/${project && project.identifier}`}>{project && project.name}</Link>】仓库成功转移给【<Link to={`/users/${owner && owner.login}`}>{owner && owner.name}</Link>】</p>
|
||||||
default:
|
default:
|
||||||
return `拒绝转移【${project && project.name}】仓库`
|
return <p>拒绝转移【<Link to={`/projects/${project && project.owner && project.owner.login}/${project && project.identifier}`}>{project && project.name}</Link>】仓库</p>
|
||||||
}
|
}
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
|
@ -67,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>
|
<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>
|
<span className="color-grey-9">{i.time_ago}</span>
|
||||||
</p>
|
</p>
|
||||||
<p>{renderStatus(i.status,i.applied)}</p>
|
{renderStatus(i.status,i.applied)}
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
)
|
)
|
||||||
|
|
|
@ -13,7 +13,6 @@ function UndoEvent(props){
|
||||||
const [ page , setPage ] = useState(1);
|
const [ page , setPage ] = useState(1);
|
||||||
const [ total , setTotal ] = useState(0);
|
const [ total , setTotal ] = useState(0);
|
||||||
|
|
||||||
|
|
||||||
useEffect(()=>{
|
useEffect(()=>{
|
||||||
if(username){
|
if(username){
|
||||||
getList();
|
getList();
|
||||||
|
|
|
@ -53,7 +53,8 @@ class Infos extends Component {
|
||||||
user: undefined,
|
user: undefined,
|
||||||
project_type: undefined,
|
project_type: undefined,
|
||||||
route_type: undefined,
|
route_type: undefined,
|
||||||
undo_events:0
|
undo_events:0,
|
||||||
|
undo_messages:0
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,7 +87,8 @@ class Infos extends Component {
|
||||||
this.setState({
|
this.setState({
|
||||||
user: result.data,
|
user: result.data,
|
||||||
isSpin: false,
|
isSpin: false,
|
||||||
undo_events:notice ? (e-p) : e
|
undo_events:notice ? (e-p) : e,
|
||||||
|
undo_messages:notice ? result.data && result.data.undo_messages : 0
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
|
@ -123,7 +125,7 @@ class Infos extends Component {
|
||||||
const {user} = this.state
|
const {user} = this.state
|
||||||
this.setState({
|
this.setState({
|
||||||
route_type: undefined,
|
route_type: undefined,
|
||||||
project_type:"notice"
|
project_type:"notice",
|
||||||
})
|
})
|
||||||
this.props.history.push(`/users/${user && user.login}/notice`)
|
this.props.history.push(`/users/${user && user.login}/notice`)
|
||||||
}
|
}
|
||||||
|
@ -148,7 +150,7 @@ class Infos extends Component {
|
||||||
const { current_user, mygetHelmetapi } = this.props;
|
const { current_user, mygetHelmetapi } = this.props;
|
||||||
const { username } = this.props.match.params;
|
const { username } = this.props.match.params;
|
||||||
|
|
||||||
const { user, isSpin, project_type, route_type , undo_events } = this.state;
|
const { user, isSpin, project_type, route_type , undo_events , undo_messages } = this.state;
|
||||||
return (
|
return (
|
||||||
<div className="newMain clearfix">
|
<div className="newMain clearfix">
|
||||||
<Spin spinning={isSpin}>
|
<Spin spinning={isSpin}>
|
||||||
|
|
Loading…
Reference in New Issue