From aeedad170570fc8b336b2afe0cfac851e3e22f86 Mon Sep 17 00:00:00 2001 From: Praveen K B Date: Thu, 9 Jan 2025 10:39:44 +0530 Subject: [PATCH] fix: Removed options for insecure http --- .../Stream/Views/Explore/StaticLogTable.tsx | 32 +++++++++++-------- src/utils/index.ts | 27 +++------------- 2 files changed, 22 insertions(+), 37 deletions(-) diff --git a/src/pages/Stream/Views/Explore/StaticLogTable.tsx b/src/pages/Stream/Views/Explore/StaticLogTable.tsx index 8a3b98f0..3f138768 100644 --- a/src/pages/Stream/Views/Explore/StaticLogTable.tsx +++ b/src/pages/Stream/Views/Explore/StaticLogTable.tsx @@ -341,20 +341,24 @@ const Table = (props: { primaryHeaderHeight: number }) => { return null; })()} - { - copyJSON(); - closeContextMenu(); - }}> - Copy JSON - - { - copyUrl(); - closeContextMenu(); - }}> - Copy permalink - + {isSecureHTTPContext && ( + <> + { + copyJSON(); + closeContextMenu(); + }}> + Copy JSON + + { + copyUrl(); + closeContextMenu(); + }}> + Copy permalink + + + )} )} diff --git a/src/utils/index.ts b/src/utils/index.ts index efaf7a87..2f8e36cf 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -99,32 +99,13 @@ export const addOrRemoveElement = (array: any[], element: any) => { }; export const copyTextToClipboard = async (value: any) => { - try { - await navigator.clipboard.writeText(_.isString(value) ? value : JSON.stringify(value, null, 2)); - } catch (error) { - console.warn('Clipboard API failed, falling back to execCommand:', error); - fallbackCopyToClipboard(value); + if (_.isString(value)) { + return await navigator.clipboard.writeText(value); + } else { + return await navigator.clipboard.writeText(JSON.stringify(value, null, 2)); } }; -function fallbackCopyToClipboard(text: string) { - const textarea = document.createElement('textarea'); - textarea.value = text; - document.body.appendChild(textarea); - textarea.select(); - try { - const successful = document.execCommand('copy'); - if (successful) { - alert('Copied to clipboard!'); - } else { - alert('Copy failed. Please copy manually.'); - } - } catch (err) { - console.error('Fallback copy failed:', err); - } - document.body.removeChild(textarea); -} - export const getOffset = (page: number, rowSize: number) => { const product = page * rowSize; if (product % 1000 === 0) {