Merge pull request 'ÅDD compare api on create pr action' (#191) from pre_develop_dev into pre_develop
This commit is contained in:
commit
b31503ee0d
|
@ -150,7 +150,7 @@ class CreateMerge extends Component {
|
||||||
}else{
|
}else{
|
||||||
if(pullOwner === mergeOwner){
|
if(pullOwner === mergeOwner){
|
||||||
if (!noMergeBranch) {
|
if (!noMergeBranch) {
|
||||||
this.compareProject(result.data.id, branchParams);
|
this.compareProject(true, branchParams);
|
||||||
} else {
|
} else {
|
||||||
this.setState({
|
this.setState({
|
||||||
showMessage: true,
|
showMessage: true,
|
||||||
|
@ -172,53 +172,51 @@ class CreateMerge extends Component {
|
||||||
};
|
};
|
||||||
|
|
||||||
// compare接口,获取分支对比信息
|
// compare接口,获取分支对比信息
|
||||||
compareProject = (baseid, branchParams) => {
|
compareProject = (sameProject, branchParams) => {
|
||||||
// const { project } = this.props;
|
// const { project } = this.props;
|
||||||
// const { owner, projectsId } = this.props.match.params;
|
// const { owner, projectsId } = this.props.match.params;
|
||||||
const projectObj = this.props.project;
|
|
||||||
const { pullOwner, pullBranch, mergeOwner, mergeBranch, projectId } =
|
const { pullOwner, pullBranch, mergeOwner, mergeBranch, projectId } =
|
||||||
branchParams;
|
branchParams;
|
||||||
|
|
||||||
let url = `/${mergeOwner}/${projectId}/compare`;
|
let url = `/${mergeOwner}/${projectId}/compare`;
|
||||||
if (projectObj) {
|
if (sameProject) {
|
||||||
if (baseid === projectObj.id) {
|
url += `/${pullBranch}...${mergeBranch}.json`;
|
||||||
url += `/${pullBranch}...${mergeBranch}.json`;
|
} else {
|
||||||
} else {
|
url += `/${mergeBranch}...${pullOwner}/${projectId}:${pullBranch}.json`;
|
||||||
url += `/${mergeBranch}...${pullOwner}/${projectId}:${pullBranch}.json`;
|
}
|
||||||
}
|
this.setState({ isSpin: false, isCompareSpin: true });
|
||||||
this.setState({ isSpin: false, isCompareSpin: true });
|
axios
|
||||||
axios
|
.get(url)
|
||||||
.get(url)
|
.then((result) => {
|
||||||
.then((result) => {
|
if (result) {
|
||||||
if (result) {
|
if (result.data.status === 0) {
|
||||||
if (result.data.status === 0) {
|
|
||||||
this.setState({
|
|
||||||
showMessage: false,
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
this.setState({
|
|
||||||
showMessage: true,
|
|
||||||
defaultMessage: result.data.message,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
this.setState({
|
this.setState({
|
||||||
comparesData: result.data,
|
showMessage: false,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.setState({
|
||||||
|
showMessage: true,
|
||||||
|
defaultMessage: result.data.message,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
this.setState({
|
this.setState({
|
||||||
isFirstLoading: false,
|
comparesData: result.data,
|
||||||
isSpin: false,
|
|
||||||
isCompareSpin: false,
|
|
||||||
});
|
});
|
||||||
})
|
}
|
||||||
.catch((error) => {
|
this.setState({
|
||||||
this.setState({ isSpin: false, isCompareSpin: false });
|
isFirstLoading: false,
|
||||||
|
isSpin: false,
|
||||||
|
isCompareSpin: false,
|
||||||
});
|
});
|
||||||
}
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
this.setState({ isSpin: false, isCompareSpin: false });
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// 根据所有者、仓库名,获取分支列表,目前仅涉及目标仓库分支查询
|
// 根据所有者、仓库名,获取分支列表,目前仅涉及目标仓库分支查询
|
||||||
getBranchList = ({ mergeOwner, projectId, mergeBranch }) => {
|
getBranchList = (branchParams) => {
|
||||||
|
const { mergeOwner, projectId, mergeBranch } = branchParams;
|
||||||
this.setState({ isSpin: true });
|
this.setState({ isSpin: true });
|
||||||
const url = `/${mergeOwner}/${projectId}/pulls/get_branches.json`;
|
const url = `/${mergeOwner}/${projectId}/pulls/get_branches.json`;
|
||||||
axios
|
axios
|
||||||
|
@ -234,6 +232,7 @@ class CreateMerge extends Component {
|
||||||
defaultMessage: '目标分支不存在',
|
defaultMessage: '目标分支不存在',
|
||||||
isCompareSpin: false,
|
isCompareSpin: false,
|
||||||
});
|
});
|
||||||
|
!noMergeBranch && this.compareProject(false, branchParams);
|
||||||
}
|
}
|
||||||
this.setState({ isSpin: false });
|
this.setState({ isSpin: false });
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue