Skip to content

Commit 3300523

Browse files
committed
Fix review suggestions
1 parent 51b867f commit 3300523

2 files changed

Lines changed: 38 additions & 6 deletions

File tree

frontend/src/components/CodeBoxWithCopy.tsx

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* under the License.
1717
*/
1818

19-
import React, { useState } from 'react';
19+
import React, { useState, useRef, useEffect } from 'react';
2020
import { Box, IconButton } from '@wso2/oxygen-ui';
2121
import { Check, Copy } from '@wso2/oxygen-ui-icons-react';
2222

@@ -26,11 +26,30 @@ interface CodeBoxWithCopyProps {
2626

2727
const CodeBoxWithCopy: React.FC<CodeBoxWithCopyProps> = ({ code }) => {
2828
const [copied, setCopied] = useState(false);
29+
const copyTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);
30+
2931
const handleCopy = async () => {
30-
await navigator.clipboard.writeText(code);
31-
setCopied(true);
32-
setTimeout(() => setCopied(false), 2000);
32+
if (copyTimeoutRef.current) {
33+
clearTimeout(copyTimeoutRef.current);
34+
}
35+
try {
36+
await navigator.clipboard.writeText(code);
37+
setCopied(true);
38+
copyTimeoutRef.current = setTimeout(() => setCopied(false), 2000);
39+
} catch (err) {
40+
// Optionally, show a fallback UI or error message
41+
// For now, just log the error
42+
console.error('Failed to copy to clipboard:', err);
43+
}
3344
};
45+
46+
useEffect(() => {
47+
return () => {
48+
if (copyTimeoutRef.current) {
49+
clearTimeout(copyTimeoutRef.current);
50+
}
51+
};
52+
}, []);
3453
return (
3554
<Box sx={{ position: 'relative', my: 1 }}>
3655
<Box

frontend/src/pages/OrgRuntimes.tsx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,19 @@ function SecretDrawer({ env, onClose }: { env: GqlEnvironment; onClose: () => vo
147147
);
148148
}
149149

150+
enabled = true
151+
environment = "${envName}"
152+
project = "<project name>"
153+
integration = "<integration name>"
154+
runtime = "<unique id for the runtime>"
155+
secret = "${secret}"
156+
#icp_url = "https://<hostname>:9445"`;
157+
environment = "${envName}"
158+
project = "<project name>"
159+
integration = "<integration name>"
160+
runtime = "<unique id for the runtime>"
161+
secret = "${secret}"
162+
#serverUrl="https://<hostname>:9445"`;
150163
function miToml(envName: string, secret: string): string {
151164
return `[icp_config]
152165
enabled = true
@@ -155,7 +168,7 @@ project = "<project name>"
155168
integration = "<integration name>"
156169
runtime = "<unique id for the runtime>"
157170
secret = "${secret}"
158-
#icp_url = "https://<hostname>:9445"`;
171+
# icp_url = "https://<hostname>:9445"`;
159172
}
160173

161174
function biToml(envName: string, secret: string): string {
@@ -165,7 +178,7 @@ project = "<project name>"
165178
integration = "<integration name>"
166179
runtime = "<unique id for the runtime>"
167180
secret = "${secret}"
168-
#serverUrl="https://<hostname>:9445"`;
181+
# serverUrl = "https://<hostname>:9445"`;
169182
}
170183

171184
function AddRuntimeModal({ env, onClose }: { env: GqlEnvironment; onClose: () => void }) {

0 commit comments

Comments
 (0)