diff --git a/components/dashboard/src/Login.tsx b/components/dashboard/src/Login.tsx index 3990df02bf041e..fb7c2a41142b37 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-descriptions-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 authProviders = useAuthProviderDescriptions(); const [errorMessage, setErrorMessage] = useState(undefined); const [hostFromContext, setHostFromContext] = useState(); const [repoPathname, setRepoPathname] = useState(); @@ -58,7 +58,7 @@ export const Login: FC = ({ onLoggedIn }) => { } }, [urlHash]); - let providerFromContext: AuthProviderInfo | undefined; + let providerFromContext: AuthProviderDescription | undefined; if (hostFromContext && authProviders.data) { providerFromContext = authProviders.data.find((provider) => provider.host === hostFromContext); } @@ -158,7 +158,7 @@ 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)} @@ -170,7 +170,7 @@ export const Login: FC = ({ onLoggedIn }) => { className="btn-login flex-none w-56 h-10 p-0 inline-flex rounded-xl" onClick={() => openLogin(ap.host)} > - {iconForAuthProvider(ap.authProviderType)} + {iconForAuthProvider(ap.type)} Continue with {simplifyProviderName(ap.host)} diff --git a/components/dashboard/src/components/AuthorizeGit.tsx b/components/dashboard/src/components/AuthorizeGit.tsx index 96e945b1aa8cd9..aa8ad0c0cd1640 100644 --- a/components/dashboard/src/components/AuthorizeGit.tsx +++ b/components/dashboard/src/components/AuthorizeGit.tsx @@ -4,10 +4,9 @@ * See License.AGPL.txt in the project root for license information. */ -import { AuthProviderInfo } from "@gitpod/gitpod-protocol"; import { FC, useCallback, useContext } from "react"; import { Link } from "react-router-dom"; -import { useAuthProviders } from "../data/auth-providers/auth-provider-query"; +import { useAuthProviderDescriptions } from "../data/auth-providers/auth-provider-descriptions-query"; import { openAuthorizeWindow } from "../provider-utils"; import { getGitpodService } from "../service/service"; import { UserContext, useCurrentUser } from "../user-context"; @@ -16,29 +15,29 @@ import { Heading2, Heading3, Subheading } from "./typography/headings"; import classNames from "classnames"; import { iconForAuthProvider, simplifyProviderName } from "../provider-utils"; import { useIsOwner } from "../data/organizations/members-query"; +import { AuthProviderDescription } from "@gitpod/public-api/lib/gitpod/v1/authprovider_pb"; export function useNeedsGitAuthorization() { - const authProviders = useAuthProviders(); + const authProviders = useAuthProviderDescriptions(); const user = useCurrentUser(); if (!user || !authProviders.data) { return false; } - return !authProviders.data.some((ap) => user.identities.some((i) => ap.authProviderId === i.authProviderId)); + return !authProviders.data.some((ap) => user.identities.some((i) => ap.id === i.authProviderId)); } export const AuthorizeGit: FC<{ className?: string }> = ({ className }) => { const { setUser } = useContext(UserContext); const owner = useIsOwner(); - const authProviders = useAuthProviders(); + const { data: authProviders } = useAuthProviderDescriptions(); const updateUser = useCallback(() => { getGitpodService().server.getLoggedInUser().then(setUser); }, [setUser]); const connect = useCallback( - (ap: AuthProviderInfo) => { + (ap: AuthProviderDescription) => { openAuthorizeWindow({ host: ap.host, - scopes: ap.requirements?.default, overrideScopes: true, onSuccess: updateUser, }); @@ -46,15 +45,13 @@ export const AuthorizeGit: FC<{ className?: string }> = ({ className }) => { [updateUser], ); - if (authProviders.data === undefined) { + if (authProviders === undefined) { return <>; } - const verifiedProviders = authProviders.data.filter((ap) => ap.verified); - return (
- {verifiedProviders.length === 0 ? ( + {authProviders.length === 0 ? ( <> No Git integrations {!!owner ? ( @@ -82,7 +79,7 @@ export const AuthorizeGit: FC<{ className?: string }> = ({ className }) => { Select one of the following available providers to access repositories for your account.
- {verifiedProviders.map((ap) => { + {authProviders.map((ap) => { return (