mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-15 18:25:54 +08:00
fix: copy to clipboard not copying complete value in case of numbers (#5770)
This commit is contained in:
parent
9f481aacff
commit
6fb2a6d4c9
@ -3,14 +3,14 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
&.small {
|
&.small {
|
||||||
height: 16px;
|
line-height: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
&.medium {
|
&.medium {
|
||||||
height: 20px;
|
line-height: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
&.large {
|
&.large {
|
||||||
height: 24px;
|
line-height: 24px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import { ReactNode, useCallback, useEffect } from 'react';
|
|||||||
import { useCopyToClipboard } from 'react-use';
|
import { useCopyToClipboard } from 'react-use';
|
||||||
|
|
||||||
function CopyClipboardHOC({
|
function CopyClipboardHOC({
|
||||||
|
entityKey,
|
||||||
textToCopy,
|
textToCopy,
|
||||||
children,
|
children,
|
||||||
}: CopyClipboardHOCProps): JSX.Element {
|
}: CopyClipboardHOCProps): JSX.Element {
|
||||||
@ -11,11 +12,15 @@ function CopyClipboardHOC({
|
|||||||
const { notifications } = useNotifications();
|
const { notifications } = useNotifications();
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (value.value) {
|
if (value.value) {
|
||||||
|
const key = entityKey || '';
|
||||||
|
|
||||||
|
const notificationMessage = `${key} copied to clipboard`;
|
||||||
|
|
||||||
notifications.success({
|
notifications.success({
|
||||||
message: 'Copied to clipboard',
|
message: notificationMessage,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, [value, notifications]);
|
}, [value, notifications, entityKey]);
|
||||||
|
|
||||||
const onClick = useCallback((): void => {
|
const onClick = useCallback((): void => {
|
||||||
setCopy(textToCopy);
|
setCopy(textToCopy);
|
||||||
@ -34,6 +39,7 @@ function CopyClipboardHOC({
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface CopyClipboardHOCProps {
|
interface CopyClipboardHOCProps {
|
||||||
|
entityKey: string | undefined;
|
||||||
textToCopy: string;
|
textToCopy: string;
|
||||||
children: ReactNode;
|
children: ReactNode;
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
.tags {
|
.tags {
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 8;
|
flex-wrap: wrap;
|
||||||
|
gap: 8px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ export function TableViewActions(
|
|||||||
);
|
);
|
||||||
|
|
||||||
const [isOpen, setIsOpen] = useState<boolean>(false);
|
const [isOpen, setIsOpen] = useState<boolean>(false);
|
||||||
const textToCopy = fieldData.value.slice(1, -1);
|
const textToCopy = fieldData.value;
|
||||||
|
|
||||||
if (record.field === 'body') {
|
if (record.field === 'body') {
|
||||||
const parsedBody = recursiveParseJSON(fieldData.value);
|
const parsedBody = recursiveParseJSON(fieldData.value);
|
||||||
@ -93,7 +93,7 @@ export function TableViewActions(
|
|||||||
return (
|
return (
|
||||||
<div className={cx('value-field', isOpen ? 'open-popover' : '')}>
|
<div className={cx('value-field', isOpen ? 'open-popover' : '')}>
|
||||||
{record.field === 'body' ? (
|
{record.field === 'body' ? (
|
||||||
<CopyClipboardHOC textToCopy={textToCopy}>
|
<CopyClipboardHOC entityKey={fieldFilterKey} textToCopy={textToCopy}>
|
||||||
<span
|
<span
|
||||||
style={{
|
style={{
|
||||||
color: Color.BG_SIENNA_400,
|
color: Color.BG_SIENNA_400,
|
||||||
@ -104,7 +104,7 @@ export function TableViewActions(
|
|||||||
/>
|
/>
|
||||||
</CopyClipboardHOC>
|
</CopyClipboardHOC>
|
||||||
) : (
|
) : (
|
||||||
<CopyClipboardHOC textToCopy={textToCopy}>
|
<CopyClipboardHOC entityKey={fieldFilterKey} textToCopy={textToCopy}>
|
||||||
<span
|
<span
|
||||||
style={{
|
style={{
|
||||||
color: Color.BG_SIENNA_400,
|
color: Color.BG_SIENNA_400,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user