Merge pull request #4968 from h3poteto/iss-4961

refs #4961 Show authorization URL in login modal
This commit is contained in:
AkiraFukushima 2024-06-13 23:54:11 +09:00 committed by GitHub
commit f46dc86d3f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 24 additions and 1 deletions

View File

@ -41,6 +41,7 @@
"domain": "Domain", "domain": "Domain",
"sign_in": "Sign in", "sign_in": "Sign in",
"authorize": "Authorize", "authorize": "Authorize",
"authorization_url": "Normally, the browser will open automatically, but if it doesn't, please open the following URL in your browser and approve it.",
"authorization_code": "Authorization Code", "authorization_code": "Authorization Code",
"authorization_helper": "Please paste the authorization code from your browser", "authorization_helper": "Please paste the authorization code from your browser",
"without_code_authorize": "Please approve Whalebird in your browser, and after you approve it please authorize", "without_code_authorize": "Please approve Whalebird in your browser, and after you approve it please authorize",

View File

@ -114,6 +114,10 @@
opacity: 1; opacity: 1;
} }
.no-scroll::-webkit-scrollbar {
display: none;
}
button:focus { button:focus {
outline: none; outline: none;
} }

View File

@ -2,8 +2,9 @@ import generator, { MegalodonInterface, OAuth, detector } from 'megalodon'
import { useCallback, useEffect, useRef, useState } from 'react' import { useCallback, useEffect, useRef, useState } from 'react'
import { db } from '@/db' import { db } from '@/db'
import { FormattedMessage, useIntl } from 'react-intl' import { FormattedMessage, useIntl } from 'react-intl'
import { Alert, Button, Dialog, DialogBody, DialogHeader, Input, Spinner, Typography } from '@material-tailwind/react' import { Alert, Button, Dialog, DialogBody, DialogHeader, IconButton, Input, Spinner, Typography } from '@material-tailwind/react'
import { invoke } from '@/utils/invoke' import { invoke } from '@/utils/invoke'
import { FaPaperclip } from 'react-icons/fa6'
type NewProps = { type NewProps = {
opened: boolean opened: boolean
@ -77,6 +78,10 @@ export default function New(props: NewProps) {
} }
}, [props.opened, sns]) }, [props.opened, sns])
const copyText = (text: string) => {
navigator.clipboard.writeText(text)
}
const authorize = async () => { const authorize = async () => {
setError('') setError('')
setLoading(true) setLoading(true)
@ -169,6 +174,19 @@ export default function New(props: NewProps) {
<> <>
{appData ? ( {appData ? (
<form className="flex max-w-md flex-col gap-2" ref={authorizeFormRef}> <form className="flex max-w-md flex-col gap-2" ref={authorizeFormRef}>
<div>
<Typography>
<FormattedMessage id="accounts.new.authorization_url" />
</Typography>
</div>
<div className="w-full px-1 flex justify-between">
<span className="whitespace-nowrap overflow-x-auto w-11/12 p-1 bg-gray-200 dark:bg-gray-800 no-scroll">
{appData.url}
</span>
<IconButton size="sm" variant="text" color="blue" onClick={() => copyText(appData.url)}>
<FaPaperclip className="text-xl" />
</IconButton>
</div>
{appData.session_token ? ( {appData.session_token ? (
<> <>
<div className="block text-gray-600"> <div className="block text-gray-600">