Skip to content

Commit 8286641

Browse files
authored
fix(app): connect to cdn modal instructions (#6824)
1 parent 719f169 commit 8286641

File tree

5 files changed

+103
-35
lines changed

5 files changed

+103
-35
lines changed

packages/web/app/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@
114114
"react-icons": "5.4.0",
115115
"react-select": "5.9.0",
116116
"react-string-replace": "1.1.1",
117+
"react-textarea-autosize": "8.5.9",
117118
"react-toastify": "10.0.6",
118119
"react-virtualized-auto-sizer": "1.0.25",
119120
"react-virtuoso": "4.12.3",

packages/web/app/src/components/layouts/target.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -536,9 +536,10 @@ function FederationModalContent(props: {
536536
{authenticateSection}
537537
<div className="mt-2">
538538
<InputCopy
539+
multiline
539540
value={`docker run --name hive-gateway --rm -p 4000:4000 \\
540541
ghcr.io/graphql-hive/gateway supergraph \\
541-
'${props.cdnUrl}' \\
542+
"${props.cdnUrl}" \\
542543
--hive-cdn-key '<hive_cdn_access_key>'`}
543544
/>
544545
</div>
@@ -557,6 +558,7 @@ function FederationModalContent(props: {
557558
</p>
558559
{authenticateSection}
559560
<InputCopy
561+
multiline
560562
value={`docker run --name hive-gateway --rm \\
561563
--env HIVE_CDN_ENDPOINT="${props.cdnUrl}" \\
562564
--env HIVE_CDN_KEY="<hive_cdn_access_key>"
@@ -575,14 +577,17 @@ function FederationModalContent(props: {
575577
.
576578
</p>
577579
</TabsContent>
578-
<TabsContent value="cdn" className="space-y-2 pt-2" variant="content">
580+
<TabsContent value="cdn" variant="content">
579581
<p>For other tooling you can access the raw supergraph by sending a HTTP request.</p>
580582
<p>To access your schema from Hive's CDN, use the following endpoint:</p>
581-
<InputCopy value={`${props.cdnUrl}/supergraph`} />
583+
<div>
584+
<InputCopy multiline value={`${props.cdnUrl}/supergraph`} />
585+
</div>
582586
<p>Here is an example calling the endpoint using curl.</p>
583587
{authenticateSection}
584588
<div className="mt-2">
585589
<InputCopy
590+
multiline
586591
value={`curl -H 'X-Hive-CDN-Key: <hive_cdn_access_key>' \\
587592
${props.cdnUrl}/supergraph`}
588593
/>

packages/web/app/src/components/ui/input-copy.tsx

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ import { useCallback, useEffect, useState } from 'react';
22
import { CheckIcon, CopyIcon } from 'lucide-react';
33
import { Button } from '@/components/ui/button';
44
import { Input } from '@/components/ui/input';
5+
import { Textarea } from '@/components/ui/textarea';
56
import { useClipboard } from '@/lib/hooks';
67

7-
export function InputCopy(props: { value: string; className?: string }) {
8+
export function InputCopy(props: { value: string; className?: string; multiline?: boolean }) {
89
const [isCopied, setIsCopied] = useState(false);
910
const copyToClipboard = useClipboard();
1011

@@ -22,25 +23,35 @@ export function InputCopy(props: { value: string; className?: string }) {
2223
const handleClick = useCallback(async () => {
2324
await copyToClipboard(props.value);
2425
setIsCopied(true);
25-
}, [copyToClipboard]);
26+
}, [copyToClipboard, props.value]);
2627

2728
return (
2829
<div className="flex w-full max-w-2xl items-center space-x-2">
29-
<div className="relative grow">
30-
<Input
31-
type="text"
30+
{props.multiline ? (
31+
<Textarea
3232
value={props.value}
3333
readOnly
34-
className={`bg-secondary truncate text-white ${props.className}`}
34+
autoSize
3535
onFocus={ev => ev.target.select()}
36+
className={`bg-secondary w-full resize-none font-mono text-xs text-white ${props.className}`}
3637
/>
37-
</div>
38+
) : (
39+
<div className="relative grow">
40+
<Input
41+
type="text"
42+
value={props.value}
43+
readOnly
44+
className={`bg-secondary truncate text-white ${props.className}`}
45+
onFocus={ev => ev.target.select()}
46+
/>
47+
</div>
48+
)}
3849
<Button
3950
type="button"
4051
onClick={handleClick}
4152
variant="outline"
4253
size="icon"
43-
className="bg-secondary size-10 shrink-0"
54+
className="bg-secondary size-10 shrink-0 self-baseline"
4455
>
4556
{isCopied ? (
4657
<CheckIcon className="size-4 text-emerald-500" />

packages/web/app/src/components/ui/textarea.tsx

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
import React from 'react';
2+
import TextareaAutosize from 'react-textarea-autosize';
23
import { cn } from '@/lib/utils';
34

45
type TextareaProps = React.TextareaHTMLAttributes<HTMLTextAreaElement>;
56

6-
const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(
7-
({ className, ...props }, ref) => {
8-
return (
9-
<textarea
10-
className={cn(
11-
'border-input bg-background ring-offset-background placeholder:text-muted-foreground focus-visible:ring-ring flex min-h-[80px] w-full rounded-md border px-3 py-2 text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50',
12-
className,
13-
)}
14-
ref={ref}
15-
{...props}
16-
/>
7+
const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps & { autoSize?: boolean }>(
8+
({ className, autoSize, ...props }, ref) => {
9+
const classNameFinal = cn(
10+
'border-input bg-background ring-offset-background placeholder:text-muted-foreground focus-visible:ring-ring flex min-h-[80px] w-full rounded-md border px-3 py-2 text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50',
11+
autoSize && 'min-h-[0px]',
12+
className,
1713
);
14+
15+
if (autoSize) {
16+
return <TextareaAutosize className={classNameFinal} ref={ref} {...(props as any)} />;
17+
}
18+
19+
return <textarea className={classNameFinal} ref={ref} {...props} />;
1820
},
1921
);
2022
Textarea.displayName = 'Textarea';

pnpm-lock.yaml

Lines changed: 62 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)