通知-跳转

This commit is contained in:
caishi 2021-04-27 17:46:05 +08:00
parent efaf0c29b5
commit ae34240bfb
4 changed files with 19 additions and 17 deletions

View File

@ -18,17 +18,18 @@ function Index(props){
const username = props.match.params.username;
const pathname = props.history.location.pathname;
const user = props.user;
const undo_messages = props.undo_messages;
const [ menu , setMenu ] = useState("notify");
const [ undo_messages , setMessages ] = useState("notify");
const [ undo_transfer_projects , setTransferProjects ] = useState("notify");
const [ messages , setMessages ] = useState(0);
const [ transferProjects , setTransferProjects ] = useState(0);
useEffect(()=>{
if(user){
setMessages(user.undo_messages);
if(user && undo_messages){
setMessages(undo_messages);
setTransferProjects(user.undo_transfer_projects);
}
},[user])
},[user,undo_messages])
useEffect(()=>{
if(pathname && username){
@ -55,13 +56,13 @@ function Index(props){
<li className={menu === "notify" ? "active":""}>
<Link to={`/users/${username}/notice`} onClick={changeNum}>
<span>通知</span>
{undo_messages ? <span className="unNum">{undo_messages}</span>:""}
{messages ? <span className="unNum">{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>:""}
{transferProjects ? <span className="unNum">{transferProjects}</span>:""}
</Link>
</li>
</ul>

View File

@ -37,13 +37,13 @@ function Notify(props){
if(status){
switch(status){
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':
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':
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:
return `拒绝转移【${project && project.name}】仓库`
return <p>拒绝转移<Link to={`/projects/${project && project.owner && project.owner.login}/${project && project.identifier}`}>{project && project.name}</Link>仓库</p>
}
}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>
<span className="color-grey-9">{i.time_ago}</span>
</p>
<p>{renderStatus(i.status,i.applied)}</p>
{renderStatus(i.status,i.applied)}
</div>
</li>
)

View File

@ -13,7 +13,6 @@ function UndoEvent(props){
const [ page , setPage ] = useState(1);
const [ total , setTotal ] = useState(0);
useEffect(()=>{
if(username){
getList();

View File

@ -53,7 +53,8 @@ class Infos extends Component {
user: undefined,
project_type: undefined,
route_type: undefined,
undo_events:0
undo_events:0,
undo_messages:0
};
}
@ -86,7 +87,8 @@ class Infos extends Component {
this.setState({
user: result.data,
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) => {
@ -123,7 +125,7 @@ class Infos extends Component {
const {user} = this.state
this.setState({
route_type: undefined,
project_type:"notice"
project_type:"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 { 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 (
<div className="newMain clearfix">
<Spin spinning={isSpin}>