From 370c2fadc2a28b867fa122dff2489d43ccfd05bf Mon Sep 17 00:00:00 2001 From: caicai8 <1149225589@qq.com> Date: Fri, 3 Jan 2020 17:25:49 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=86=E6=94=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/forge/Main/CoderRootDirectory.js | 90 +++++++++++++------ public/react/src/forge/Main/list.css | 6 +- 2 files changed, 70 insertions(+), 26 deletions(-) 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()}>