diff --git a/public/react/src/forge/Main/CoderRootDirectory.js b/public/react/src/forge/Main/CoderRootDirectory.js index 152ed5358..2b83644e9 100644 --- a/public/react/src/forge/Main/CoderRootDirectory.js +++ b/public/react/src/forge/Main/CoderRootDirectory.js @@ -1,6 +1,8 @@ import React , { Component } from 'react'; import { Dropdown , Icon , Menu , Table } from 'antd'; import {Link} from 'react-router-dom'; + +import { getImageUrl } from 'educoder'; import axios from 'axios'; // 点击按钮复制功能 @@ -16,7 +18,10 @@ class CoderRootDirectory extends Component{ address:"http", ref:"master", - rootList:undefined + rootList:undefined, + branchList:undefined, + branchs:undefined, + branchLastCommit:undefined } } @@ -37,8 +42,20 @@ class CoderRootDirectory extends Component{ const url =`/projects/${projectsId}/branches.json`; axios.get(url).then((result)=>{ - if(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] + }) } }).catch((error)=>{}) } @@ -73,17 +90,19 @@ class CoderRootDirectory extends Component{ }) } + // 选择分支 + changeBranch=(value)=>{ + const { branchList } = this.state; + let branchLastCommit = branchList[parseInt(value.key)]; + + this.setState({ + ref:branchLastCommit.name, + branchLastCommit + }) + } + render(){ - const menu = ( - - - 1st menu item - - - 2nd menu item - - - ); + const columns = [ { @@ -95,19 +114,40 @@ class CoderRootDirectory extends Component{ } ]; + const { address , ref , rootList , branchList , branchs, branchLastCommit } = this.state; + const menu = ( + + { + branchs && branchs.map((item,key)=>{ + return( + {item.name} + ) + }) + } + + ); + const title = () =>{ - return( -
- - 蔡蔡 - asljfowfjoer - first commit - 3小时前 -
- ) + if(branchLastCommit && branchLastCommit.last_commit){ + return( +
+ { + branchLastCommit.author ? + + + {branchLastCommit.author.login} + + :"" + } + {branchLastCommit.last_commit.id} + {branchLastCommit.last_commit.message} + {branchLastCommit.last_commit.time_from_now} +
+ ) + }else{ + return undefined; + } } - - const { address , ref , rootList } = this.state; return(

@@ -128,7 +168,7 @@ class CoderRootDirectory extends Component{ this.changeAddress("http")}>HTTP this.changeAddress("ssh")}>SSH - + jsCopy()}> diff --git a/public/react/src/forge/Main/list.css b/public/react/src/forge/Main/list.css index 78bf62d0d..f4457d174 100644 --- a/public/react/src/forge/Main/list.css +++ b/public/react/src/forge/Main/list.css @@ -256,8 +256,9 @@ body,#root{ padding:0px 5px; height: 28px; line-height: 28px; - margin:0px 15px; + margin-right:15px; border-radius: 4px; + max-width: 100%; } @media screen and (max-width: 750px){ @@ -291,4 +292,7 @@ body,#root{ .p-r-about{ flex-wrap: wrap; } + .commitKey{ + margin-right: 0px; + } }