From 8cde912fdff5d0d64e8071af9e7c18e8c9c5fc91 Mon Sep 17 00:00:00 2001
From: Orne Brocaar <info@brocaar.com>
Date: Tue, 19 Mar 2024 14:12:03 +0000
Subject: [PATCH] Show error when navigator.clipboard is not available.

There can be multiple reasons for this, e.g. it is not supported by the
browser or the browser does not provide this feature because there is no
secure context (HTTP).

Closes #231.
---
 ui/src/components/AesKeyInput.tsx  | 6 ++++++
 ui/src/components/DevAddrInput.tsx | 6 ++++++
 ui/src/components/EuiInput.tsx     | 6 ++++++
 3 files changed, 18 insertions(+)

diff --git a/ui/src/components/AesKeyInput.tsx b/ui/src/components/AesKeyInput.tsx
index e23ab68d..334fd5c2 100644
--- a/ui/src/components/AesKeyInput.tsx
+++ b/ui/src/components/AesKeyInput.tsx
@@ -96,6 +96,12 @@ function AesKeyInput(props: IProps) {
             duration: 3,
           });
         });
+    } else {
+      notification.error({
+        message: "Error",
+        description: "Clipboard functionality is not available.",
+        duration: 3,
+      });
     }
   };
 
diff --git a/ui/src/components/DevAddrInput.tsx b/ui/src/components/DevAddrInput.tsx
index e72f6795..d372be6e 100644
--- a/ui/src/components/DevAddrInput.tsx
+++ b/ui/src/components/DevAddrInput.tsx
@@ -99,6 +99,12 @@ function DevAddrInput(props: IProps) {
             duration: 3,
           });
         });
+    } else {
+      notification.error({
+        message: "Error",
+        description: "Clipboard functionality is not available.",
+        duration: 3,
+      });
     }
   };
 
diff --git a/ui/src/components/EuiInput.tsx b/ui/src/components/EuiInput.tsx
index 791f8361..ba95ed5c 100644
--- a/ui/src/components/EuiInput.tsx
+++ b/ui/src/components/EuiInput.tsx
@@ -96,6 +96,12 @@ function EuiInput(props: IProps) {
             duration: 3,
           });
         });
+    } else {
+      notification.error({
+        message: "Error",
+        description: "Clipboard functionality is not available.",
+        duration: 3,
+      });
     }
   };