Fix for copying stream key without revealing it only copies asterisks (#3663)

* asterisk copy fix for #3460

* rename text to keys for consistency + linting fix

* make onCopy spawn an antd message directly, remove redundant copyText function

---------

Co-authored-by: Muaz Ahmad <mahmad2000@protonmail.com>
This commit is contained in:
mahmed2000 2024-04-11 01:15:53 +05:00 committed by GitHub
parent 9bbb09c911
commit de8bc8d41b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -135,12 +135,6 @@ const AddKeyButton = ({ setShowAddKeyForm }) => (
<PlusOutlined />
</Button>
);
const copyText = (text: string) => {
navigator.clipboard
.writeText(text)
.then(() => message.success('Copied to clipboard'))
.catch(() => message.error('Failed to copy to clipboard'));
};
const StreamKeys = () => {
const serverStatusData = useContext(ServerStatusContext);
@ -171,22 +165,22 @@ const StreamKeys = () => {
title: 'Key',
dataIndex: 'key',
key: 'key',
render: text => (
render: key => (
<Space direction="horizontal">
<Paragraph
copyable={{
text: showKeyMap[text] ? text : '**********',
onCopy: () => copyText(text),
text: key,
onCopy: () => message.success('Copied to clipboard'),
}}
>
{showKeyMap[text] ? text : '**********'}
{showKeyMap[key] ? key : '**********'}
</Paragraph>
<Button
type="link"
style={{ top: '-7px' }}
icon={<EyeOutlined />}
onClick={() => handleToggleShowKey(text)}
onClick={() => handleToggleShowKey(key)}
/>
</Space>
),