mirror of
https://github.com/outline/outline.git
synced 2026-12-01 09:22:14 +03:00
Add developer to authorize page
This commit is contained in:
1 parent
1289f5f3be
commit
057a1bbc7f
1 file changed
+54
-31
@@ -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 (
|
||||
<Background>
|
||||
<ChangeLanguage locale={detectLanguage()} />
|
||||
<Centered>
|
||||
<StyledHeading>{t("An error occurred")}</StyledHeading>
|
||||
<Text as="p" type="secondary">
|
||||
{t("Required OAuth parameters are missing")}
|
||||
<Pre>
|
||||
{missingParams.map((param) => (
|
||||
<>
|
||||
{param}
|
||||
<br />
|
||||
</>
|
||||
))}
|
||||
</Pre>
|
||||
</Text>
|
||||
</Centered>
|
||||
</Background>
|
||||
);
|
||||
}
|
||||
|
||||
if (error) {
|
||||
return (
|
||||
<Background>
|
||||
<ChangeLanguage locale={detectLanguage()} />
|
||||
<Centered>
|
||||
<StyledHeading>{t("An error occurred")}</StyledHeading>
|
||||
<p>{t("Unable to load details of OAuth client")}</p>
|
||||
{clientError ? (
|
||||
<Text as="p" type="secondary">
|
||||
{t(
|
||||
"The OAuth client could not be found, please check the provided client ID"
|
||||
)}
|
||||
<Pre>{clientId}</Pre>
|
||||
</Text>
|
||||
) : (
|
||||
<Text as="p" type="secondary">
|
||||
{t("Required OAuth parameters are missing")}
|
||||
<Pre>
|
||||
{missingParams.map((param) => (
|
||||
<>
|
||||
{param}
|
||||
<br />
|
||||
</>
|
||||
))}
|
||||
</Pre>
|
||||
</Text>
|
||||
)}
|
||||
</Centered>
|
||||
</Background>
|
||||
);
|
||||
}
|
||||
|
||||
if (!response) {
|
||||
// TODO
|
||||
return null;
|
||||
return <LoadingIndicator />;
|
||||
}
|
||||
|
||||
const { name, developerName, developerUrl } = response.data;
|
||||
|
||||
return (
|
||||
<Background>
|
||||
<PageTitle title={t("Authorize")} />
|
||||
@@ -128,15 +127,39 @@ function Authorize() {
|
||||
</Flex>
|
||||
<StyledHeading>
|
||||
{t(`{{ appName }} wants to access {{ teamName }}`, {
|
||||
appName: response.data.name,
|
||||
appName: name,
|
||||
teamName: team.name,
|
||||
})}
|
||||
</StyledHeading>
|
||||
{developerName && (
|
||||
<Text type="secondary" as="p" style={{ marginTop: -12 }}>
|
||||
<Trans
|
||||
defaults="By <em>{{ developerName }}</em>"
|
||||
values={{
|
||||
developerName,
|
||||
}}
|
||||
components={{
|
||||
em: developerUrl ? (
|
||||
<Text
|
||||
as="a"
|
||||
type="secondary"
|
||||
weight="bold"
|
||||
href={developerUrl}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
/>
|
||||
) : (
|
||||
<strong />
|
||||
),
|
||||
}}
|
||||
/>
|
||||
</Text>
|
||||
)}
|
||||
<Text type="tertiary" as="p">
|
||||
{t(
|
||||
"{{ appName }} will be able to access your account and perform the following actions:",
|
||||
{
|
||||
appName: response.data.name,
|
||||
appName: name,
|
||||
}
|
||||
)}
|
||||
</Text>
|
||||
|
||||
Reference in new issue
Block a user