dev_forge
caicai8 5 years ago
parent 69239238bd
commit 370c2fadc2

@ -1,6 +1,8 @@
import React , { Component } from 'react'; import React , { Component } from 'react';
import { Dropdown , Icon , Menu , Table } from 'antd'; import { Dropdown , Icon , Menu , Table } from 'antd';
import {Link} from 'react-router-dom'; import {Link} from 'react-router-dom';
import { getImageUrl } from 'educoder';
import axios from 'axios'; import axios from 'axios';
// 点击按钮复制功能 // 点击按钮复制功能
@ -16,7 +18,10 @@ class CoderRootDirectory extends Component{
address:"http", address:"http",
ref:"master", ref:"master",
rootList:undefined rootList:undefined,
branchList:undefined,
branchs:undefined,
branchLastCommit:undefined
} }
} }
@ -37,8 +42,20 @@ class CoderRootDirectory extends Component{
const url =`/projects/${projectsId}/branches.json`; const url =`/projects/${projectsId}/branches.json`;
axios.get(url).then((result)=>{ axios.get(url).then((result)=>{
if(result){ if(result && result.data.length>0){
const branchs = [];
result.data.map((item,key)=>{
branchs.push({
index:key,
name:item.name
})
})
this.setState({
branchList:result.data,
branchs,
branchLastCommit:result.data[0]
})
} }
}).catch((error)=>{}) }).catch((error)=>{})
} }
@ -73,17 +90,19 @@ class CoderRootDirectory extends Component{
}) })
} }
// 选择分支
changeBranch=(value)=>{
const { branchList } = this.state;
let branchLastCommit = branchList[parseInt(value.key)];
this.setState({
ref:branchLastCommit.name,
branchLastCommit
})
}
render(){ render(){
const menu = (
<Menu>
<Menu.Item key="0">
<a href="http://www.alipay.com/">1st menu item</a>
</Menu.Item>
<Menu.Item key="1">
<a href="http://www.taobao.com/">2nd menu item</a>
</Menu.Item>
</Menu>
);
const columns = [ const columns = [
{ {
@ -95,19 +114,40 @@ class CoderRootDirectory extends Component{
} }
]; ];
const { address , ref , rootList , branchList , branchs, branchLastCommit } = this.state;
const menu = (
<Menu>
{
branchs && branchs.map((item,key)=>{
return(
<Menu.Item key={item.index} onClick={this.changeBranch}>{item.name}</Menu.Item>
)
})
}
</Menu>
);
const title = () =>{ const title = () =>{
return( if(branchLastCommit && branchLastCommit.last_commit){
<div className="f-wrap-alignCenter"> return(
<img src={``} alt=""/> <div className="f-wrap-alignCenter">
<span>蔡蔡</span> {
<Link to={``} className="commitKey">asljfowfjoer</Link> branchLastCommit.author ?
<span className="color-blue flex-1 hide-1">first commit</span> <React.Fragment>
<span>3小时前</span> <img src={getImageUrl(`/images${branchLastCommit.author.image_url}`)} alt=""/>
</div> <span className="mr15">{branchLastCommit.author.login}</span>
) </React.Fragment>
:""
}
<Link to={``} className="commitKey">{branchLastCommit.last_commit.id}</Link>
<span className="color-blue flex-1 hide-1">{branchLastCommit.last_commit.message}</span>
<span>{branchLastCommit.last_commit.time_from_now}</span>
</div>
)
}else{
return undefined;
}
} }
const { address , ref , rootList } = this.state;
return( return(
<div className="main"> <div className="main">
<p className="branch-wrapper"> <p className="branch-wrapper">
@ -128,7 +168,7 @@ class CoderRootDirectory extends Component{
<span className={address ==="http" ? "addressType active":"addressType"} onClick={()=>this.changeAddress("http")}>HTTP</span> <span className={address ==="http" ? "addressType active":"addressType"} onClick={()=>this.changeAddress("http")}>HTTP</span>
<span className={address ==="ssh" ? "addressType active":"addressType"} onClick={()=>this.changeAddress("ssh")}>SSH</span> <span className={address ==="ssh" ? "addressType active":"addressType"} onClick={()=>this.changeAddress("ssh")}>SSH</span>
<input type="text" id="copy_rep_content" value={"git@testgitea.trustie.net:sylor/test11.git"}/> <input type="text" id="copy_rep_content" value={"git@testgitea.trustie.net:sylor/test11.git"}/>
<span><i className="iconfont icon-fuzhi"></i></span> <span onClick={()=>jsCopy()}><i className="iconfont icon-fuzhi"></i></span>
<span> <span>
<Dropdown overlay={menu} trigger={['click']} placement="bottomRight"> <Dropdown overlay={menu} trigger={['click']} placement="bottomRight">
<a className="ant-dropdown-link"> <a className="ant-dropdown-link">

@ -256,8 +256,9 @@ body,#root{
padding:0px 5px; padding:0px 5px;
height: 28px; height: 28px;
line-height: 28px; line-height: 28px;
margin:0px 15px; margin-right:15px;
border-radius: 4px; border-radius: 4px;
max-width: 100%;
} }
@media screen and (max-width: 750px){ @media screen and (max-width: 750px){
@ -291,4 +292,7 @@ body,#root{
.p-r-about{ .p-r-about{
flex-wrap: wrap; flex-wrap: wrap;
} }
.commitKey{
margin-right: 0px;
}
} }

Loading…
Cancel
Save