11import React from 'react'
22import Loading from '../Components/Loading' ;
3+ import ProjectListSelector from '../Components/ProjectListSelector' ;
34import { withGithubRepositories } from './withGitHubRepositories' ;
4- import Select from 'react-select' ;
5- import 'react-select/dist/react-select.css' ;
65import LABELS_TO_ADD from '../Labels' ;
76import invertColor from '../invertColor' ;
87import './GitHub.css' ;
@@ -11,18 +10,20 @@ class GitHub extends React.Component {
1110
1211 constructor ( props ) {
1312 super ( props )
14- this . state = { selectedOption : null }
13+ this . state = {
14+ selectedOption : null ,
15+ applying : false ,
16+ }
1517 }
1618
17- handleSelect ( selectedOption ) {
18- this . setState ( { selectedOption } )
19+ handleApply ( selectedOption ) {
20+ console . log ( selectedOption )
21+ this . setState ( { selectedOption, applying : true } )
1922 }
2023
2124 render ( ) {
2225 const { loading, repositories } = this . props ;
23- const selectedOption = this . state . selectedOption && this . state . selectedOption . value
2426
25- repositories . sort ( ( a , b ) => a . full_name . toLocaleLowerCase ( ) > b . full_name . toLocaleLowerCase ( ) ? 1 : - 1 )
2627 return (
2728 < div className = "GitHub" >
2829 { loading ?
@@ -32,21 +33,20 @@ class GitHub extends React.Component {
3233 </ section >
3334 :
3435 < section >
35- < div className = "row select-group" >
36- < div className = "col-md-10" >
37- < Select
38- value = { selectedOption }
39- onChange = { ( e ) => this . handleSelect ( e ) }
40- options = { repositories . map ( r => Object . assign ( r , {
41- value : r . full_name ,
42- label : r . full_name ,
43- } ) ) }
44- />
36+ < ProjectListSelector className = "select-group"
37+ disabled = { this . state . applying }
38+ selected = { this . state . selectedOption }
39+ projects = { repositories . map ( r => Object . assign ( r , {
40+ value : r . full_name ,
41+ label : r . full_name ,
42+ } ) ) }
43+ onApply = { ( selected ) => this . handleApply ( selected ) }
44+ />
45+ { ! this . state . applying ? null :
46+ < div className = "row applying-status" >
47+ < div className = "col-md-12" > < Loading /> </ div >
4548 </ div >
46- < div className = "col-md-2" >
47- < button className = "btn btn-apply-labels btn-primary" > Apply</ button >
48- </ div >
49- </ div >
49+ }
5050 < div className = "row labels" >
5151 { LABELS_TO_ADD . map ( ( { name, color } ) => (
5252 < div key = { name } className = "col-md-4" >
0 commit comments