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 = ( -
- ); + const columns = [ { @@ -95,19 +114,40 @@ class CoderRootDirectory extends Component{ } ]; + const { address , ref , rootList , branchList , branchs, branchLastCommit } = this.state; + const menu = ( + + ); + const title = () =>{ - return( -
@@ -128,7 +168,7 @@ class CoderRootDirectory extends Component{
this.changeAddress("http")}>HTTP
this.changeAddress("ssh")}>SSH
-
+ jsCopy()}>