dev_forge
Jasder 5 years ago
commit 3b79b25bc1

@ -48,13 +48,12 @@ class Index extends Component{
const {current_user} = this.state;
return(
<Switch {...this.props}>
<Route exact path="/projects/:projectsType/new"
<Route path="/projects/:projectsType/new"
render={
(props) => (<ProjectNew {...this.props} {...props} {...this.state} current_user={current_user}/>)
}
></Route>
<Route exact path="/projects/:projectsId"
<Route path="/projects/:projectsId"
render={
(props) => (<ProjectDetail {...this.props} {...props} {...this.state} current_user={current_user}/>)
}

@ -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;

@ -1,14 +1,14 @@
import React , { Component } from 'react';
import { Dropdown , Icon , Menu , Table } from 'antd';
import {Link} from 'react-router-dom';
import { Menu , Table } from 'antd';
import { getImageUrl } from 'educoder';
import axios from 'axios';
import {Link} from 'react-router-dom';
import SelectBranch from '../Branch/SelectBranch'
import CloneAddress from '../Branch/CloneAddress'
import './list.css';
import SelectBranch from '../Branch/SelectBranch';
import CloneAddress from '../Branch/CloneAddress';
import axios from 'axios';
class CoderRootDirectory extends Component{
constructor(props){
super(props);
@ -17,13 +17,10 @@ class CoderRootDirectory extends Component{
branch:"master",
http_url:undefined,
rootList:undefined,
branchList:undefined,
branchs:undefined,
branchLastCommit:undefined
}
}
changeAddress=(address)=>{
this.setState({
address
@ -32,32 +29,6 @@ class CoderRootDirectory extends Component{
componentDidMount=()=>{
this.getProjectRoot();
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)=>{})
}
// 获取分支文件
@ -101,10 +72,10 @@ class CoderRootDirectory extends Component{
http_url:branchLastCommit.http_url
})
}
render(){
const { rootList } = this.state;
const { branchs , branch , branchLastCommit , http_url } = this.props;
const columns = [
{
dataIndex: 'name',
@ -114,10 +85,6 @@ class CoderRootDirectory extends Component{
),
}
];
const { branch , rootList , branchs, branchLastCommit , http_url } = this.state;
const title = () =>{
if(branchLastCommit && branchLastCommit.last_commit){
return(
@ -139,7 +106,6 @@ class CoderRootDirectory extends Component{
return undefined;
}
}
const downloadUrl = ()=>{
if(branchLastCommit && branchLastCommit.zip_url){
return(
@ -151,12 +117,7 @@ class CoderRootDirectory extends Component{
}
}
return(
<div className="main">
<p className="branch-wrapper">
<span><i className="iconfont icon-tijiaojilu font-18 mr3"></i></span>
<span><i className="iconfont icon-fenzhi font-18 mr3"></i></span>
</p>
<div>
<div className="f-wrap-between mt20">
<SelectBranch branch={branch} branchs={branchs} changeBranch={this.changeBranch}></SelectBranch>
<CloneAddress http_url={http_url} downloadUrl={downloadUrl}></CloneAddress>

@ -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;

@ -6,35 +6,58 @@ import './list.css';
import Loadable from 'react-loadable';
import Loading from '../../Loading';
import axios from 'axios';
const CoderRootDirectory = Loadable({
loader: () => import('./CoderRootDirectory'),
loading: Loading,
})
const CoderRootIndex = Loadable({
loader: () => import('./CoderRootIndex'),
loading: Loading,
})
class Detail extends Component{
constructor(props){
super(props);
this.state={
currentKey:"coder"
currentKey:"coder",
data:undefined
}
}
// 切换菜单
ChangeMenu=(value)=>{
console.log(value);
componentDidMount=()=>{
this.getDetail();
}
getDetail=()=>{
const { login } = this.props.current_user;
const { projectsId } = this.props.match.params;
const url = `/${login}/${projectsId}.json`;
axios.get(url).then((result)=>{
if(result){
this.setState({
data:result.data
})
}
}).catch((error)=>{})
}
render(){
const { currentKey } = this.state;
const { projectsId } = this.props.match.params;
const { data } = this.state;
return(
<div>
<div className="detailHeader-wrapper">
<div className="normal f-wrap-between mb20">
<p className="font-18 color-blue df flex-1" style={{alignItems:"center"}}>kosasa胡 / <span className="hide-1 flex-1">test11111111111</span></p>
<p className="font-18 color-blue df flex-1" style={{alignItems:"center"}}>{data && data.author && data.author.name} / <span className="hide-1 flex-1">{ data && data.identifier }</span></p>
<span className="p-r-tags large">
<span><label>关注</label><span>11</span></span>
<span><label>点赞</label><span>12</span></span>
<span><label>Fork</label><span>11</span></span>
<span><label>关注</label><span>{data && data.watchers_count}</span></span>
<span><label>点赞</label><span>{data && data.praises_count}</span></span>
<span><label>Fork</label><span>{data && data.forked_count}</span></span>
</span>
</div>
<div className="normal f-wrap-between">
@ -49,14 +72,10 @@ class Detail extends Component{
</div>
<Switch {...this.props}>
<Route exact path="/projects/:projectsId/coder"
render={
(props) => (<CoderRootDirectory {...this.props} {...props} {...this.state}/>)
}
></Route>
<Route exact path="/projects/:projectsId"
<Route path="/projects/:projectsId"
render={
(props) => (<CoderRootDirectory {...this.props} {...props} {...this.state}/>)
(props) => (<CoderRootIndex {...this.props} {...props} {...this.state}/>)
}
></Route>
</Switch>

@ -186,7 +186,7 @@ body,#root{
display: flex;
padding:5px;
}
.branch-wrapper span{
.branch-wrapper a{
display: flex;
align-items: center;
justify-content: center;
@ -197,10 +197,10 @@ body,#root{
cursor: pointer;
font-size: 16px;
}
.branch-wrapper span.active{
.branch-wrapper a.active{
background: #eee;
}
.branch-wrapper span:hover{
.branch-wrapper a:hover{
color: #4CACFF;
}
@ -252,6 +252,9 @@ body,#root{
border-radius: 4px;
max-width: 100%;
}
/* 提交 */
@media screen and (max-width: 750px){
.list-left,.list-right{

@ -11,6 +11,9 @@
.back-white{
background: #fff;
}
.back-black{
background: #000;
}
/* 灰色按钮-高度32 */
.btn_32{
border-radius: 4px;

Loading…
Cancel
Save