@@ -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,37 @@ export function hasVisitedMarketingWebsiteBefore() {
46
47
export function Login ( ) {
47
48
const { setUser } = useContext ( UserContext ) ;
48
49
const { setTeams } = useContext ( TeamsContext ) ;
49
- const showWelcome = ! hasLoggedInBefore ( ) && ! hasVisitedMarketingWebsiteBefore ( ) ;
50
+ const urlHash = getURLHash ( ) ;
51
+ let hostFromContext : string | undefined ;
52
+ let repoPathname : string | undefined ;
53
+ try {
54
+ if ( urlHash . length > 0 ) {
55
+ const url = new URL ( urlHash ) ;
56
+ hostFromContext = url . host ;
57
+ repoPathname = url . pathname ;
58
+ }
59
+ } catch ( error ) {
60
+ // Hash is not a valid URL
61
+ }
50
62
51
- const [ authProviders , setAuthProviders ] = useState < AuthProviderInfo [ ] > ( [ ] ) ;
52
- const [ errorMessage , setErrorMessage ] = useState < string | undefined > ( undefined ) ;
63
+ const [ authProviders , setAuthProviders ] = useState < AuthProviderInfo [ ] > ( [ ] ) ;
64
+ const [ errorMessage , setErrorMessage ] = useState < string | undefined > ( undefined ) ;
65
+ const [ providerFromContext , setProviderFromContext ] = useState < AuthProviderInfo > ( ) ;
66
+ const showWelcome = ! hasLoggedInBefore ( ) && ! hasVisitedMarketingWebsiteBefore ( ) && ! urlHash . startsWith ( "https://" ) ;
53
67
54
68
useEffect ( ( ) => {
55
69
( async ( ) => {
56
70
setAuthProviders ( await getGitpodService ( ) . server . getAuthProviders ( ) ) ;
57
71
} ) ( ) ;
58
72
} , [ ] )
59
73
74
+ useEffect ( ( ) => {
75
+ if ( hostFromContext && authProviders ) {
76
+ const providerFromContext = authProviders . find ( provider => provider . host === hostFromContext ) ;
77
+ setProviderFromContext ( providerFromContext ) ;
78
+ }
79
+ } , [ authProviders ] )
80
+
60
81
const authorizeSuccessful = async ( payload ?: string ) => {
61
82
updateUser ( ) . catch ( console . error ) ;
62
83
// Check for a valid returnTo in payload
@@ -69,7 +90,7 @@ export function Login() {
69
90
70
91
const updateUser = async ( ) => {
71
92
await getGitpodService ( ) . reconnect ( ) ;
72
- const [ user , teams ] = await Promise . all ( [
93
+ const [ user , teams ] = await Promise . all ( [
73
94
getGitpodService ( ) . server . getLoggedInUser ( ) ,
74
95
getGitpodService ( ) . server . getTeams ( ) ,
75
96
] ) ;
@@ -136,21 +157,37 @@ export function Login() {
136
157
< div className = "flex-grow h-100 flex flex-row items-center justify-center" >
137
158
< div className = "rounded-xl px-10 py-10 mx-auto" >
138
159
< div className = "mx-auto pb-8" >
139
- < img src = { gitpodIcon } className = "h-16 mx-auto" alt = "Gitpod's logo" />
160
+ < img src = { providerFromContext ? gitpod : gitpodIcon } className = "h-14 mx-auto block dark:hidden" alt = "Gitpod's logo" />
161
+ < img src = { gitpodDark } className = "h-14 hidden dark:block" alt = "Gitpod dark theme logo" />
140
162
</ div >
163
+
141
164
< 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 >
165
+ { providerFromContext
166
+ ? < >
167
+ < h2 className = "text-xl text-black dark:text-gray-50 font-semibold" > Open a cloud-based development environment</ h2 >
168
+ < h2 className = "text-xl" > for the repository { repoPathname ?. slice ( 1 ) } </ h2 >
169
+ </ >
170
+ : < >
171
+ < h1 className = "text-3xl" > Log in{ showWelcome ? '' : ' to Gitpod' } </ h1 >
172
+ < h2 className = "uppercase text-sm text-gray-400" > ALWAYS READY-TO-CODE</ h2 >
173
+ </ > }
144
174
</ div >
175
+
176
+
145
177
< 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 >
178
+ { providerFromContext
179
+ ?
180
+ < button key = { "button" + providerFromContext . host } className = "btn-login flex-none w-56 h-10 p-0 inline-flex" onClick = { ( ) => openLogin ( providerFromContext . host ) } >
181
+ { iconForAuthProvider ( providerFromContext . authProviderType ) }
182
+ < span className = "pt-2 pb-2 mr-3 text-sm my-auto font-medium truncate overflow-ellipsis" > Continue with { simplifyProviderName ( providerFromContext . host ) } </ span >
151
183
</ button >
152
- ) ;
153
- } ) }
184
+ :
185
+ authProviders . map ( ap =>
186
+ < button key = { "button" + ap . host } className = "btn-login flex-none w-56 h-10 p-0 inline-flex" onClick = { ( ) => openLogin ( ap . host ) } >
187
+ { iconForAuthProvider ( ap . authProviderType ) }
188
+ < span className = "pt-2 pb-2 mr-3 text-sm my-auto font-medium truncate overflow-ellipsis" > Continue with { simplifyProviderName ( ap . host ) } </ span >
189
+ </ button > )
190
+ }
154
191
</ div >
155
192
156
193
{ errorMessage && (
0 commit comments