From 0cb7e6666f88494cd5a69633b843b9847313c632 Mon Sep 17 00:00:00 2001 From: Alex Tugarev Date: Fri, 10 Nov 2023 12:30:56 +0000 Subject: [PATCH 01/18] convert Login.ts --- components/dashboard/src/Login.tsx | 23 +++++++++-------- .../auth-providers/auth-provider-query.ts | 25 +++++++++++++++++++ components/dashboard/src/provider-utils.tsx | 7 +++++- 3 files changed, 44 insertions(+), 11 deletions(-) diff --git a/components/dashboard/src/Login.tsx b/components/dashboard/src/Login.tsx index 3990df02bf041e..d0978cad1a8756 100644 --- a/components/dashboard/src/Login.tsx +++ b/components/dashboard/src/Login.tsx @@ -4,7 +4,6 @@ * See License.AGPL.txt in the project root for license information. */ -import { AuthProviderInfo } from "@gitpod/gitpod-protocol"; import * as GitpodCookie from "@gitpod/gitpod-protocol/lib/util/gitpod-cookie"; import { useContext, useEffect, useState, useMemo, useCallback, FC } from "react"; import { UserContext } from "./user-context"; @@ -18,9 +17,10 @@ import { getURLHash } from "./utils"; import ErrorMessage from "./components/ErrorMessage"; import { Heading1, Heading2, Subheading } from "./components/typography/headings"; import { SSOLoginForm } from "./login/SSOLoginForm"; -import { useAuthProviders } from "./data/auth-providers/auth-provider-query"; +import { useAuthProviderDescriptions } from "./data/auth-providers/auth-provider-query"; import { SetupPending } from "./login/SetupPending"; import { useNeedsSetup } from "./dedicated-setup/use-needs-setup"; +import { AuthProviderDescription } from "@gitpod/public-api/lib/gitpod/v1/authprovider_pb"; export function markLoggedIn() { document.cookie = GitpodCookie.generateCookie(window.location.hostname); @@ -38,7 +38,7 @@ export const Login: FC = ({ onLoggedIn }) => { const urlHash = useMemo(() => getURLHash(), []); - const authProviders = useAuthProviders(); + const authProviderDescriptions = useAuthProviderDescriptions(); const [errorMessage, setErrorMessage] = useState(undefined); const [hostFromContext, setHostFromContext] = useState(); const [repoPathname, setRepoPathname] = useState(); @@ -58,9 +58,9 @@ export const Login: FC = ({ onLoggedIn }) => { } }, [urlHash]); - let providerFromContext: AuthProviderInfo | undefined; - if (hostFromContext && authProviders.data) { - providerFromContext = authProviders.data.find((provider) => provider.host === hostFromContext); + let providerFromContext: AuthProviderDescription | undefined; + if (hostFromContext && authProviderDescriptions.data) { + providerFromContext = authProviderDescriptions.data.find((provider) => provider.host === hostFromContext); } const updateUser = useCallback(async () => { @@ -158,19 +158,19 @@ export const Login: FC = ({ onLoggedIn }) => { className="btn-login flex-none w-56 h-10 p-0 inline-flex rounded-xl" onClick={() => openLogin(providerFromContext!.host)} > - {iconForAuthProvider(providerFromContext.authProviderType)} + {iconForAuthProvider(providerFromContext.type)} Continue with {simplifyProviderName(providerFromContext.host)} ) : ( - authProviders.data?.map((ap) => ( + authProviderDescriptions.data?.map((ap) => ( ) : ( - authProviderDescriptions.data?.map((ap) => ( + authProviders.data?.map((ap) => (