Skip to content

Commit

Permalink
fix: Removed options for insecure http
Browse files Browse the repository at this point in the history
  • Loading branch information
praveen5959 committed Jan 9, 2025
1 parent 44f5007 commit aeedad1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 37 deletions.
32 changes: 18 additions & 14 deletions src/pages/Stream/Views/Explore/StaticLogTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -341,20 +341,24 @@ const Table = (props: { primaryHeaderHeight: number }) => {

return null;
})()}
<Menu.Item
onClick={() => {
copyJSON();
closeContextMenu();
}}>
Copy JSON
</Menu.Item>
<Menu.Item
onClick={() => {
copyUrl();
closeContextMenu();
}}>
Copy permalink
</Menu.Item>
{isSecureHTTPContext && (
<>
<Menu.Item
onClick={() => {
copyJSON();
closeContextMenu();
}}>
Copy JSON
</Menu.Item>
<Menu.Item
onClick={() => {
copyUrl();
closeContextMenu();
}}>
Copy permalink
</Menu.Item>
</>
)}
</Menu>
</div>
)}
Expand Down
27 changes: 4 additions & 23 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit aeedad1

Please sign in to comment.