From 057a1bbc7f61ef41b85a87e998decc4a693fd5b8 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Fri, 4 Apr 2025 21:09:30 -0400 Subject: [PATCH] Add developer to authorize page --- app/scenes/Login/OAuthAuthorize.tsx | 85 ++++++++++++++++++----------- 1 file changed, 54 insertions(+), 31 deletions(-) diff --git a/app/scenes/Login/OAuthAuthorize.tsx b/app/scenes/Login/OAuthAuthorize.tsx index 9cda4e826f..7e0b60c287 100644 --- a/app/scenes/Login/OAuthAuthorize.tsx +++ b/app/scenes/Login/OAuthAuthorize.tsx @@ -1,6 +1,6 @@ import { MoreIcon } from "outline-icons"; import React from "react"; -import { useTranslation } from "react-i18next"; +import { Trans, useTranslation } from "react-i18next"; import styled from "styled-components"; import Flex from "@shared/components/Flex"; import { s } from "@shared/styles"; @@ -8,6 +8,7 @@ import { Avatar, AvatarSize } from "~/components/Avatar"; import ButtonLarge from "~/components/ButtonLarge"; import ChangeLanguage from "~/components/ChangeLanguage"; import Heading from "~/components/Heading"; +import LoadingIndicator from "~/components/LoadingIndicator"; import PageTitle from "~/components/PageTitle"; import Text from "~/components/Text"; import useCurrentTeam from "~/hooks/useCurrentTeam"; @@ -33,7 +34,7 @@ function Authorize() { const scope = params.get("scope"); const [scopes] = React.useState(() => scope?.split(" ") ?? []); const { - error, + error: clientError, data: response, request, } = useRequest(() => client.post("/oauthClients.info", { clientId })); @@ -42,7 +43,7 @@ function Authorize() { if (clientId) { void request(); } - }, [clientId, request]); + }, []); const handleCancel = () => { window.location.href = redirectUri ?? "/"; @@ -69,45 +70,43 @@ function Authorize() { !scope && "scope", ].filter(Boolean); - if (missingParams.length) { + if (missingParams.length || clientError) { return ( {t("An error occurred")} - - {t("Required OAuth parameters are missing")} -
-              {missingParams.map((param) => (
-                <>
-                  {param}
-                  
- - ))} -
-
-
-
- ); - } - - if (error) { - return ( - - - - {t("An error occurred")} -

{t("Unable to load details of OAuth client")}

+ {clientError ? ( + + {t( + "The OAuth client could not be found, please check the provided client ID" + )} +
{clientId}
+
+ ) : ( + + {t("Required OAuth parameters are missing")} +
+                {missingParams.map((param) => (
+                  <>
+                    {param}
+                    
+ + ))} +
+
+ )}
); } if (!response) { - // TODO - return null; + return ; } + const { name, developerName, developerUrl } = response.data; + return ( @@ -128,15 +127,39 @@ function Authorize() { {t(`{{ appName }} wants to access {{ teamName }}`, { - appName: response.data.name, + appName: name, teamName: team.name, })} + {developerName && ( + + + ) : ( + + ), + }} + /> + + )} {t( "{{ appName }} will be able to access your account and perform the following actions:", { - appName: response.data.name, + appName: name, } )}