Skip to content

Commit b18016e

Browse files
[UI] Disable copy button if not secure (#11427)
- Hide copy button if not within secure context - Ref: #11422
1 parent ac9a1f2 commit b18016e

4 files changed

Lines changed: 10 additions & 2 deletions

File tree

src/frontend/src/components/buttons/CopyButton.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ export function CopyButton({
3838
}>) {
3939
const ButtonComponent = label ? Button : ActionIcon;
4040

41+
// Disable the copy button if we are not in a secure context, as the Clipboard API is not available
42+
if (!window.isSecureContext) {
43+
return null;
44+
}
45+
4146
return (
4247
<MantineCopyButton value={value}>
4348
{({ copied, copy }) => (

src/frontend/src/forms/CompanyForms.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export function useSupplierPartFields({
3939
},
4040
manufacturer_part: {
4141
value: manufacturerPartId,
42+
autoFill: true,
4243
filters: {
4344
manufacturer: manufacturerId,
4445
part_detail: true,

src/frontend/src/tables/CopyableCell.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export function CopyableCell({
2929
align='center'
3030
>
3131
{children}
32-
{isHovered && value != null && (
32+
{window.isSecureContext && isHovered && value != null && (
3333
<span
3434
style={{ position: 'relative' }}
3535
onClick={(e) => e.stopPropagation()}

src/frontend/src/tables/InvenTreeTable.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,10 @@ export function InvenTreeTable<T extends Record<string, any>>({
285285
}
286286
const copyValue = rawCopyValue == null ? '' : String(rawCopyValue);
287287

288-
if (!!copyValue) {
288+
if (window.isSecureContext && !!copyValue) {
289289
return <CopyableCell value={copyValue}>{content}</CopyableCell>;
290+
} else {
291+
return content;
290292
}
291293
};
292294
}

0 commit comments

Comments
 (0)