update
This commit is contained in:
parent
f9588407b8
commit
2e04851b66
|
@ -36,7 +36,7 @@ function Files({data,history,owner,projectsId,showDown}){
|
|||
<span>{item.name}</span>
|
||||
</AlignCenter>
|
||||
<span>
|
||||
<Button className="mr20" onClick={()=>{history.push(`/projects/${owner}/${projectsId}?url=${item.name}`)}}>查看文件</Button>
|
||||
<Button className="mr20" onClick={()=>{history.push(`/projects/${owner}/${projectsId}?${item.sha ? `branch=${item.sha}&`:""}url=${item.name}`)}}>查看文件</Button>
|
||||
<span className="color-green">+{item.addition}</span>
|
||||
<span className="color-red ml20">-{item.deletion}</span>
|
||||
</span>
|
||||
|
|
|
@ -520,14 +520,12 @@ class MessageCount extends Component {
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div className="main" style={{padding:"15px 30px 20px 30px"}}>
|
||||
<MergeFooter
|
||||
footer_type={true}
|
||||
order_id={data && data.issue.id}
|
||||
{...this.props}
|
||||
{...this.state}
|
||||
></MergeFooter>
|
||||
</div>
|
||||
<MergeFooter
|
||||
footer_type={true}
|
||||
order_id={data && data.issue.id}
|
||||
{...this.props}
|
||||
{...this.state}
|
||||
></MergeFooter>
|
||||
</div>
|
||||
) : (
|
||||
""
|
||||
|
|
|
@ -60,7 +60,6 @@ class NewMerge extends Component {
|
|||
getmergelist = (projectsId) => {
|
||||
this.setState({isSpin: true})
|
||||
const { owner } = this.props.match.params;
|
||||
|
||||
const url = `/${owner}/${projectsId}/pulls/new.json`;
|
||||
axios
|
||||
.get(url)
|
||||
|
@ -344,19 +343,20 @@ class NewMerge extends Component {
|
|||
data={data}
|
||||
merge={merge}
|
||||
pull={pull}
|
||||
files_count={comparesData && comparesData.diff && comparesData.diff.files_count}
|
||||
commits_count={comparesData && comparesData.commits_count}
|
||||
></MergeForm>
|
||||
)}
|
||||
</Spin>
|
||||
</div>
|
||||
|
||||
<div className="main" style={{paddingTop:"0px"}}>
|
||||
<MergeFooter
|
||||
order_id={data && data.issue && data.issue.id}
|
||||
{...this.props}
|
||||
{...this.state}
|
||||
comparesData={comparesData}
|
||||
></MergeFooter>
|
||||
</div>
|
||||
<MergeFooter
|
||||
order_id={data && data.issue && data.issue.id}
|
||||
{...this.props}
|
||||
{...this.state}
|
||||
merge={merge}
|
||||
pull={pull}
|
||||
comparesData={comparesData}
|
||||
></MergeFooter>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -13,21 +13,44 @@ class MergeFooter extends Component {
|
|||
super(props);
|
||||
this.state={
|
||||
pageData:undefined,
|
||||
commitsData:undefined,
|
||||
filesData:undefined,
|
||||
isSpin:false,
|
||||
activeKey:"1"
|
||||
activeKey:"1",
|
||||
commitCount:0,
|
||||
filesCount:0
|
||||
}
|
||||
}
|
||||
componentDidMount=()=>{
|
||||
const { footer_type } = this.props;
|
||||
const { footer_type ,data } = this.props;
|
||||
if(footer_type){
|
||||
const { projectsId , owner , mergeId } = this.props.match.params;
|
||||
this.getCommit(owner,projectsId,mergeId);
|
||||
this.getFile(owner,projectsId,mergeId);
|
||||
}
|
||||
this.setState({
|
||||
activeKey:footer_type ? "1" : "2"
|
||||
activeKey:footer_type ? "1" : "2",
|
||||
commitCount:data && data.commits_count,
|
||||
filesCount:data && data.files_count
|
||||
})
|
||||
}
|
||||
componentDidUpdate=(prevProps)=>{
|
||||
const { comparesData } = this.props;
|
||||
const { activeKey } = this.state;
|
||||
const { footer_type } = this.props;
|
||||
if(footer_type){
|
||||
const { data } = this.props;
|
||||
if(data !== prevProps.data){
|
||||
this.setState({
|
||||
commitCount:data && data.commits_count,
|
||||
filesCount:data && data.files_count
|
||||
})
|
||||
}
|
||||
}
|
||||
if(comparesData !== prevProps.comparesData){
|
||||
this.changeTab(activeKey);
|
||||
this.setState({
|
||||
activeKey:footer_type ? "1" : "2"
|
||||
})
|
||||
this.changeTab(footer_type ? "1" : "2");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -42,71 +65,88 @@ class MergeFooter extends Component {
|
|||
const { projectsId , owner , mergeId } = this.props.match.params;
|
||||
if(index === "2"){
|
||||
if(footer_type){
|
||||
const url = `/${owner}/${projectsId}/pulls/${mergeId}/commits.json`;
|
||||
axios.get(url).then(result=>{
|
||||
if(result){
|
||||
this.setState({
|
||||
pageData:result.data.commits,
|
||||
})
|
||||
}
|
||||
}).catch(error=>{})
|
||||
this.getCommit(owner,projectsId,mergeId);
|
||||
}else{
|
||||
this.setState({
|
||||
pageData:comparesData.commits
|
||||
commitsData:comparesData.commits,
|
||||
filesData:comparesData.diff,
|
||||
commitCount:comparesData.commits_count,
|
||||
filesCount:comparesData.diff && comparesData.diff.files_count,
|
||||
isSpin:false
|
||||
})
|
||||
this.setState({
|
||||
isSpin:false
|
||||
})
|
||||
}
|
||||
this.setState({
|
||||
isSpin:false
|
||||
})
|
||||
}else if(index === "3"){
|
||||
if(footer_type){
|
||||
const url = `/${owner}/${projectsId}/pulls/${mergeId}/files.json`;
|
||||
axios.get(url).then(result=>{
|
||||
if(result){
|
||||
this.setState({
|
||||
pageData:result.data,
|
||||
})
|
||||
}
|
||||
}).catch(error=>{})
|
||||
this.getFile(owner,projectsId,mergeId);
|
||||
}else{
|
||||
this.setState({
|
||||
pageData:comparesData.diff
|
||||
commitsData:comparesData.commits,
|
||||
filesData:comparesData.diff,
|
||||
filesCount:comparesData.diff && comparesData.diff.files_count,
|
||||
commitCount:comparesData.commits_count
|
||||
})
|
||||
this.setState({
|
||||
isSpin:false
|
||||
})
|
||||
}
|
||||
this.setState({
|
||||
isSpin:false
|
||||
})
|
||||
}else{
|
||||
this.setState({
|
||||
isSpin:false
|
||||
})
|
||||
}
|
||||
}
|
||||
getCommit =(owner,projectsId,mergeId)=>{
|
||||
const url = `/${owner}/${projectsId}/pulls/${mergeId}/commits.json`;
|
||||
axios.get(url).then(result=>{
|
||||
if(result){
|
||||
this.setState({
|
||||
commitsData:result.data.commits,
|
||||
isSpin:false
|
||||
})
|
||||
}
|
||||
}).catch(error=>{})
|
||||
}
|
||||
getFile =(owner,projectsId,mergeId)=>{
|
||||
const url = `/${owner}/${projectsId}/pulls/${mergeId}/files.json`;
|
||||
axios.get(url).then(result=>{
|
||||
if(result){
|
||||
this.setState({
|
||||
filesData:result.data,
|
||||
isSpin:false
|
||||
})
|
||||
}
|
||||
}).catch(error=>{})
|
||||
}
|
||||
|
||||
showDown=(flag,index,isBin)=>{
|
||||
if(!isBin){
|
||||
const { pageData } = this.state;
|
||||
const { files } = pageData;
|
||||
const { filesData } = this.state;
|
||||
const { files } = filesData;
|
||||
|
||||
let arr = files[index];
|
||||
let f = files;
|
||||
let d = pageData;
|
||||
let d = filesData;
|
||||
arr.flag = !flag ? true : false;
|
||||
|
||||
f[index] = arr;
|
||||
d.files = f;
|
||||
this.setState({
|
||||
pageData:d
|
||||
filesData:d
|
||||
});
|
||||
}
|
||||
}
|
||||
render() {
|
||||
const { projectsId , owner } = this.props.match.params;
|
||||
|
||||
const { footer_type, order_id, data } = this.props;
|
||||
let { pageData , isSpin , activeKey } = this.state;
|
||||
const { footer_type, order_id, data , comparesData } = this.props;
|
||||
let { pageData , isSpin , activeKey , filesCount, commitCount , filesData , commitsData } = this.state;
|
||||
|
||||
return (
|
||||
<div>
|
||||
!footer_type && !comparesData || (comparesData && ((comparesData.commits && comparesData.commits.length===0)||(comparesData && !comparesData.diff)) )?"":
|
||||
<div className="main" style={{paddingTop:"0px"}}>
|
||||
<Spin spinning={isSpin}>
|
||||
<Tabs
|
||||
activeKey={activeKey}
|
||||
|
@ -119,7 +159,7 @@ class MergeFooter extends Component {
|
|||
<TabPane
|
||||
tab={
|
||||
<span><span className="font-16">评论</span>
|
||||
{data && data.comments_count > 0 && <span className="tabNum">{data.comments_count}</span>}
|
||||
{data && parseInt(data.comments_count) > 0 && <span className="tabNum">{data.comments_count}</span>}
|
||||
</span>
|
||||
} key="1">
|
||||
<Comments
|
||||
|
@ -130,18 +170,25 @@ class MergeFooter extends Component {
|
|||
/>
|
||||
</TabPane>
|
||||
}
|
||||
<TabPane tab={<span><span className="font-16">提交</span>
|
||||
{data && data.commits_count > 0 && <span className="tabNum">{data.commits_count}</span>}
|
||||
</span>} key="2">
|
||||
<Commits {...this.props} commits={pageData}></Commits>
|
||||
</TabPane>
|
||||
<TabPane tab={
|
||||
<span><span className="font-16">文件</span>
|
||||
{data && data.files_count > 0 && <span className="tabNum">{data.files_count}</span>}
|
||||
</span>
|
||||
} key="3">
|
||||
<Files {...this.props} data={pageData} projectsId={projectsId} owner={owner} showDown={this.showDown} />
|
||||
</TabPane>
|
||||
{
|
||||
commitsData && commitsData.length > 0 &&
|
||||
<TabPane tab={<span><span className="font-16">提交</span>
|
||||
{commitCount > 0 && <span className="tabNum">{commitCount}</span>}
|
||||
</span>} key="2">
|
||||
<Commits {...this.props} commits={commitsData}></Commits>
|
||||
</TabPane>
|
||||
}
|
||||
{
|
||||
filesData && filesData.files && filesData.files.length>0 &&
|
||||
<TabPane tab={
|
||||
<span><span className="font-16">文件</span>
|
||||
{filesCount > 0 && <span className="tabNum">{filesCount}</span>}
|
||||
</span>
|
||||
} key="3">
|
||||
<Files {...this.props} data={filesData} projectsId={projectsId} owner={owner} showDown={this.showDown} />
|
||||
</TabPane>
|
||||
}
|
||||
|
||||
</Tabs>
|
||||
</Spin>
|
||||
</div>
|
||||
|
|
|
@ -138,7 +138,7 @@ class MergeForm extends Component {
|
|||
this.props.form.validateFieldsAndScroll((err, values) => {
|
||||
if (!err) {
|
||||
const { projectsId, mergeId , owner } = this.props.match.params;
|
||||
const { merge, pull, merge_type, data } = this.props;
|
||||
const { merge, pull, merge_type, data , commits_count , files_count } = this.props;
|
||||
if (values.issue_tag_ids && values.issue_tag_ids.length > 0) {
|
||||
values.issue_tag_ids = [parseInt(values.issue_tag_ids)];
|
||||
} else {
|
||||
|
@ -154,7 +154,9 @@ class MergeForm extends Component {
|
|||
base: merge,
|
||||
is_original: data && data.is_original,
|
||||
fork_project_id: data && data.fork_project_id,
|
||||
merge_user_login: data && data.merge_user_login
|
||||
merge_user_login: data && data.merge_user_login,
|
||||
files_count,
|
||||
commits_count
|
||||
})
|
||||
.then((result) => {
|
||||
if (result) {
|
||||
|
|
|
@ -19,7 +19,6 @@ class Setting extends Component {
|
|||
}
|
||||
|
||||
componentDidUpdate=(prevPros)=>{
|
||||
console.log("dddd",this.props.checkIfLogin());
|
||||
if(prevPros && this.props && !this.props.checkIfLogin()){
|
||||
this.props.history.push("/403")
|
||||
return
|
||||
|
|
Loading…
Reference in New Issue