Skip to content

Commit b1f282c

Browse files
committed
fix: copy tooltip
1 parent 31e5a79 commit b1f282c

File tree

2 files changed

+24
-8
lines changed

2 files changed

+24
-8
lines changed

src/containers/Tenant/Diagnostics/TopQueries/QueryDetails.tsx

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
import React from 'react';
2+
13
import {Code, Link, Xmark} from '@gravity-ui/icons';
2-
import {Button, Icon} from '@gravity-ui/uikit';
4+
import {ActionTooltip, Button, Icon} from '@gravity-ui/uikit';
35

46
import EnableFullscreenButton from '../../../../components/EnableFullscreenButton/EnableFullscreenButton';
57
import Fullscreen from '../../../../components/Fullscreen/Fullscreen';
@@ -29,15 +31,22 @@ export const QueryDetails = ({
2931
onOpenInEditor,
3032
onCopyLink,
3133
}: QueryDetailsProps) => {
34+
const [isTooltipOpen, setIsTooltipOpen] = React.useState(false);
35+
3236
// Function to copy current URL to clipboard
3337
const copyLinkToClipboard = (e: React.MouseEvent) => {
3438
e.stopPropagation();
3539

40+
setIsTooltipOpen(true);
3641
// If onCopyLink is provided, call it to generate and copy a shareable URL
3742
// The actual copy to clipboard is handled in the parent component
3843
if (onCopyLink) {
3944
onCopyLink();
4045
}
46+
47+
setTimeout(() => {
48+
setIsTooltipOpen(false);
49+
}, 1000);
4150
};
4251

4352
return (
@@ -46,13 +55,19 @@ export const QueryDetails = ({
4655
<div className={b('title')}>Query</div>
4756
<div className={b('actions')}>
4857
{onCopyLink && (
49-
<Button
50-
view="flat-secondary"
51-
onClick={copyLinkToClipboard}
52-
title={i18n('query-details.copy-link')}
58+
<ActionTooltip
59+
disabled={!isTooltipOpen}
60+
closeDelay={1000}
61+
title={i18n('query-details.link-copied')}
5362
>
54-
<Icon data={Link} size={16} />
55-
</Button>
63+
<Button
64+
view="flat-secondary"
65+
onClick={copyLinkToClipboard}
66+
title={i18n('query-details.copy-link')}
67+
>
68+
<Icon data={Link} size={16} />
69+
</Button>
70+
</ActionTooltip>
5671
)}
5772
<EnableFullscreenButton />
5873
<Button view="flat-secondary" onClick={onClose}>

src/containers/Tenant/Diagnostics/TopQueries/i18n/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@
1313
"query-details.not-found.description": "This query no longer exists",
1414
"query-not-found": "Query Not Found",
1515
"query-not-found.description": "The selected query is no longer available in the current dataset",
16-
"query-details.copy-link": "Copy link to query"
16+
"query-details.copy-link": "Copy link to query",
17+
"query-details.link-copied": "Copied to clipboard"
1718
}

0 commit comments

Comments
 (0)