@@ -21,6 +21,7 @@ import customize from "./images/welcome/customize.svg";
21
21
import fresh from "./images/welcome/fresh.svg" ;
22
22
import prebuild from "./images/welcome/prebuild.svg" ;
23
23
import exclamation from "./images/exclamation.svg" ;
24
+ import { getURLHash } from "./App" ;
24
25
25
26
26
27
function Item ( props : { icon : string , iconSize ?: string , text : string } ) {
@@ -46,17 +47,27 @@ export function hasVisitedMarketingWebsiteBefore() {
46
47
export function Login ( ) {
47
48
const { setUser } = useContext ( UserContext ) ;
48
49
const { setTeams } = useContext ( TeamsContext ) ;
50
+ const urlHash = getURLHash ( ) ;
51
+ const URLFromPrefix = urlHash . length > 0 ? new URL ( urlHash ) . host : null ;
49
52
const showWelcome = ! hasLoggedInBefore ( ) && ! hasVisitedMarketingWebsiteBefore ( ) ;
50
53
51
54
const [ authProviders , setAuthProviders ] = useState < AuthProviderInfo [ ] > ( [ ] ) ;
52
55
const [ errorMessage , setErrorMessage ] = useState < string | undefined > ( undefined ) ;
56
+ const [ providerFromPrefix , setProviderFromPrefix ] = useState < AuthProviderInfo > ( ) ;
53
57
54
58
useEffect ( ( ) => {
55
59
( async ( ) => {
56
60
setAuthProviders ( await getGitpodService ( ) . server . getAuthProviders ( ) ) ;
57
61
} ) ( ) ;
58
62
} , [ ] )
59
63
64
+ useEffect ( ( ) => {
65
+ if ( URLFromPrefix ) {
66
+ const providerFromPrefix = authProviders . find ( provider => provider . host === URLFromPrefix ) ;
67
+ setProviderFromPrefix ( providerFromPrefix ) ;
68
+ }
69
+ } , [ authProviders ] )
70
+
60
71
const authorizeSuccessful = async ( payload ?: string ) => {
61
72
updateUser ( ) . catch ( console . error ) ;
62
73
// Check for a valid returnTo in payload
@@ -104,6 +115,47 @@ export function Login() {
104
115
}
105
116
}
106
117
118
+ const renderWelcomeText = ( ) => {
119
+ if ( providerFromPrefix ) {
120
+ return ( < div className = "mx-auto text-center pb-8 space-y-2" >
121
+ < h1 className = "text-3xl" > Log in / Sign up</ h1 >
122
+ < h2 className = "text-m text-gray-400" > Open a cloud-based environment for</ h2 >
123
+ < h2 className = "text-m text-gray-400" > { urlHash } </ h2 >
124
+ </ div > )
125
+ }
126
+ return (
127
+ < div className = "mx-auto text-center pb-8 space-y-2" >
128
+ < h1 className = "text-3xl" > Log in{ showWelcome ? '' : ' to Gitpod' } </ h1 >
129
+ < h2 className = "uppercase text-sm text-gray-400" > ALWAYS READY-TO-CODE</ h2 >
130
+ </ div >
131
+ )
132
+ }
133
+
134
+ const renderAuthProviders = ( ) => {
135
+ if ( providerFromPrefix ) {
136
+ return (
137
+ < div className = "flex flex-col space-y-3 items-center" >
138
+ < button key = { "button" + providerFromPrefix . host } className = "btn-login flex-none w-56 h-10 p-0 inline-flex" onClick = { ( ) => openLogin ( providerFromPrefix . host ) } >
139
+ { iconForAuthProvider ( providerFromPrefix . authProviderType ) }
140
+ < span className = "pt-2 pb-2 mr-3 text-sm my-auto font-medium truncate overflow-ellipsis" > Continue with { simplifyProviderName ( providerFromPrefix . host ) } </ span >
141
+ </ button >
142
+ </ div >
143
+ )
144
+ }
145
+ return (
146
+ < div className = "flex flex-col space-y-3 items-center" >
147
+ { authProviders . map ( ap => {
148
+ return (
149
+ < button key = { "button" + ap . host } className = "btn-login flex-none w-56 h-10 p-0 inline-flex" onClick = { ( ) => openLogin ( ap . host ) } >
150
+ { iconForAuthProvider ( ap . authProviderType ) }
151
+ < span className = "pt-2 pb-2 mr-3 text-sm my-auto font-medium truncate overflow-ellipsis" > Continue with { simplifyProviderName ( ap . host ) } </ span >
152
+ </ button >
153
+ ) ;
154
+ } ) }
155
+ </ div >
156
+ )
157
+ }
158
+
107
159
return ( < div id = "login-container" className = "z-50 flex w-screen h-screen" >
108
160
{ showWelcome ? < div id = "feature-section" className = "flex-grow bg-gray-100 dark:bg-gray-800 w-1/2 hidden lg:block" >
109
161
< div id = "feature-section-column" className = "flex max-w-xl h-full mx-auto pt-6" >
@@ -138,20 +190,10 @@ export function Login() {
138
190
< div className = "mx-auto pb-8" >
139
191
< img src = { gitpodIcon } className = "h-16 mx-auto" alt = "Gitpod's logo" />
140
192
</ div >
141
- < div className = "mx-auto text-center pb-8 space-y-2" >
142
- < h1 className = "text-3xl" > Log in{ showWelcome ? '' : ' to Gitpod' } </ h1 >
143
- < h2 className = "uppercase text-sm text-gray-400" > ALWAYS READY-TO-CODE</ h2 >
144
- </ div >
145
- < div className = "flex flex-col space-y-3 items-center" >
146
- { authProviders . map ( ap => {
147
- return (
148
- < button key = { "button" + ap . host } className = "btn-login flex-none w-56 h-10 p-0 inline-flex" onClick = { ( ) => openLogin ( ap . host ) } >
149
- { iconForAuthProvider ( ap . authProviderType ) }
150
- < span className = "pt-2 pb-2 mr-3 text-sm my-auto font-medium truncate overflow-ellipsis" > Continue with { simplifyProviderName ( ap . host ) } </ span >
151
- </ button >
152
- ) ;
153
- } ) }
154
- </ div >
193
+
194
+ { renderWelcomeText ( ) }
195
+
196
+ { renderAuthProviders ( ) }
155
197
156
198
{ errorMessage && (
157
199
< div className = "mt-16 flex space-x-2 py-6 px-6 w-96 justify-between bg-gitpod-kumquat-light rounded-xl" >
0 commit comments