新建合并请求-提交部分增加分页功能

This commit is contained in:
caishi 2022-05-10 09:21:38 +08:00
parent 0b959c4a9b
commit 35c32aed9c
3 changed files with 35 additions and 5 deletions

View File

@ -4,8 +4,9 @@ import User from '../Component/User';
import { truncateCommitId } from '../common/util';
import { getImageUrl } from 'educoder';
import { Link } from 'react-router-dom';
import { Pagination } from 'antd';
function Commits({ commits , projectsId , owner }){
function Commits({ commits , projectsId , owner , total ,limit , changeCommitFunc }){
return(
<div className="pb20">
{
@ -29,6 +30,12 @@ function Commits({ commits , projectsId , owner }){
)
})
}
{
total > limit &&
<div style={{textAlign:"center",paddingTop:"20px"}}>
<Pagination pageSize={limit} total={total} onChange={(page)=>changeCommitFunc(page)}/>
</div>
}
</div>
)
}

View File

@ -18,6 +18,8 @@ import './merge.css';
* 3合并请求列表页新建无数据时的提示仓库相同目标都为默认分支owner/projectId/compare
* 4新建页面切换分支切换目标仓库刷新页面等存在所有可能情况
*/
const limit = 15;
function getBranchParams(pathname) {
const result = {
// 目标仓库所有者
@ -152,7 +154,7 @@ class CreateMerge extends Component {
let getbranch =await this.getBranchList(mergeOwner,projectId,pullBranch,mergeBranch,"merge");
let checkpull =await this.getBranchList(pullOwner,projectId,pullBranch,mergeBranch,"pull");
if(getbranch && checkpull){
this.compareProject(mergeOwner === pullOwner, branchParams);
this.compareProject(mergeOwner === pullOwner, branchParams,1);
}else{
this.setState({
isSpin: false,isCompareSpin: false
@ -161,7 +163,7 @@ class CreateMerge extends Component {
}
// compare接口获取分支对比信息
compareProject = (sameProject, branchParams) => {
compareProject = (sameProject, branchParams ,page) => {
const { pullOwner, pullBranch, mergeOwner, mergeBranch, projectId } = branchParams;
let url = `/${mergeOwner}/${projectId}/compare`;
if (sameProject) {
@ -170,7 +172,9 @@ class CreateMerge extends Component {
url += `/${Base64.encode(returnbar(mergeBranch))}...${pullOwner}/${projectId}:${Base64.encode(returnbar(pullBranch))}.json`;
}
axios
.get(url)
.get(url,{
params:{limit,page}
})
.then((result) => {
if (result) {
if (result.data.status === 0) {
@ -354,6 +358,15 @@ class CreateMerge extends Component {
}).catch(error=>{})
}
changeCommitFunc=(page)=>{
this.setState({
isSpin:true
})
const branchParams = getBranchParams(this.props.location.pathname);
const { mergeOwner , pullOwner} = branchParams;
this.compareProject(mergeOwner === pullOwner, branchParams,page);
}
render() {
const {
data,
@ -465,6 +478,8 @@ class CreateMerge extends Component {
{...this.props}
merge={merge}
pull={pull}
limit = {limit}
changeCommitFunc={this.changeCommitFunc}
comparesData={comparesData}
></MergeFooter>
)}

View File

@ -22,9 +22,14 @@ class MergeFooter extends Component {
});
};
changeCommitFunc=(page)=>{
const { changeCommitFunc } = this.props;
changeCommitFunc&& changeCommitFunc(page);
}
render() {
const { projectsId, owner } = this.props.match.params;
const { comparesData = {} } = this.props;
const { comparesData = {} ,limit } = this.props;
const { commits, diff, commits_count } = comparesData;
const { activeKey } = this.state;
@ -53,6 +58,9 @@ class MergeFooter extends Component {
<Commits
{...this.props}
commits={commits}
total={commits_count}
limit={limit}
changeCommitFunc={this.changeCommitFunc}
projectsId={projectsId}
owner={owner}
></Commits>