|
|
|
@ -2,6 +2,7 @@ import React , { Component } from 'react';
|
|
|
|
|
import {Menu, Spin} from 'antd';
|
|
|
|
|
import { getImageUrl , markdownToHTML } from 'educoder';
|
|
|
|
|
import { Router , Route , Link } from 'react-router-dom';
|
|
|
|
|
import Top from './DetailTop';
|
|
|
|
|
|
|
|
|
|
import './list.css';
|
|
|
|
|
|
|
|
|
@ -9,6 +10,7 @@ import SelectBranch from '../Branch/SelectBranch';
|
|
|
|
|
import CloneAddress from '../Branch/CloneAddress';
|
|
|
|
|
import RootTable from './RootTable';
|
|
|
|
|
import CoderRootFileDetail from './CoderRootFileDetail';
|
|
|
|
|
import NullData from './NullData';
|
|
|
|
|
|
|
|
|
|
import axios from 'axios';
|
|
|
|
|
/**
|
|
|
|
@ -29,13 +31,14 @@ class CoderRootDirectory extends Component{
|
|
|
|
|
subFileType:"",
|
|
|
|
|
readMeContent:undefined,
|
|
|
|
|
|
|
|
|
|
isSpin:false,
|
|
|
|
|
isSpin:true,
|
|
|
|
|
|
|
|
|
|
branchList:undefined,
|
|
|
|
|
fileDetail:undefined,
|
|
|
|
|
branchLastCommit:undefined,
|
|
|
|
|
current_user:undefined,
|
|
|
|
|
|
|
|
|
|
rootData:undefined
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
changeAddress=(address)=>{
|
|
|
|
@ -44,22 +47,7 @@ class CoderRootDirectory extends Component{
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// getUserInfo=()=>{
|
|
|
|
|
// const url = `/users/me.json`;
|
|
|
|
|
// axios.get(url).then(result=>{
|
|
|
|
|
// if(result && result.data.login){
|
|
|
|
|
// this.setState({
|
|
|
|
|
// current_user:result.data
|
|
|
|
|
// })
|
|
|
|
|
// this.getProjectRoot();
|
|
|
|
|
// }
|
|
|
|
|
// }).catch(error=>{
|
|
|
|
|
// console.log(error)
|
|
|
|
|
// })
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
componentDidMount=()=>{
|
|
|
|
|
// this.getUserInfo();
|
|
|
|
|
let { search } = this.props.history.location;
|
|
|
|
|
let branchName = undefined;
|
|
|
|
|
if(search && search.indexOf("branch")>-1){
|
|
|
|
@ -74,10 +62,9 @@ class CoderRootDirectory extends Component{
|
|
|
|
|
|
|
|
|
|
// 获取根目录
|
|
|
|
|
getProjectRoot=(branch)=>{
|
|
|
|
|
console.log("root",this.props);
|
|
|
|
|
const { current_user } = this.props;
|
|
|
|
|
const { projectsId } = this.props.match.params;
|
|
|
|
|
const url = `/${current_user && current_user.login}/${projectsId}/entries.json`;
|
|
|
|
|
const url = `/${current_user && current_user.login}/${projectsId}/entries.json`;
|
|
|
|
|
axios.get((url),{
|
|
|
|
|
params:{
|
|
|
|
|
branch
|
|
|
|
@ -89,7 +76,10 @@ class CoderRootDirectory extends Component{
|
|
|
|
|
fileDetail:undefined,
|
|
|
|
|
isSpin: false
|
|
|
|
|
})
|
|
|
|
|
this.renderData(result.data)
|
|
|
|
|
this.renderData(result.data);
|
|
|
|
|
this.setState({
|
|
|
|
|
rootData:result.data
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}).catch((error)=>{})
|
|
|
|
|
}
|
|
|
|
@ -215,7 +205,7 @@ class CoderRootDirectory extends Component{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
render(){
|
|
|
|
|
const { rootList , branch ,filePath , fileDetail , subFileType , readMeContent, isSpin } = this.state;
|
|
|
|
|
const { rootList , branch ,filePath , fileDetail , subFileType , readMeContent, isSpin , rootData } = this.state;
|
|
|
|
|
|
|
|
|
|
const { branchLastCommit , http_url , isManager , isDeveloper } = this.props;
|
|
|
|
|
const { projectsId } = this.props.match.params;
|
|
|
|
@ -266,61 +256,74 @@ class CoderRootDirectory extends Component{
|
|
|
|
|
|
|
|
|
|
const urlRoot = filePath && filePath.length > 0 ? `/${filePath[filePath.length - 1].path}` : "";
|
|
|
|
|
return(
|
|
|
|
|
<div>
|
|
|
|
|
<div className="f-wrap-between mt20">
|
|
|
|
|
<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>
|
|
|
|
|
<React.Fragment>
|
|
|
|
|
{
|
|
|
|
|
rootData &&
|
|
|
|
|
<React.Fragment>
|
|
|
|
|
{
|
|
|
|
|
rootData.length > 0 ?
|
|
|
|
|
<div>
|
|
|
|
|
<Top { ...this.props } {...this.state} />
|
|
|
|
|
<div className="f-wrap-between mt20">
|
|
|
|
|
<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" key={key}>{item.name}</span>
|
|
|
|
|
:
|
|
|
|
|
<a onClick={()=>this.ChangeFile(item,key)} className="color-blue subFileName" key={key}>{item.name}</a>
|
|
|
|
|
}
|
|
|
|
|
</React.Fragment>
|
|
|
|
|
)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
<div className="f-wrap-alignCenter">
|
|
|
|
|
{
|
|
|
|
|
subFileType !== "file" && isManager && isDeveloper &&
|
|
|
|
|
<p className="addFile">
|
|
|
|
|
<Link to={`/projects/${projectsId}/coder/${branch}/newfile${urlRoot}`} >新建文件</Link>
|
|
|
|
|
<Link to={``}>上传文件</Link>
|
|
|
|
|
</p>
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
filePath && filePath.length === 0 && <CloneAddress http_url={http_url} downloadUrl={downloadUrl} showNotification={this.props.showNotification}></CloneAddress>
|
|
|
|
|
}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<Spin spinning={isSpin}>
|
|
|
|
|
{/* 文件夹-子目录列表 */}
|
|
|
|
|
{
|
|
|
|
|
filePath.map((item,key)=>{
|
|
|
|
|
return(
|
|
|
|
|
<React.Fragment>
|
|
|
|
|
{
|
|
|
|
|
key === filePath.length-1 ?
|
|
|
|
|
<span className="color-grey-6 subFileName" key={key}>{item.name}</span>
|
|
|
|
|
:
|
|
|
|
|
<a onClick={()=>this.ChangeFile(item,key)} className="color-blue subFileName" key={key}>{item.name}</a>
|
|
|
|
|
}
|
|
|
|
|
</React.Fragment>
|
|
|
|
|
)
|
|
|
|
|
})
|
|
|
|
|
rootList && <RootTable columns = {columns} data={rootList} title={() => title()}></RootTable>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
<div className="f-wrap-alignCenter">
|
|
|
|
|
{
|
|
|
|
|
subFileType !== "file" && isManager && isDeveloper &&
|
|
|
|
|
<p className="addFile">
|
|
|
|
|
<Link to={`/projects/${projectsId}/coder/${branch}/newfile${urlRoot}`} >新建文件</Link>
|
|
|
|
|
<Link to={``}>上传文件</Link>
|
|
|
|
|
</p>
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
filePath && filePath.length === 0 && <CloneAddress http_url={http_url} downloadUrl={downloadUrl} showNotification={this.props.showNotification}></CloneAddress>
|
|
|
|
|
}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<Spin spinning={isSpin}>
|
|
|
|
|
{/* 文件夹-子目录列表 */}
|
|
|
|
|
{
|
|
|
|
|
rootList && <RootTable columns = {columns} data={rootList} title={() => title()}></RootTable>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
fileDetail &&
|
|
|
|
|
<CoderRootFileDetail detail = {fileDetail} {...this.props} {...this.state}></CoderRootFileDetail>
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
fileDetail &&
|
|
|
|
|
<CoderRootFileDetail detail = {fileDetail} {...this.props} {...this.state}></CoderRootFileDetail>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{/* readme.txt */}
|
|
|
|
|
{ this.renderReadMeContent(readMeContent) }
|
|
|
|
|
</Spin>
|
|
|
|
|
</div>
|
|
|
|
|
{/* readme.txt */}
|
|
|
|
|
{ this.renderReadMeContent(readMeContent) }
|
|
|
|
|
</Spin>
|
|
|
|
|
</div>
|
|
|
|
|
:
|
|
|
|
|
<NullData {...this.props} {...this.state} http_url={http_url} ></NullData>
|
|
|
|
|
}
|
|
|
|
|
</React.Fragment>
|
|
|
|
|
}
|
|
|
|
|
</React.Fragment>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|