feat: add a popup on Copy webhook Button to display the webhook url (#117)

This commit is contained in:
Yrobot
2024-11-10 10:56:38 +08:00
committed by GitHub
parent 30cd8ec528
commit d5cceb9589

View File

@@ -1,5 +1,5 @@
import React, { useEffect, useState } from 'react'; import React, { useEffect, useState } from 'react';
import { Button, Form, Label, Pagination, Table } from 'semantic-ui-react'; import { Button, Form, Label, Pagination, Table, Popup } from 'semantic-ui-react';
import { Link } from 'react-router-dom'; import { Link } from 'react-router-dom';
import { API, copy, showError, showSuccess, showWarning } from '../helpers'; import { API, copy, showError, showSuccess, showWarning } from '../helpers';
@@ -223,6 +223,7 @@ const WebhooksTable = () => {
) )
.map((webhook, idx) => { .map((webhook, idx) => {
if (webhook.deleted) return <></>; if (webhook.deleted) return <></>;
const webhookUrl = `${window.location.origin}/webhook/${webhook.link}`;
return ( return (
<Table.Row key={webhook.id}> <Table.Row key={webhook.id}>
<Table.Cell>{webhook.id}</Table.Cell> <Table.Cell>{webhook.id}</Table.Cell>
@@ -238,13 +239,14 @@ const WebhooksTable = () => {
</Table.Cell> </Table.Cell>
<Table.Cell> <Table.Cell>
<div> <div>
<Popup content={webhookUrl} hoverable trigger={
<Button <Button
size={'small'} size={'small'}
positive positive
onClick={async () => { onClick={async () => {
if ( if (
await copy( await copy(
`${window.location.origin}/webhook/${webhook.link}` webhookUrl
) )
) { ) {
showSuccess('已复制到剪贴板!'); showSuccess('已复制到剪贴板!');
@@ -255,6 +257,7 @@ const WebhooksTable = () => {
> >
复制 Webhook 链接 复制 Webhook 链接
</Button> </Button>
} />
<Button <Button
size={'small'} size={'small'}
negative negative