|
|
|
@ -8,6 +8,7 @@ import './list.css';
|
|
|
|
|
import SelectBranch from '../Branch/SelectBranch';
|
|
|
|
|
import CloneAddress from '../Branch/CloneAddress';
|
|
|
|
|
import RootTable from './RootTable';
|
|
|
|
|
import CoderRootFileDetail from './CoderRootFileDetail';
|
|
|
|
|
|
|
|
|
|
import axios from 'axios';
|
|
|
|
|
class CoderRootDirectory extends Component{
|
|
|
|
@ -16,9 +17,11 @@ class CoderRootDirectory extends Component{
|
|
|
|
|
this.state={
|
|
|
|
|
address:"http",
|
|
|
|
|
branch:"master",
|
|
|
|
|
filePath:[],
|
|
|
|
|
http_url:undefined,
|
|
|
|
|
|
|
|
|
|
branchList:undefined,
|
|
|
|
|
fileDetail:undefined,
|
|
|
|
|
branchLastCommit:undefined
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -32,7 +35,7 @@ class CoderRootDirectory extends Component{
|
|
|
|
|
this.getProjectRoot();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 获取分支文件
|
|
|
|
|
// 获取根目录
|
|
|
|
|
getProjectRoot=(branch)=>{
|
|
|
|
|
const { login } = this.props.current_user;
|
|
|
|
|
const { projectsId } = this.props.match.params;
|
|
|
|
@ -44,11 +47,76 @@ class CoderRootDirectory extends Component{
|
|
|
|
|
}
|
|
|
|
|
}).then((result)=>{
|
|
|
|
|
if(result && result.data && result.data.length > 0){
|
|
|
|
|
this.setState({
|
|
|
|
|
filePath:[],
|
|
|
|
|
fileDetail:undefined
|
|
|
|
|
})
|
|
|
|
|
this.renderData(result.data)
|
|
|
|
|
}
|
|
|
|
|
}).catch((error)=>{})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ChangeFile=(arr)=>{
|
|
|
|
|
this.renderUrl(arr);
|
|
|
|
|
this.getFileDetail(arr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
renderUrl=(array)=>{
|
|
|
|
|
if(array && array.path){
|
|
|
|
|
let { path } = array;
|
|
|
|
|
let list = [];
|
|
|
|
|
let urlList=Object.assign({},array);
|
|
|
|
|
let str = "";
|
|
|
|
|
if(path.indexOf("/")>0){
|
|
|
|
|
const wraps = path.split("/");
|
|
|
|
|
wraps.map((item,key)=>{
|
|
|
|
|
str += '/'+item;
|
|
|
|
|
urlList.path = str.substr(1);
|
|
|
|
|
urlList.name = item;
|
|
|
|
|
list.push({...urlList});
|
|
|
|
|
})
|
|
|
|
|
}else{
|
|
|
|
|
urlList.path = '';
|
|
|
|
|
urlList.name = path;
|
|
|
|
|
list.push({...urlList});
|
|
|
|
|
}
|
|
|
|
|
this.setState({
|
|
|
|
|
filePath:list
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 获取子目录
|
|
|
|
|
getFileDetail=(arr)=>{
|
|
|
|
|
const { current_user } = this.props;
|
|
|
|
|
const { projectsId } = this.props.match.params;
|
|
|
|
|
const { branch } = this.state;
|
|
|
|
|
const url =`/${current_user.login}/${projectsId}/sub_entries.json`;
|
|
|
|
|
|
|
|
|
|
axios.get(url,{
|
|
|
|
|
params:{
|
|
|
|
|
filepath:arr.path,
|
|
|
|
|
ref:branch
|
|
|
|
|
}
|
|
|
|
|
}).then((result)=>{
|
|
|
|
|
if(result && result.data && result.data.length > 0){
|
|
|
|
|
if(arr.type==="file"){
|
|
|
|
|
this.setState({
|
|
|
|
|
fileDetail:result.data[0],
|
|
|
|
|
rootList:undefined
|
|
|
|
|
})
|
|
|
|
|
}else{
|
|
|
|
|
this.setState({
|
|
|
|
|
fileDetail:undefined
|
|
|
|
|
})
|
|
|
|
|
this.renderData(result.data)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}).catch((error)=>{
|
|
|
|
|
console.log(error);
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
renderData=(data)=>{
|
|
|
|
|
const rootList = [];
|
|
|
|
|
data && data.map((item,key)=>{
|
|
|
|
@ -74,7 +142,7 @@ class CoderRootDirectory extends Component{
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
render(){
|
|
|
|
|
const { rootList , branch } = this.state;
|
|
|
|
|
const { rootList , branch ,filePath , fileDetail } = this.state;
|
|
|
|
|
|
|
|
|
|
const { branchLastCommit , http_url } = this.props;
|
|
|
|
|
const { projectsId } = this.props.match.params;
|
|
|
|
@ -84,7 +152,7 @@ class CoderRootDirectory extends Component{
|
|
|
|
|
dataIndex: 'name',
|
|
|
|
|
width:"100%",
|
|
|
|
|
render: (text,item) => (
|
|
|
|
|
<a href={`/projects/${projectsId}/${item.path}`}>
|
|
|
|
|
<a onClick={()=>this.ChangeFile(item)}>
|
|
|
|
|
<i className={ item.type === "file" ? "iconfont icon-zuoye font-15 color-blue mr5":"iconfont icon-wenjian font-15 color-blue mr5"}></i>{text}
|
|
|
|
|
</a>
|
|
|
|
|
),
|
|
|
|
@ -111,6 +179,7 @@ class CoderRootDirectory extends Component{
|
|
|
|
|
return undefined;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const downloadUrl = ()=>{
|
|
|
|
|
if(branchLastCommit && branchLastCommit.zip_url){
|
|
|
|
|
return(
|
|
|
|
@ -124,10 +193,45 @@ class CoderRootDirectory extends Component{
|
|
|
|
|
return(
|
|
|
|
|
<div>
|
|
|
|
|
<div className="f-wrap-between mt20">
|
|
|
|
|
<SelectBranch branch={branch} changeBranch={this.changeBranch} {...this.props} {...this.state}></SelectBranch>
|
|
|
|
|
<CloneAddress http_url={http_url} downloadUrl={downloadUrl}></CloneAddress>
|
|
|
|
|
<div className="f-wrap-alignCenter">
|
|
|
|
|
<SelectBranch branch={branch} changeBranch={this.changeBranch} {...this.props} {...this.state}></SelectBranch>
|
|
|
|
|
{
|
|
|
|
|
filePath && filePath.length > 0 &&
|
|
|
|
|
<span className="ml20 font-16">
|
|
|
|
|
<a onClick={()=>this.getProjectRoot(branch)} className="color-blue">{projectsId}</a>
|
|
|
|
|
{
|
|
|
|
|
filePath.map((item,key)=>{
|
|
|
|
|
return(
|
|
|
|
|
<React.Fragment>
|
|
|
|
|
{
|
|
|
|
|
key === filePath.length-1 ?
|
|
|
|
|
<span className="color-grey-6 subFileName">{item.name}</span>
|
|
|
|
|
:
|
|
|
|
|
<a onClick={()=>this.ChangeFile(item)} className="color-blue subFileName">{item.name}</a>
|
|
|
|
|
}
|
|
|
|
|
</React.Fragment>
|
|
|
|
|
)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
{
|
|
|
|
|
filePath && filePath.length === 0 && <CloneAddress http_url={http_url} downloadUrl={downloadUrl}></CloneAddress>
|
|
|
|
|
}
|
|
|
|
|
</div>
|
|
|
|
|
<RootTable columns = {columns} data={rootList} title={() => title()}></RootTable>
|
|
|
|
|
{/* 文件夹-子目录列表 */}
|
|
|
|
|
{
|
|
|
|
|
rootList && <RootTable columns = {columns} data={rootList} title={() => title()}></RootTable>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
fileDetail &&
|
|
|
|
|
<CoderRootFileDetail detail = {fileDetail}></CoderRootFileDetail>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|