2
0
mirror of https://github.com/inventree/InvenTree.git synced 2026-03-01 01:42:49 +00:00

[UI] Disable copy button if not secure (#11427)

- Hide copy button if not within secure context
- Ref: https://github.com/inventree/InvenTree/discussions/11422
This commit is contained in:
Oliver
2026-02-26 09:53:04 +11:00
committed by GitHub
parent ac9a1f2251
commit b18016e43e
4 changed files with 10 additions and 2 deletions

View File

@@ -38,6 +38,11 @@ export function CopyButton({
}>) { }>) {
const ButtonComponent = label ? Button : ActionIcon; const ButtonComponent = label ? Button : ActionIcon;
// Disable the copy button if we are not in a secure context, as the Clipboard API is not available
if (!window.isSecureContext) {
return null;
}
return ( return (
<MantineCopyButton value={value}> <MantineCopyButton value={value}>
{({ copied, copy }) => ( {({ copied, copy }) => (

View File

@@ -39,6 +39,7 @@ export function useSupplierPartFields({
}, },
manufacturer_part: { manufacturer_part: {
value: manufacturerPartId, value: manufacturerPartId,
autoFill: true,
filters: { filters: {
manufacturer: manufacturerId, manufacturer: manufacturerId,
part_detail: true, part_detail: true,

View File

@@ -29,7 +29,7 @@ export function CopyableCell({
align='center' align='center'
> >
{children} {children}
{isHovered && value != null && ( {window.isSecureContext && isHovered && value != null && (
<span <span
style={{ position: 'relative' }} style={{ position: 'relative' }}
onClick={(e) => e.stopPropagation()} onClick={(e) => e.stopPropagation()}

View File

@@ -285,8 +285,10 @@ export function InvenTreeTable<T extends Record<string, any>>({
} }
const copyValue = rawCopyValue == null ? '' : String(rawCopyValue); const copyValue = rawCopyValue == null ? '' : String(rawCopyValue);
if (!!copyValue) { if (window.isSecureContext && !!copyValue) {
return <CopyableCell value={copyValue}>{content}</CopyableCell>; return <CopyableCell value={copyValue}>{content}</CopyableCell>;
} else {
return content;
} }
}; };
} }