@@ -4,60 +4,80 @@ import { withRouter } from 'react-router-dom';
44import githubLogo from './assets/images/github.svg'
55import gitlabLogo from './assets/images/gitlab.svg'
66import trelloLogo from './assets/images/trello.svg'
7+ import Authenticator from 'netlify-auth-providers' ;
8+ import { UncontrolledTooltip } from 'reactstrap' ;
79import './Home.css'
8- import { githubAuthorizeUrl } from './GitHub/constants' ;
910
10- const callbackUrl = ( setupable ) => `${ window . location . href } ${ setupable } /callback`
11- const SETUPABLE = [
12- {
13- name : "GitHub" ,
14- logo : githubLogo ,
15- enabled : true ,
16- url : githubAuthorizeUrl ( callbackUrl ( 'github' ) ) ,
17- } ,
18- {
19- name : "GitLab" ,
20- logo : gitlabLogo ,
21- enabled : false ,
22- url : null ,
23- } ,
24- {
25- name : "Trello" ,
26- logo : trelloLogo ,
27- enabled : false ,
28- url : null ,
29- } ,
30- ] ;
11+ const nullCallback = ( event ) => event . preventDefault ( ) ;
12+ const auth = new Authenticator ( { site_id : "cwps.lucassabreu.net.br" } ) ;
3113
32- const Home = ( ) => (
33- < div className = "Home" >
34- < section className = "description" >
35- < p >
36- This web client helps to setup a project at GitHub, GitLab or Trello to use the
37- Coderockr Way's labels, making easier to bootstrap the basic configuration at
38- your project.
39- </ p >
40- </ section >
41- < section className = "project-handlers" >
42- < h2 > Where is your project?</ h2 >
43- < ul className = "row project-handlers-buttons justify-content-md-center" >
44- { SETUPABLE . map ( ( { name, logo : Logo , url, enabled } ) => (
45- < li key = { name } className = "col-md-4" >
46- < a className = { `btn btn-primary ${ enabled ? null : 'disabled' } ` } href = { url }
47- alt = { enabled ? '' : `${ name } will be supported soon` } >
48- < Logo className = "icon" />
49- { name }
50- </ a >
51- </ li >
52- ) ) }
53- </ ul >
54- </ section >
55- < section className = "more-about" >
56- < h4 > Wanna know more about?</ h4 >
57- < p > Look this link: < a href = "https://blog.coderockr.com/simplificando-o-setup-de-projetos-no-github-f29b76c83194" > Simplificando o Setup de Projetos no GitHub</ a >
14+ const Home = ( { history } ) => {
15+ const origins = [
16+ {
17+ name : "GitHub" ,
18+ logo : githubLogo ,
19+ enabled : true ,
20+ callback : ( event ) => {
21+ auth . authenticate ( { provider : "github" , scope : "user" } , ( err , data ) => {
22+ if ( err ) {
23+ console . error ( err ) ;
24+ return
25+ }
26+ sessionStorage . setItem ( 'github-token' , data . token ) ;
27+ history . push ( '/github' ) ;
28+ } )
29+ }
30+ } ,
31+ {
32+ name : "GitLab" ,
33+ logo : gitlabLogo ,
34+ enabled : false ,
35+ callback : nullCallback ,
36+ } ,
37+ {
38+ name : "Trello" ,
39+ logo : trelloLogo ,
40+ enabled : false ,
41+ callback : nullCallback ,
42+ } ,
43+ ] ;
44+
45+ return (
46+ < div className = "Home" >
47+ < section className = "description" >
48+ < p >
49+ This web client helps to setup a project at GitHub, GitLab or Trello to use the
50+ Coderockr Way's labels, making easier to bootstrap the basic configuration at
51+ your project.
5852 </ p >
59- </ section >
60- </ div >
61- )
53+ </ section >
54+ < section className = "project-handlers" >
55+ < h2 > Where is your project?</ h2 >
56+ < ul className = "row project-handlers-buttons justify-content-md-center" >
57+ { origins . map ( ( { name, logo : Logo , callback, enabled } ) => (
58+ < li key = { name } className = "col-md-4" >
59+ < button id = { `btn_origin_${ name } ` } className = { `btn btn-primary ${ enabled ? null : 'disabled' } ` }
60+ onClick = { ( event ) => callback ( event ) }
61+ >
62+ < Logo className = "icon" />
63+ { name }
64+ </ button >
65+ { enabled ? null :
66+ < UncontrolledTooltip placement = "bottom" target = { `btn_origin_${ name } ` } >
67+ { name } will be supported soon
68+ </ UncontrolledTooltip >
69+ }
70+ </ li >
71+ ) ) }
72+ </ ul >
73+ </ section >
74+ < section className = "more-about" >
75+ < h4 > Wanna know more about?</ h4 >
76+ < p > Look this link: < a href = "https://blog.coderockr.com/simplificando-o-setup-de-projetos-no-github-f29b76c83194" > Simplificando o Setup de Projetos no GitHub</ a >
77+ </ p >
78+ </ section >
79+ </ div >
80+ )
81+ }
6282
6383export default withRouter ( Home ) ;
0 commit comments