Skip to content

Commit

Permalink
Merge pull request #4968 from h3poteto/iss-4961
Browse files Browse the repository at this point in the history
refs #4961 Show authorization URL in login modal
  • Loading branch information
h3poteto authored Jun 13, 2024
2 parents 1b7ba78 + 4990a1c commit f46dc86
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
1 change: 1 addition & 0 deletions locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"domain": "Domain",
"sign_in": "Sign in",
"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_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",
Expand Down
4 changes: 4 additions & 0 deletions renderer/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@
opacity: 1;
}

.no-scroll::-webkit-scrollbar {
display: none;
}

button:focus {
outline: none;
}
Expand Down
20 changes: 19 additions & 1 deletion renderer/components/accounts/New.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import generator, { MegalodonInterface, OAuth, detector } from 'megalodon'
import { useCallback, useEffect, useRef, useState } from 'react'
import { db } from '@/db'
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 { FaPaperclip } from 'react-icons/fa6'

type NewProps = {
opened: boolean
Expand Down Expand Up @@ -77,6 +78,10 @@ export default function New(props: NewProps) {
}
}, [props.opened, sns])

const copyText = (text: string) => {
navigator.clipboard.writeText(text)
}

const authorize = async () => {
setError('')
setLoading(true)
Expand Down Expand Up @@ -169,6 +174,19 @@ export default function New(props: NewProps) {
<>
{appData ? (
<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 ? (
<>
<div className="block text-gray-600">
Expand Down

0 comments on commit f46dc86

Please sign in to comment.