mirror of
https://github.com/astuto/astuto.git
synced 2025-12-16 11:47:56 +01:00
Add OAuth2 authentication (#147)
- Added Site settings > Authentication section - Create/edit/delete your custom oauth2 configurations - Login or signup with oauth2
This commit is contained in:
committed by
GitHub
parent
3bda6dee08
commit
4c73b398e8
43
app/javascript/components/common/CopyToClipboardButton.tsx
Normal file
43
app/javascript/components/common/CopyToClipboardButton.tsx
Normal file
@@ -0,0 +1,43 @@
|
||||
import * as React from 'react';
|
||||
import I18n from 'i18n-js';
|
||||
import { useState } from 'react';
|
||||
|
||||
interface Props {
|
||||
label: string;
|
||||
textToCopy: string;
|
||||
copiedLabel?: string;
|
||||
}
|
||||
|
||||
const CopyToClipboardButton = ({
|
||||
label,
|
||||
textToCopy,
|
||||
copiedLabel = I18n.t('common.copied')
|
||||
}: Props) => {
|
||||
const [ready, setReady] = useState(true);
|
||||
|
||||
const alertError = () =>
|
||||
alert(`Error in automatically copying to clipboard. Please copy the callback url manually:\n\n${textToCopy}`);
|
||||
|
||||
return (
|
||||
ready ?
|
||||
<a
|
||||
onClick={() => {
|
||||
if (navigator.clipboard) {
|
||||
navigator.clipboard.writeText(textToCopy).then(() => {
|
||||
setReady(false);
|
||||
setTimeout(() => setReady(true), 2000);
|
||||
},
|
||||
alertError);
|
||||
} else {
|
||||
alertError();
|
||||
}
|
||||
}}
|
||||
>
|
||||
{label}
|
||||
</a>
|
||||
:
|
||||
<span>{copiedLabel}</span>
|
||||
);
|
||||
};
|
||||
|
||||
export default CopyToClipboardButton;
|
||||
Reference in New Issue
Block a user