Skip to content

Commit 04b9e9b

Browse files
committed
feat: Add copy icons to the two URLs on the config overview page
Closes #898
1 parent b7be770 commit 04b9e9b

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed
Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import { TextLoadingSkeleton } from '@/components/TextLoadingSkeleton';
2+
import { Button } from '@/components/ui/button';
3+
import { useCopyToClipboard } from '@/hooks/useCopyToClipboard';
24
import { Cluster } from '@/lib/api.patch';
5+
import { CopyIcon } from 'lucide-react';
36

47
export const ApplicationURL = ({
58
loadingInstanceInfo,
@@ -8,10 +11,26 @@ export const ApplicationURL = ({
811
loadingInstanceInfo?: boolean;
912
clusterInfo?: Cluster | undefined;
1013
}) => {
14+
const [onCopyClick] = useCopyToClipboard(clusterInfo?.fqdn || '');
1115
return (
1216
<>
1317
<dt className="font-bold text-sm/6">Application URL</dt>
14-
<dd className="text-sm/6 sm:mt-2">{loadingInstanceInfo ? <TextLoadingSkeleton /> : clusterInfo?.fqdn || 'N/A'}</dd>
18+
<dd className="text-sm/6 sm:mt-2">{loadingInstanceInfo
19+
? <TextLoadingSkeleton />
20+
: clusterInfo?.fqdn
21+
? <>
22+
{clusterInfo.fqdn}
23+
<Button
24+
className="ml-2"
25+
type="button"
26+
variant="default"
27+
size="sm"
28+
onClick={onCopyClick}
29+
>
30+
<CopyIcon className="w-4 h-4" />
31+
</Button>
32+
</>
33+
: 'N/A'}</dd>
1534
</>
1635
);
1736
};

src/features/instance/config/overview/components/InstanceURL.tsx

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import { TextLoadingSkeleton } from '@/components/TextLoadingSkeleton';
2+
import { Button } from '@/components/ui/button';
3+
import { useCopyToClipboard } from '@/hooks/useCopyToClipboard';
24
import { Instance } from '@/lib/api.patch';
35
import { getOperationsUrlForInstance } from '@/lib/urls/getOperationsUrlForInstance';
46
import { Link } from '@tanstack/react-router';
7+
import { CopyIcon } from 'lucide-react';
58
import { useMemo } from 'react';
69

710
export const InstanceURL = ({
@@ -12,13 +15,26 @@ export const InstanceURL = ({
1215
instanceInfo?: Instance | undefined;
1316
}) => {
1417
const instanceUrl = useMemo(() => instanceInfo ? getOperationsUrlForInstance(instanceInfo) : null, [instanceInfo]);
18+
const [onCopyClick] = useCopyToClipboard(instanceUrl || '');
1519
return (
1620
<>
1721
<dt className="font-bold text-sm/6">Operations URL</dt>
1822
<dd className="text-sm/6 sm:mt-2">{loadingInstanceInfo
1923
? (<TextLoadingSkeleton />)
2024
: instanceUrl
21-
? (<Link to={instanceUrl} target="_blank" className="underline hover:text-blue-300">{instanceUrl}</Link>)
25+
? (
26+
<>
27+
<Link to={instanceUrl} target="_blank" className="underline hover:text-blue-300">{instanceUrl}</Link>
28+
<Button
29+
className="ml-2"
30+
type="button"
31+
variant="default"
32+
size="sm"
33+
onClick={onCopyClick}
34+
>
35+
<CopyIcon className="w-4 h-4" />
36+
</Button>
37+
</>)
2238
: 'N/A'}</dd>
2339
</>
2440
);

0 commit comments

Comments
 (0)