forked from Gitlink/forgeplus-react
新建合并请求-提交部分增加分页功能
This commit is contained in:
parent
cb811990f1
commit
934157349d
|
@ -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>
|
||||
)
|
||||
}
|
||||
|
|
|
@ -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>
|
||||
)}
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in New Issue