From 838ff5c4dd82a4283b3e353552312ff9ec82cb24 Mon Sep 17 00:00:00 2001 From: Krzysztof Kowalczyk Date: Fri, 18 Oct 2024 12:09:54 +0200 Subject: [PATCH] [Share] Add loading state to link_content (#196809) ## Summary This PR adds a loading state to `Copy Link` button in share modal. Fixes: #194641 (cherry picked from commit 32dec20719f12277234d99953370a4060d4ebaac) --- .../share/public/components/tabs/link/link_content.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/plugins/share/public/components/tabs/link/link_content.tsx b/src/plugins/share/public/components/tabs/link/link_content.tsx index 9527fad4ef37b..389080cc37296 100644 --- a/src/plugins/share/public/components/tabs/link/link_content.tsx +++ b/src/plugins/share/public/components/tabs/link/link_content.tsx @@ -54,6 +54,7 @@ export const LinkContent = ({ const [urlParams] = useState(undefined); const [isTextCopied, setTextCopied] = useState(false); const [shortUrlCache, setShortUrlCache] = useState(undefined); + const [isLoading, setIsLoading] = useState(false); const getUrlWithUpdatedParams = useCallback( (tempUrl: string): string => { @@ -99,6 +100,7 @@ export const LinkContent = ({ }, [shareableUrlLocatorParams, urlService.shortUrls, getSnapshotUrl, setShortUrlCache]); const copyUrlHelper = useCallback(async () => { + setIsLoading(true); let urlToCopy = url; if (!urlToCopy || delegatedShareUrlHandler) { @@ -112,6 +114,7 @@ export const LinkContent = ({ copyToClipboard(urlToCopy); setUrl(urlToCopy); setTextCopied(true); + setIsLoading(false); return urlToCopy; }, [url, delegatedShareUrlHandler, allowShortUrl, createShortUrl, getSnapshotUrl]); @@ -164,6 +167,7 @@ export const LinkContent = ({ onBlur={() => (objectType === 'lens' && isDirty ? null : setTextCopied(false))} onClick={copyUrlHelper} color={objectType === 'lens' && isDirty ? 'warning' : 'primary'} + isLoading={isLoading} >