Merge branch 'forge' of http://bdgit.educoder.net/Hjqreturn/educoder into forge
commit
3b79b25bc1
@ -0,0 +1,37 @@
|
||||
import React , { Component } from 'react';
|
||||
|
||||
import axios from 'axios';
|
||||
|
||||
class CoderRootBranch extends Component {
|
||||
constructor(porps){
|
||||
super(porps);
|
||||
this.state={
|
||||
data:undefined
|
||||
}
|
||||
}
|
||||
|
||||
componentDidMount=()=>{
|
||||
this.getBranchList();
|
||||
}
|
||||
|
||||
getBranchList=()=>{
|
||||
const { projectsId } = this.props.match.params;
|
||||
const url = `/projects/${projectsId}/branches.json`;
|
||||
axios.get(url).then((result)=>{
|
||||
if(result){
|
||||
this.setState({
|
||||
data:result.data
|
||||
})
|
||||
}
|
||||
}).catch(error=>{console.log(error)})
|
||||
}
|
||||
|
||||
render(){
|
||||
return(
|
||||
<div>bbbbbbbbbb</div>
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default CoderRootBranch;
|
@ -0,0 +1,129 @@
|
||||
import React , { Component } from 'react';
|
||||
import { Table } from 'antd';
|
||||
import { getImageUrl } from 'educoder';
|
||||
import SelectBranch from '../Branch/SelectBranch';
|
||||
|
||||
import axios from 'axios';
|
||||
|
||||
class CoderRootCommit extends Component{
|
||||
constructor(props){
|
||||
super(props)
|
||||
this.state={
|
||||
branch:"master",
|
||||
data:undefined,
|
||||
dataCount:undefined,
|
||||
limit:30,
|
||||
page:1
|
||||
}
|
||||
}
|
||||
|
||||
componentDidMount=()=>{
|
||||
this.getCommitList();
|
||||
}
|
||||
|
||||
getCommitList=()=>{
|
||||
const { login } = this.props.current_user;
|
||||
const { projectsId } = this.props.match.params;
|
||||
|
||||
const { branch , page , limit } = this.state;
|
||||
const url = `/${login}/${projectsId}/commits.json`;
|
||||
axios.get(url,{
|
||||
params:{
|
||||
sha:branch,
|
||||
page,
|
||||
limit
|
||||
}
|
||||
}).then((result)=>{
|
||||
if(result){
|
||||
const array = [];
|
||||
result.data && result.data.commits.length > 0 && result.data.commits.map((item,key)=>{
|
||||
array.push({
|
||||
name:item.author && item.author.name,
|
||||
image_url:item.author && item.author.image_url,
|
||||
sha:item.sha,
|
||||
time_from_now:item.time_from_now,
|
||||
message:item.message
|
||||
})
|
||||
})
|
||||
this.setState({
|
||||
data:array,
|
||||
dataCount:result.data.total_count
|
||||
})
|
||||
}
|
||||
}).catch((error)=>{console.log(error)})
|
||||
}
|
||||
|
||||
changeBranch=(value)=>{
|
||||
const { branchList } = this.props;
|
||||
let branchLastCommit = branchList[parseInt(value.key)];
|
||||
|
||||
this.setState({
|
||||
branch:branchLastCommit.name,
|
||||
})
|
||||
}
|
||||
|
||||
render(){
|
||||
const { branch , data , dataCount } = this.state;
|
||||
const { branchs } = this.props;
|
||||
const columns=[{
|
||||
title:"作者",
|
||||
dataIndex: 'name',
|
||||
width:"10%",
|
||||
render: (text,item) => (
|
||||
<span className="f-wrap-alignCenter">
|
||||
<img src={getImageUrl(`images/${item.image_url}`)} alt="" width="28px" height="28px" className="mr3 radius"/>
|
||||
<label className="hide-1" style={{maxWidth:"75px"}}>{text}</label>
|
||||
</span>
|
||||
),
|
||||
},{
|
||||
title:"SHA",
|
||||
dataIndex: 'sha',
|
||||
render: (text) => (
|
||||
<span className="commitKey">{text}</span>
|
||||
)
|
||||
},{
|
||||
title:"备注",
|
||||
dataIndex: 'message',
|
||||
render: (text) => (
|
||||
<span>{text}</span>
|
||||
)
|
||||
},{
|
||||
title:"提交时间",
|
||||
className:"edu-txt-right",
|
||||
dataIndex: 'time_from_now',
|
||||
render: (text) => (
|
||||
<span>{text}</span>
|
||||
)
|
||||
}]
|
||||
|
||||
const title =()=>{
|
||||
return(
|
||||
<div className="f-wrap-between" style={{alignItems:"center"}}>
|
||||
<span className="font-16">{dataCount}次提交代码({branch})</span>
|
||||
{/* <div className="f-wrap-alignCenter">
|
||||
<Input placeholder="搜索提交历史" style={{width:"300px"}}/>
|
||||
<Checkbox className="ml15">所有分支</Checkbox>
|
||||
<a className="btn_32 ml15">搜索</a>
|
||||
</div> */}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
return(
|
||||
<div>
|
||||
<div className="f-wrap-between mt20">
|
||||
<SelectBranch branch={branch} branchs={branchs} changeBranch={this.changeBranch}></SelectBranch>
|
||||
</div>
|
||||
<Table
|
||||
className="mt20 wrap-commit-table"
|
||||
columns={columns}
|
||||
dataSource={data}
|
||||
showHeader={false}
|
||||
size="small"
|
||||
pagination={false}
|
||||
title={() => title()}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
export default CoderRootCommit;
|
@ -0,0 +1,96 @@
|
||||
import React , { Component } from 'react';
|
||||
import { Route , Switch , Link} from 'react-router-dom';
|
||||
|
||||
import Loadable from 'react-loadable';
|
||||
import Loading from '../../Loading';
|
||||
|
||||
import axios from 'axios';
|
||||
|
||||
|
||||
const CoderRootDirectory = Loadable({
|
||||
loader: () => import('./CoderRootDirectory'),
|
||||
loading: Loading,
|
||||
})
|
||||
const CoderRootCommit = Loadable({
|
||||
loader: () => import('./CoderRootCommit'),
|
||||
loading: Loading,
|
||||
})
|
||||
const CoderRootBranch = Loadable({
|
||||
loader: () => import('./CoderRootBranch'),
|
||||
loading: Loading,
|
||||
})
|
||||
class CoderRootIndex extends Component{
|
||||
constructor(props){
|
||||
super(props);
|
||||
this.state={
|
||||
branchs:undefined,
|
||||
branchList:undefined,
|
||||
branchLastCommit:undefined,
|
||||
http_url:undefined
|
||||
}
|
||||
}
|
||||
componentDidMount=()=>{
|
||||
this.getBranch();
|
||||
}
|
||||
// 获取分支列表
|
||||
getBranch=()=>{
|
||||
const { projectsId } = this.props.match.params;
|
||||
|
||||
const url =`/projects/${projectsId}/branches.json`;
|
||||
axios.get(url).then((result)=>{
|
||||
if(result && result.data.length>0){
|
||||
const branchs = [];
|
||||
result.data.map((item,key)=>{
|
||||
branchs.push({
|
||||
index:key,
|
||||
name:item.name
|
||||
})
|
||||
})
|
||||
|
||||
this.setState({
|
||||
branchList:result.data,
|
||||
branchs,
|
||||
branchLastCommit:result.data[0],
|
||||
http_url:result.data[0].http_url
|
||||
})
|
||||
}
|
||||
}).catch((error)=>{})
|
||||
}
|
||||
render(){
|
||||
const { projectsId } = this.props.match.params;
|
||||
const { pathname } = this.props.location;
|
||||
return(
|
||||
<div className="main">
|
||||
<p className="branch-wrapper">
|
||||
<Link to={`/projects/${projectsId}/coder/commit`} className={ pathname.indexOf("/coder/commit") > 0 ? "active" : ""}><i className="iconfont icon-tijiaojilu font-18 mr3"></i>提交</Link>
|
||||
<Link to={`/projects/${projectsId}/coder/branch`} className={ pathname.indexOf("/coder/branch") > 0 ? "active" : ""}><i className="iconfont icon-fenzhi font-18 mr3"></i>分支</Link>
|
||||
</p>
|
||||
|
||||
<Switch {...this.props}>
|
||||
<Route path="/projects/:projectsId/coder/commit"
|
||||
render={
|
||||
(props) => (<CoderRootCommit {...this.props} {...props} {...this.state}/>)
|
||||
}
|
||||
></Route>
|
||||
|
||||
<Route path="/projects/:projectsId/coder/branch"
|
||||
render={
|
||||
(props) => (<CoderRootBranch {...this.props} {...props} {...this.state}/>)
|
||||
}
|
||||
></Route>
|
||||
<Route path="/projects/:projectsId/coder"
|
||||
render={
|
||||
(props) => (<CoderRootDirectory {...this.props} {...props} {...this.state}/>)
|
||||
}
|
||||
></Route>
|
||||
<Route path="/projects/:projectsId"
|
||||
render={
|
||||
(props) => (<CoderRootDirectory {...this.props} {...props} {...this.state}/>)
|
||||
}
|
||||
></Route>
|
||||
</Switch>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
export default CoderRootIndex;
|
Loading…
Reference in new issue