* Update StreamKeys.tsx * Prettified Code! --------- Co-authored-by: dev265545 <dev265545@users.noreply.github.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import React, { useContext, useEffect, useState } from 'react';
|
import React, { useContext, useEffect, useState } from 'react';
|
||||||
import { Table, Space, Button, Typography, Alert, Input, Form } from 'antd';
|
import { Table, Space, Button, Typography, Alert, Input, Form, message } from 'antd';
|
||||||
import dynamic from 'next/dynamic';
|
import dynamic from 'next/dynamic';
|
||||||
import { ServerStatusContext } from '../../../../utils/server-status-context';
|
import { ServerStatusContext } from '../../../../utils/server-status-context';
|
||||||
|
|
||||||
@@ -136,6 +136,12 @@ const AddKeyButton = ({ setShowAddKeyForm }) => (
|
|||||||
<PlusOutlined />
|
<PlusOutlined />
|
||||||
</Button>
|
</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 StreamKeys = () => {
|
||||||
const serverStatusData = useContext(ServerStatusContext);
|
const serverStatusData = useContext(ServerStatusContext);
|
||||||
@@ -168,7 +174,14 @@ const StreamKeys = () => {
|
|||||||
key: 'key',
|
key: 'key',
|
||||||
render: text => (
|
render: text => (
|
||||||
<Space direction="horizontal">
|
<Space direction="horizontal">
|
||||||
<Paragraph copyable>{showKeyMap[text] ? text : '**********'}</Paragraph>
|
<Paragraph
|
||||||
|
copyable={{
|
||||||
|
text: showKeyMap[text] ? text : '**********',
|
||||||
|
onCopy: () => copyText(text),
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{showKeyMap[text] ? text : '**********'}
|
||||||
|
</Paragraph>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
type="link"
|
type="link"
|
||||||
|
|||||||
Reference in New Issue
Block a user