|
|
|
@ -5,6 +5,8 @@ import {Link} from 'react-router-dom';
|
|
|
|
|
import { getImageUrl } from 'educoder';
|
|
|
|
|
import axios from 'axios';
|
|
|
|
|
|
|
|
|
|
import SelectBranch from '../Branch/SelectBranch'
|
|
|
|
|
|
|
|
|
|
// 点击按钮复制功能
|
|
|
|
|
function jsCopy(){
|
|
|
|
|
var e = document.getElementById("copy_rep_content");
|
|
|
|
@ -16,7 +18,8 @@ class CoderRootDirectory extends Component{
|
|
|
|
|
super(props);
|
|
|
|
|
this.state={
|
|
|
|
|
address:"http",
|
|
|
|
|
ref:"master",
|
|
|
|
|
branch:"master",
|
|
|
|
|
http_url:undefined,
|
|
|
|
|
|
|
|
|
|
rootList:undefined,
|
|
|
|
|
branchList:undefined,
|
|
|
|
@ -54,21 +57,22 @@ class CoderRootDirectory extends Component{
|
|
|
|
|
this.setState({
|
|
|
|
|
branchList:result.data,
|
|
|
|
|
branchs,
|
|
|
|
|
branchLastCommit:result.data[0]
|
|
|
|
|
branchLastCommit:result.data[0],
|
|
|
|
|
http_url:result.data[0].http_url
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}).catch((error)=>{})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 获取分支文件
|
|
|
|
|
getProjectRoot=(ref)=>{
|
|
|
|
|
getProjectRoot=(branch)=>{
|
|
|
|
|
const { login } = this.props.current_user;
|
|
|
|
|
const { projectsId } = this.props.match.params;
|
|
|
|
|
|
|
|
|
|
const url = `/${login}/${projectsId}/entries.json`;
|
|
|
|
|
axios.get((url),{
|
|
|
|
|
params:{
|
|
|
|
|
ref
|
|
|
|
|
branch
|
|
|
|
|
}
|
|
|
|
|
}).then((result)=>{
|
|
|
|
|
if(result && result.data && result.data.length > 0){
|
|
|
|
@ -96,8 +100,9 @@ class CoderRootDirectory extends Component{
|
|
|
|
|
let branchLastCommit = branchList[parseInt(value.key)];
|
|
|
|
|
|
|
|
|
|
this.setState({
|
|
|
|
|
ref:branchLastCommit.name,
|
|
|
|
|
branchLastCommit
|
|
|
|
|
branch:branchLastCommit.name,
|
|
|
|
|
branchLastCommit,
|
|
|
|
|
http_url:branchLastCommit.http_url
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -114,18 +119,8 @@ 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 { branch , rootList , branchs, branchLastCommit , http_url } = this.state;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const title = () =>{
|
|
|
|
|
if(branchLastCommit && branchLastCommit.last_commit){
|
|
|
|
@ -134,7 +129,7 @@ class CoderRootDirectory extends Component{
|
|
|
|
|
{
|
|
|
|
|
branchLastCommit.author ?
|
|
|
|
|
<React.Fragment>
|
|
|
|
|
<img src={getImageUrl(`/images${branchLastCommit.author.image_url}`)} alt=""/>
|
|
|
|
|
<img src={getImageUrl(`images/${branchLastCommit.author.image_url}`)} alt=""/>
|
|
|
|
|
<span className="mr15">{branchLastCommit.author.login}</span>
|
|
|
|
|
</React.Fragment>
|
|
|
|
|
:""
|
|
|
|
@ -148,6 +143,17 @@ class CoderRootDirectory extends Component{
|
|
|
|
|
return undefined;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const downloadUrl = ()=>{
|
|
|
|
|
if(branchLastCommit && branchLastCommit.zip_url){
|
|
|
|
|
return(
|
|
|
|
|
<Menu>
|
|
|
|
|
<Menu.Item><a href={branchLastCommit.zip_url}>ZIP</a></Menu.Item>
|
|
|
|
|
<Menu.Item><a href={branchLastCommit.tar_url}>TAR.GZ</a></Menu.Item>
|
|
|
|
|
</Menu>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return(
|
|
|
|
|
<div className="main">
|
|
|
|
|
<p className="branch-wrapper">
|
|
|
|
@ -156,21 +162,14 @@ class CoderRootDirectory extends Component{
|
|
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
<div className="f-wrap-between mt20">
|
|
|
|
|
<div className="branchDropdown">
|
|
|
|
|
<span className="color-grey-9 mr3"><i className="iconfont icon-fenzhi font-20 color-grey-6 mr3"></i>分支:</span>
|
|
|
|
|
<Dropdown overlay={menu} trigger={['click']} placement="bottomRight">
|
|
|
|
|
<a className="ant-dropdown-link">
|
|
|
|
|
{ref} <Icon type="down" />
|
|
|
|
|
</a>
|
|
|
|
|
</Dropdown>
|
|
|
|
|
</div>
|
|
|
|
|
<SelectBranch branch={branch} branchs={branchs} changeBranch={this.changeBranch}></SelectBranch>
|
|
|
|
|
<div className="gitAddressClone">
|
|
|
|
|
<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>
|
|
|
|
|
<input type="text" id="copy_rep_content" value={"git@testgitea.trustie.net:sylor/test11.git"}/>
|
|
|
|
|
<span className={"addressType active"} onClick={()=>this.changeAddress("http")}>HTTP</span>
|
|
|
|
|
{/* <span className={address ==="ssh" ? "addressType active":"addressType"} onClick={()=>this.changeAddress("ssh")}>SSH</span> */}
|
|
|
|
|
<input type="text" id="copy_rep_content" value={ http_url }/>
|
|
|
|
|
<span onClick={()=>jsCopy()}><i className="iconfont icon-fuzhi"></i></span>
|
|
|
|
|
<span>
|
|
|
|
|
<Dropdown overlay={menu} trigger={['click']} placement="bottomRight">
|
|
|
|
|
<Dropdown overlay={downloadUrl} trigger={['click']} placement="bottomRight">
|
|
|
|
|
<a className="ant-dropdown-link">
|
|
|
|
|
<Icon type="cloud-download" className="font-18 fl"/>
|
|
|
|
|
</a>
|
|
|
|
|