import React , { Component } from 'react';
import { Route , Switch } from 'react-router-dom';
// import Top from './DetailTop';
import Loadable from 'react-loadable';
import Loading from '../../Loading';
import './Index.scss';

const FileNew = Loadable({
  loader: () => import('../Newfile/Index'),
  loading: Loading,
})
const UploadFile = Loadable({
  loader: () => import('../Newfile/upload_file'),
  loading: Loading,
})
const CoderRootCommit = Loadable({
	loader: () => import('./CoderRootCommit'),
	loading: Loading,
})
const CoderRootBranch = Loadable({
	loader: () => import('./tree/Index'),
	loading: Loading,
})
const CoderRootTag = Loadable({
  loader: () => import('./tag/Index'),
  loading: Loading,
})
const CoderRootVersion = Loadable({
  loader: () => import('./version/Index'),
  loading: Loading,
})
const Diff =  Loadable({
  loader: () => import('./Diff'),
  loading: Loading,
})

class CoderRootIndex extends Component{
  constructor(props){
    super(props);
    this.state={
      coderCount:undefined
    }
  }

  render(){
    return(
      <div className="coderSubPage">
        {/* <Top {...this.props} {...this.state}/> */}
        <Switch {...this.props}>
          {/* 新建文件 */}
          <Route path="/:owner/:projectsId/:branch/newfile/:path"
            render={
              (props) => (<FileNew {...this.props} {...props} {...this.state} />)
            }
          ></Route>
          <Route path="/:owner/:projectsId/:branch/uploadfile"
            render={
              (props) => (<UploadFile {...this.props} {...props} {...this.state} />)
            }
          ></Route>
          <Route path="/:owner/:projectsId/:branch/newfile"
            render={
              (props) => (<FileNew {...this.props} {...props} {...this.state} />)
            }
          ></Route>
          <Route path="/:owner/:projectsId/commits/branch/:branchName"
            render={
              () => (<CoderRootCommit {...this.props} {...this.state} commit_class="main" />)
            }
          ></Route>
          <Route path="/:owner/:projectsId/commits/:sha"
            render={
              (props) => (<Diff {...this.props} {...props} {...this.state}/>)
            }
          ></Route>
          <Route path="/:owner/:projectsId/commits"
            render={
              () => (<CoderRootCommit {...this.props} {...this.state} commit_class="main" />)
            }
          ></Route>
          {/* <Route path="/:owner/:projectsId/releases/:versionId/update"
            render={
              (props) => (<CoderRootVersionUpdate {...this.props} {...this.state} {...props} />)
            }
          ></Route>
          <Route path="/:owner/:projectsId/releases/new"
            render={
              () => (<CoderRootVersionNew {...this.props} {...this.state} />)
            }
          ></Route> */}
          <Route path="/:owner/:projectsId/releases"
            render={
              () => (<CoderRootVersion {...this.props} {...this.state} />)
            }
          ></Route>
          <Route path="/:owner/:projectsId/tags"
            render={
              () => (<CoderRootTag {...this.props} {...this.state} />)
            }
          ></Route>
          <Route path="/:owner/:projectsId/branches"
            render={
              () => (<CoderRootBranch {...this.props} {...this.state} />)
            }
          ></Route>
        </Switch>
      </div>
    )
  }
}
export default CoderRootIndex;
