2020-03-16 14:12:11 +08:00
|
|
|
import React , { Component } from 'react';
|
2020-05-20 18:11:32 +08:00
|
|
|
import { Route , Switch } from 'react-router-dom';
|
2020-07-03 16:32:47 +08:00
|
|
|
import Top from './DetailTop';
|
2020-03-16 14:12:11 +08:00
|
|
|
import Loadable from 'react-loadable';
|
|
|
|
|
import Loading from '../../Loading';
|
2020-07-03 16:32:47 +08:00
|
|
|
import axios from 'axios';
|
2020-03-16 14:12:11 +08:00
|
|
|
|
2020-07-03 16:32:47 +08:00
|
|
|
const FileNew = Loadable({
|
|
|
|
|
loader: () => import('../Newfile/Index'),
|
|
|
|
|
loading: Loading,
|
|
|
|
|
})
|
|
|
|
|
const UploadFile = Loadable({
|
|
|
|
|
loader: () => import('../Newfile/upload_file'),
|
|
|
|
|
loading: Loading,
|
|
|
|
|
})
|
2020-03-16 14:12:11 +08:00
|
|
|
const CoderRootDirectory = Loadable({
|
|
|
|
|
loader: () => import('./CoderRootDirectory'),
|
|
|
|
|
loading: Loading,
|
|
|
|
|
})
|
|
|
|
|
const CoderRootCommit = Loadable({
|
|
|
|
|
loader: () => import('./CoderRootCommit'),
|
|
|
|
|
loading: Loading,
|
|
|
|
|
})
|
|
|
|
|
const CoderRootBranch = Loadable({
|
|
|
|
|
loader: () => import('./CoderRootBranch'),
|
|
|
|
|
loading: Loading,
|
|
|
|
|
})
|
2020-05-20 18:11:32 +08:00
|
|
|
const CoderRootTag = Loadable({
|
|
|
|
|
loader: () => import('./CoderRootTag'),
|
|
|
|
|
loading: Loading,
|
|
|
|
|
})
|
|
|
|
|
const CoderRootVersion = Loadable({
|
|
|
|
|
loader: () => import('../Version/version'),
|
|
|
|
|
loading: Loading,
|
|
|
|
|
})
|
|
|
|
|
const CoderRootVersionNew = Loadable({
|
2020-05-28 11:35:57 +08:00
|
|
|
loader: () => import('../Version/New'),
|
2020-05-20 18:11:32 +08:00
|
|
|
loading: Loading,
|
|
|
|
|
})
|
|
|
|
|
const CoderRootVersionUpdate = Loadable({
|
2020-05-28 11:35:57 +08:00
|
|
|
loader: () => import('../Version/New'),
|
2020-05-20 18:11:32 +08:00
|
|
|
loading: Loading,
|
|
|
|
|
})
|
2020-05-29 17:00:42 +08:00
|
|
|
const Diff = Loadable({
|
|
|
|
|
loader: () => import('./Diff'),
|
|
|
|
|
loading: Loading,
|
|
|
|
|
})
|
2020-03-30 18:51:30 +08:00
|
|
|
|
2020-03-16 14:12:11 +08:00
|
|
|
class CoderRootIndex extends Component{
|
2020-07-03 16:32:47 +08:00
|
|
|
constructor(props){
|
|
|
|
|
super(props);
|
|
|
|
|
this.state={
|
|
|
|
|
coderCount:undefined
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
componentDidMount=()=>{
|
|
|
|
|
let { search } = this.props.history.location;
|
|
|
|
|
let branchName = undefined;
|
|
|
|
|
if (search && search.indexOf("?branch=") > -1) {
|
|
|
|
|
branchName = search.split("?branch=")[1];
|
|
|
|
|
}
|
|
|
|
|
this.getTopCount(branchName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getTopCount=(branch)=>{
|
|
|
|
|
const { projectsId } = this.props.match.params;
|
|
|
|
|
const url = `/repositories/${projectsId}/top_counts.json`;
|
|
|
|
|
axios.get(url,{params:{
|
|
|
|
|
ref:branch
|
|
|
|
|
}}).then(result=>{
|
|
|
|
|
if(result){
|
|
|
|
|
this.setState({
|
|
|
|
|
coderCount:result.data
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}).catch(error=>{console.log(error);})
|
|
|
|
|
}
|
2020-03-16 14:12:11 +08:00
|
|
|
render(){
|
|
|
|
|
return(
|
2020-05-20 18:11:32 +08:00
|
|
|
<div>
|
2020-07-03 16:32:47 +08:00
|
|
|
<Top {...this.props} {...this.state}/>
|
2020-03-16 14:12:11 +08:00
|
|
|
<Switch {...this.props}>
|
2020-07-03 16:32:47 +08:00
|
|
|
{/* 新建文件 */}
|
|
|
|
|
<Route path="/projects/:projectsId/coders/:branch/newfile/:path"
|
|
|
|
|
render={
|
|
|
|
|
(props) => (<FileNew {...this.props} {...props} {...this.state} />)
|
|
|
|
|
}
|
|
|
|
|
></Route>
|
|
|
|
|
<Route path="/projects/:projectsId/coders/:branch/uploadfile"
|
|
|
|
|
render={
|
|
|
|
|
(props) => (<UploadFile {...this.props} {...props} {...this.state} />)
|
|
|
|
|
}
|
|
|
|
|
></Route>
|
|
|
|
|
<Route path="/projects/:projectsId/coders/:branch/newfile"
|
|
|
|
|
render={
|
2020-07-03 17:26:07 +08:00
|
|
|
(props) => (<FileNew {...this.props} {...props} {...this.state} getTopCount={this.getTopCount} />)
|
2020-07-03 16:32:47 +08:00
|
|
|
}
|
|
|
|
|
></Route>
|
2020-03-20 21:40:43 +08:00
|
|
|
<Route path="/projects/:projectsId/coders/commit"
|
2020-03-16 14:12:11 +08:00
|
|
|
render={
|
2020-07-03 16:32:47 +08:00
|
|
|
() => (<CoderRootCommit {...this.props} {...this.state} commit_class="main" getTopCount={this.getTopCount} />)
|
2020-03-16 14:12:11 +08:00
|
|
|
}
|
|
|
|
|
></Route>
|
2020-05-29 17:00:42 +08:00
|
|
|
{/* diff */}
|
2020-06-03 09:56:07 +08:00
|
|
|
<Route path="/projects/:projectsId/diff/:sha"
|
2020-05-29 17:00:42 +08:00
|
|
|
render={
|
2020-07-03 16:32:47 +08:00
|
|
|
() => (<Diff {...this.props} {...this.state}/>)
|
2020-05-29 17:00:42 +08:00
|
|
|
}
|
|
|
|
|
></Route>
|
2020-05-20 18:11:32 +08:00
|
|
|
<Route path="/projects/:projectsId/coders/version/new"
|
|
|
|
|
render={
|
2020-07-03 16:32:47 +08:00
|
|
|
() => (<CoderRootVersionNew {...this.props} {...this.state} />)
|
2020-05-20 18:11:32 +08:00
|
|
|
}
|
|
|
|
|
></Route>
|
|
|
|
|
|
|
|
|
|
<Route path="/projects/:projectsId/coders/version/:versionId/update"
|
|
|
|
|
render={
|
2020-07-03 16:32:47 +08:00
|
|
|
() => (<CoderRootVersionUpdate {...this.props} {...this.state} />)
|
2020-05-20 18:11:32 +08:00
|
|
|
}
|
|
|
|
|
></Route>
|
2020-06-29 11:34:05 +08:00
|
|
|
|
2020-05-20 18:11:32 +08:00
|
|
|
<Route path="/projects/:projectsId/coders/version"
|
|
|
|
|
render={
|
2020-07-03 16:32:47 +08:00
|
|
|
() => (<CoderRootVersion {...this.props} {...this.state} />)
|
2020-05-20 18:11:32 +08:00
|
|
|
}
|
|
|
|
|
></Route>
|
|
|
|
|
<Route path="/projects/:projectsId/coders/tag"
|
|
|
|
|
render={
|
2020-07-03 16:32:47 +08:00
|
|
|
() => (<CoderRootTag {...this.props} {...this.state} />)
|
2020-05-20 18:11:32 +08:00
|
|
|
}
|
|
|
|
|
></Route>
|
2020-03-20 21:40:43 +08:00
|
|
|
<Route path="/projects/:projectsId/coders/branch"
|
2020-03-16 14:12:11 +08:00
|
|
|
render={
|
2020-07-03 16:32:47 +08:00
|
|
|
() => (<CoderRootBranch {...this.props} {...this.state} />)
|
2020-03-16 14:12:11 +08:00
|
|
|
}
|
|
|
|
|
></Route>
|
2020-03-20 21:40:43 +08:00
|
|
|
<Route path="/projects/:projectsId/coders"
|
2020-03-16 14:12:11 +08:00
|
|
|
render={
|
2020-07-03 16:32:47 +08:00
|
|
|
() => (<CoderRootDirectory {...this.props} {...this.state} getTopCount={this.getTopCount} />)
|
2020-03-16 14:12:11 +08:00
|
|
|
}
|
|
|
|
|
></Route>
|
2020-03-20 21:40:43 +08:00
|
|
|
<Route path="/projects/:projectsId"
|
2020-03-16 14:12:11 +08:00
|
|
|
render={
|
2020-07-03 16:32:47 +08:00
|
|
|
() => (<CoderRootDirectory {...this.props} {...this.state} getTopCount={this.getTopCount} />)
|
2020-03-16 14:12:11 +08:00
|
|
|
}
|
|
|
|
|
></Route>
|
|
|
|
|
</Switch>
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-06-29 11:34:05 +08:00
|
|
|
export default CoderRootIndex;
|