@@ -2,6 +2,7 @@ import React from 'react';
22import DropdownButton from 'react-bootstrap/lib/DropdownButton' ;
33import MenuItem from 'react-bootstrap/lib/MenuItem' ;
44import CommitGraph from './CommitGraph' ;
5+ import FormControl from 'react-bootstrap/lib/FormControl' ;
56import 'whatwg-fetch' ;
67
78export default class App extends React . Component {
@@ -75,6 +76,30 @@ export default class App extends React.Component {
7576 } ) ;
7677 }
7778
79+ stopPropagation ( e ) {
80+ console . log ( e . target . value ) ;
81+ e . preventDefault ( ) ;
82+ e . stopPropagation ( ) ;
83+ }
84+
85+ doFilter ( e ) {
86+ const branchFilter = $ ( e . target ) ;
87+ const inputVal = branchFilter . val ( ) ;
88+ $ . each (
89+ branchFilter . parent ( ) . parent ( ) . parent ( )
90+ . find ( 'a' ) ,
91+ ( index , elem ) => {
92+ if ( ! inputVal ||
93+ ! elem . text . trim ( ) ||
94+ elem . text . trim ( ) . toLowerCase ( ) . indexOf ( inputVal . toLowerCase ( ) ) >= 0 ) {
95+ $ ( elem ) . parent ( ) . show ( ) ;
96+ } else {
97+ $ ( elem ) . parent ( ) . hide ( ) ;
98+ }
99+ }
100+ ) ;
101+ }
102+
78103 render ( ) {
79104 return (
80105 < div style = { { marginLeft : '20px' } } >
@@ -90,6 +115,15 @@ export default class App extends React.Component {
90115 < MenuItem key = { App . defaultBranchName } eventKey = { App . defaultBranchName } >
91116 { App . defaultBranchName }
92117 </ MenuItem >
118+ < MenuItem >
119+ < FormControl
120+ type = "text"
121+ value = { this . state . value }
122+ placeholder = "Find branch..."
123+ onClick = { this . stopPropagation }
124+ onKeyUp = { this . doFilter }
125+ />
126+ </ MenuItem >
93127 < MenuItem divider />
94128 { this . state . branches . map ( branch =>
95129 < MenuItem key = { branch } eventKey = { branch } > { branch } </ MenuItem >
0 commit comments