changeBranch

This commit is contained in:
caicai8 2020-04-24 10:38:19 +08:00
parent d1214b8b6b
commit cd5f5ed04f
2 changed files with 14 additions and 16 deletions

View File

@ -1,5 +1,5 @@
import React , { Component } from 'react';
import { Dropdown , Icon , Menu } from 'antd';
import { Dropdown , Icon , Input } from 'antd';
import "./branch.css"
@ -59,16 +59,15 @@ class SelectBranch extends Component{
const { branchs , branch } = this.props;
let branchsFilter = value ? (branchs && branchs.length>0 && branchs.filter(item=>item.name.indexOf(value)>-1)):branchs;
console.log("value",value);
const menu = (
<div className="branchOptions" id="m-btn" onClick={this.stopPropagations}>
<input placeholder="请输入分支名称进行搜索" id="input-btn" value={value} className="OptionsInput" onChange={this.changeValue} onClick={this.InputClick}/>
<Input placeholder="请输入分支名称进行搜索" id="input-btn" value={value} className="OptionsInput" onChange={this.changeValue} onClick={this.InputClick}/>
<ul className="OptionsUl" id="ul-btn">
{
branchsFilter && branchsFilter.map((item,key)=>{
return(
<li key={key}><a className="task-hide" onClick={()=>this.changeBranch(item.name)}>{item.name}</a></li>
// <Menu.Item key={item.index} onClick={(value)=>changeBranch(value)}>{item.name}</Menu.Item>
)
})
}

View File

@ -256,24 +256,23 @@ class CoderRootDirectory extends Component{
const { branchList } = this.props;
let branchLastCommit = branchList && branchList.length >0 && branchList.filter(item=>item.name === value)[0];
this.setState({
branch:branchLastCommit && branchLastCommit.name,
branchLastCommit,
http_url:branchLastCommit && branchLastCommit.http_url,
isSpin: true
})
if(branchLastCommit){
const { pathname } = this.props.location;
if(pathname && pathname.indexOf("?url=")>-1){
let url =pathname.split("?url=")[1];
this.setState({
branch:value,
branchLastCommit,
http_url:branchLastCommit && branchLastCommit.http_url,
isSpin: true
})
let { search } = this.props.history.location;
if(search && search.indexOf("?url=")>-1){
let url =search.split("?url=")[1];
this.setState({
filePath:url
})
this.getFileDetail(url, branchLastCommit.name);
this.getFileDetail(url, value);
}else{
this.getProjectRoot( branchLastCommit.name );
this.getProjectRoot( value );
}
// this.props.history.location.search.replace( branchLastCommit.name );
}
}
render(){