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:
@@ -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 }) => (
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
@@ -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()}
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user