Skip to content

Commit aeedad1

Browse files
committed
fix: Removed options for insecure http
1 parent 44f5007 commit aeedad1

File tree

2 files changed

+22
-37
lines changed

2 files changed

+22
-37
lines changed

src/pages/Stream/Views/Explore/StaticLogTable.tsx

+18-14
Original file line numberDiff line numberDiff line change
@@ -341,20 +341,24 @@ const Table = (props: { primaryHeaderHeight: number }) => {
341341

342342
return null;
343343
})()}
344-
<Menu.Item
345-
onClick={() => {
346-
copyJSON();
347-
closeContextMenu();
348-
}}>
349-
Copy JSON
350-
</Menu.Item>
351-
<Menu.Item
352-
onClick={() => {
353-
copyUrl();
354-
closeContextMenu();
355-
}}>
356-
Copy permalink
357-
</Menu.Item>
344+
{isSecureHTTPContext && (
345+
<>
346+
<Menu.Item
347+
onClick={() => {
348+
copyJSON();
349+
closeContextMenu();
350+
}}>
351+
Copy JSON
352+
</Menu.Item>
353+
<Menu.Item
354+
onClick={() => {
355+
copyUrl();
356+
closeContextMenu();
357+
}}>
358+
Copy permalink
359+
</Menu.Item>
360+
</>
361+
)}
358362
</Menu>
359363
</div>
360364
)}

src/utils/index.ts

+4-23
Original file line numberDiff line numberDiff line change
@@ -99,32 +99,13 @@ export const addOrRemoveElement = (array: any[], element: any) => {
9999
};
100100

101101
export const copyTextToClipboard = async (value: any) => {
102-
try {
103-
await navigator.clipboard.writeText(_.isString(value) ? value : JSON.stringify(value, null, 2));
104-
} catch (error) {
105-
console.warn('Clipboard API failed, falling back to execCommand:', error);
106-
fallbackCopyToClipboard(value);
102+
if (_.isString(value)) {
103+
return await navigator.clipboard.writeText(value);
104+
} else {
105+
return await navigator.clipboard.writeText(JSON.stringify(value, null, 2));
107106
}
108107
};
109108

110-
function fallbackCopyToClipboard(text: string) {
111-
const textarea = document.createElement('textarea');
112-
textarea.value = text;
113-
document.body.appendChild(textarea);
114-
textarea.select();
115-
try {
116-
const successful = document.execCommand('copy');
117-
if (successful) {
118-
alert('Copied to clipboard!');
119-
} else {
120-
alert('Copy failed. Please copy manually.');
121-
}
122-
} catch (err) {
123-
console.error('Fallback copy failed:', err);
124-
}
125-
document.body.removeChild(textarea);
126-
}
127-
128109
export const getOffset = (page: number, rowSize: number) => {
129110
const product = page * rowSize;
130111
if (product % 1000 === 0) {

0 commit comments

Comments
 (0)