forked from Gitlink/forgeplus-react
issue评论增加分页+个人主页区块确权
This commit is contained in:
parent
2f0aaccc41
commit
7cb3d9a2ad
|
@ -1,5 +1,5 @@
|
|||
import React, { useEffect, useState } from 'react';
|
||||
import { Button, Popconfirm, Radio, Input, message, Tooltip, Spin } from 'antd';
|
||||
import { Button, Popconfirm, Radio, Input, message, Tooltip, Spin, Pagination } from 'antd';
|
||||
import axios from 'axios';
|
||||
import { getImageUrl, timeAgo } from 'educoder';
|
||||
import RenderHtml from '../../../../components/render-html';
|
||||
|
@ -27,6 +27,10 @@ function IssueCommentList(props){
|
|||
const [spin, setSpin] = useState(false);
|
||||
// issue 评论总数
|
||||
const [journalsCount, setJournalsCount] = useState(undefined);
|
||||
// 分页
|
||||
const limit = 50;
|
||||
const [page, setPage] = useState(1);
|
||||
const [totalCount, setTotalCount] = useState(undefined);
|
||||
// 操作记录 icon
|
||||
const journalsIcon ={
|
||||
'issue': 'icon-chuangjianqianbao',
|
||||
|
@ -46,10 +50,12 @@ function IssueCommentList(props){
|
|||
useEffect(()=>{
|
||||
setSpin(true);
|
||||
axios.get(`/v1/${owner}/${projectsId}/issues/${index}/journals`,{params:{
|
||||
category
|
||||
category,
|
||||
page,
|
||||
limit
|
||||
}}).then(res=>{
|
||||
if(res && res.data){
|
||||
const {journals, total_comment_journals_count} = res.data;
|
||||
const {journals, total_comment_journals_count, total_count} = res.data;
|
||||
if(category === 'all'){
|
||||
const array = [];
|
||||
let start = undefined;
|
||||
|
@ -74,12 +80,13 @@ function IssueCommentList(props){
|
|||
}
|
||||
})
|
||||
}
|
||||
setTotalCount(total_count);
|
||||
setJournalsCount(total_comment_journals_count);
|
||||
setJournals(journals);
|
||||
setSpin(false)
|
||||
}
|
||||
})
|
||||
}, [reload, category])
|
||||
}, [reload, category, page])
|
||||
|
||||
function commentCtx(v){
|
||||
return <RenderHtml className="break_word_comments imageLayerParent commentRenderHtml" value={v} url={location}/>;
|
||||
|
@ -104,7 +111,7 @@ function IssueCommentList(props){
|
|||
<div className="commentListBox">
|
||||
{/* 全部 / 评论 / 操作日志 */}
|
||||
<div className='typeActionBox mt30 mb20'>
|
||||
<Radio.Group onChange={(e)=>{setSpin(true);setCategory(e.target.value)}} value={category}>
|
||||
<Radio.Group onChange={(e)=>{setSpin(true);setPage(1);setCategory(e.target.value)}} value={category}>
|
||||
<Radio value={'comment'} className='typeActionRadio font-14'>评论<span className='journalsCount font-13 ml5'>{journalsCount}</span></Radio>
|
||||
<Radio value={'operate'} className='typeActionRadio font-14'>操作日志</Radio>
|
||||
<Radio value={'all'} className='typeActionRadio font-14'>全部</Radio>
|
||||
|
@ -130,10 +137,10 @@ function IssueCommentList(props){
|
|||
{journals && (journals.length > 0 && journals.map(item=>{return item.is_journal_detail ? (!item.closeAndSpan || item.id === item.start || open === item.start) ? <div key={item.id} className='operationLog'>
|
||||
{/* 操作日志 */}
|
||||
<div className='operationCommentBor'></div>
|
||||
<div className='flexCenter font-14' style={{flex: 1}}>
|
||||
<div className='flexCenter font-14' style={{width: '100%'}}>
|
||||
<div className='flexCenter opBox'>
|
||||
<span className='iconBackBox mr10'><i className={`iconfont font-12 ${journalsIcon[item.operate_category]}`}></i></span>
|
||||
<div className='task-hide' style={{flex: '1'}}>
|
||||
<div className='task-hide' style={{maxWidth: item.closeAndSpan && item.id === item.start? '550px' : '700px'}}>
|
||||
<Link to={`/${item.user.login}`}><img src={getImageUrl(item.user.image_url)} alt="" className='commentUserImg mr5'/></Link>
|
||||
<Link to={`/${item.user.login}`}>{item.user.name} </Link>
|
||||
{(item.user.name.length + item.operate_content.length) > 62 ? <Tooltip title={<div><span>{item.user.name} </span><span dangerouslySetInnerHTML={{__html:item.operate_content}}></span></div>}><span dangerouslySetInnerHTML={{__html:item.operate_content}}></span></Tooltip> : <span dangerouslySetInnerHTML={{__html:item.operate_content}}></span>}
|
||||
|
@ -222,6 +229,9 @@ function IssueCommentList(props){
|
|||
</div>}))}
|
||||
</div>
|
||||
</Spin>
|
||||
{totalCount>limit && <div className='mt20 paginationIssueComment mb20'>
|
||||
<Pagination simple current={page} pageSize={limit} total={totalCount} onChange={(page)=>setPage(page)}/>
|
||||
</div>}
|
||||
{/* 无数据 */}
|
||||
{journals && !journals.length && <Nodata _html="暂无数据"/>}
|
||||
</div>
|
||||
|
|
|
@ -189,4 +189,7 @@
|
|||
width: 100%;
|
||||
height: 30px;
|
||||
border: none;
|
||||
}
|
||||
.paginationIssueComment{
|
||||
text-align: center;
|
||||
}
|
|
@ -28,12 +28,12 @@ function Contribution(props){
|
|||
const [error2, setError2] = useState(undefined);
|
||||
// 操作仓库id
|
||||
const [proId, setProId] = useState(undefined);
|
||||
const {current_user:{user_id, login}, current_user} = props;
|
||||
const {current_user:{user_id, login, open_blockchain}, current_user} = props;
|
||||
const {user} = props;
|
||||
const username = props.match.params.username;
|
||||
|
||||
useEffect(()=>{
|
||||
if((username && current_user && (current_user.login !== username))){
|
||||
if((username && current_user && (current_user.login !== username)) || !open_blockchain){
|
||||
props.history.push(`/${username}`);
|
||||
}
|
||||
},[current_user,username])
|
||||
|
|
Loading…
Reference in New Issue