1- import { API_ROOT , EGO_CLIENT_ID } from 'common/injectGlobals' ;
1+ import { API_ROOT , EGO_CLIENT_ID , KEYCLOAK_ENABLED } from 'common/injectGlobals' ;
22import { injectState } from 'freactal' ;
33import { css } from 'glamor' ;
44import jwtDecode from 'jwt-decode' ;
@@ -7,7 +7,7 @@ import React, { ComponentType } from 'react';
77import { compose } from 'recompose' ;
88import ajax from 'services/ajax' ;
99
10- import { BLUE , LIGHT_BLUE , TEAL , WHITE } from 'common/colors' ;
10+ import { BLUE , DEFAULT_BLACK , LIGHT_BLUE , TEAL , WHITE } from 'common/colors' ;
1111import { Orcid , Facebook , Google , GitHub , LinkedIn } from './Icons' ;
1212
1313const styles = {
@@ -51,6 +51,7 @@ const styles = {
5151const enhance = compose ( injectState ) ;
5252
5353enum LoginProvider {
54+ Keycloak = 'Keycloak' ,
5455 Google = 'Google' ,
5556 // Facebook = 'Facebook',
5657 Github = 'GitHub' ,
@@ -59,6 +60,7 @@ enum LoginProvider {
5960}
6061
6162enum ProviderLoginPaths {
63+ keycloak = 'keycloak' ,
6264 google = 'google' ,
6365 // facebook = 'facebook',
6466 github = 'github' ,
@@ -71,7 +73,7 @@ type IconComponent = ComponentType<{ width: number; height: number }>;
7173type ProviderType = {
7274 name : LoginProvider ;
7375 path : ProviderLoginPaths ;
74- Icon : IconComponent ;
76+ Icon ? : IconComponent ;
7577} ;
7678
7779const providers : ProviderType [ ] = [
@@ -82,6 +84,16 @@ const providers: ProviderType[] = [
8284 { name : LoginProvider . Linkedin , path : ProviderLoginPaths . linkedin , Icon : LinkedIn } ,
8385] ;
8486
87+ const KeycloakLogin = ( ) => {
88+ return < a
89+ key = { LoginProvider . Keycloak }
90+ href = { `${ API_ROOT } /oauth/login/${ ProviderLoginPaths . keycloak } ?client_id=${ EGO_CLIENT_ID } ` }
91+ className = { `${ css ( styles . loginButton ) } ` }
92+ >
93+ < span className = { `${ css ( { paddingLeft : 10 } ) } ` } > Login/Register</ span >
94+ </ a >
95+ }
96+
8597class Component extends React . Component < any , any > {
8698 static propTypes = {
8799 effects : PropTypes . object ,
@@ -129,7 +141,14 @@ class Component extends React.Component<any, any> {
129141 < div className = { `Login ${ css ( styles . container ) } ` } >
130142 < img src = { require ( 'assets/brand-image.svg' ) } alt = "" className = { `${ css ( styles . logo ) } ` } />
131143 < h1 className = { `${ css ( styles . title ) } ` } > Admin Portal</ h1 >
132- < h3 className = { `${ css ( styles . title ) } ` } > Login with one of the following</ h3 >
144+ {
145+ KEYCLOAK_ENABLED && < KeycloakLogin />
146+ }
147+ {
148+ KEYCLOAK_ENABLED
149+ ? < h3 className = { `${ css ( styles . title ) } ` } > Or login with one of the following services</ h3 >
150+ : < h3 className = { `${ css ( styles . title ) } ` } > Login with one of the following</ h3 >
151+ }
133152 < ul
134153 className = { `${ css ( {
135154 display : 'flex' ,
@@ -139,18 +158,21 @@ class Component extends React.Component<any, any> {
139158 padding : 0 ,
140159 } ) } `}
141160 >
142- { providers . map ( ( { name, path, Icon } ) => {
143- return (
144- < a
145- key = { name }
146- href = { `${ API_ROOT } /oauth/login/${ path } ?client_id=${ EGO_CLIENT_ID } ` }
147- className = { `${ css ( styles . loginButton ) } ` }
148- >
149- < Icon width = { 15 } height = { 15 } />
150- < span className = { `${ css ( { paddingLeft : 10 } ) } ` } > { name } </ span >
151- </ a >
152- ) ;
153- } ) }
161+ { providers
162+ . map ( ( { name, path, Icon } ) => {
163+ return (
164+ < a
165+ key = { name }
166+ href = { `${ API_ROOT } /oauth/login/${ path } ?client_id=${ EGO_CLIENT_ID } ` }
167+ className = { `${ css ( styles . loginButton ) } ` }
168+ >
169+ { Icon !== undefined &&
170+ < Icon width = { 15 } height = { 15 } />
171+ }
172+ < span className = { `${ css ( { paddingLeft : 10 } ) } ` } > { name } </ span >
173+ </ a >
174+ ) ;
175+ } ) }
154176 </ ul >
155177 </ div >
156178 ) ;
0 commit comments