diff --git a/packages/web/app/src/components/layouts/target.tsx b/packages/web/app/src/components/layouts/target.tsx index 9f3b7abc7..9a8c231f5 100644 --- a/packages/web/app/src/components/layouts/target.tsx +++ b/packages/web/app/src/components/layouts/target.tsx @@ -1,5 +1,5 @@ import { ReactElement, ReactNode, useMemo, useState } from 'react'; -import { CopyIcon, LinkIcon } from 'lucide-react'; +import { LinkIcon } from 'lucide-react'; import { useQuery } from 'urql'; import { Button } from '@/components/ui/button'; import { @@ -10,6 +10,7 @@ import { DialogTitle, } from '@/components/ui/dialog'; import { HiveLink } from '@/components/ui/hive-link'; +import { InputCopy } from '@/components/ui/input-copy'; import { Link as UiLink } from '@/components/ui/link'; import { Select, @@ -22,7 +23,7 @@ import { UserMenu } from '@/components/ui/user-menu'; import { graphql } from '@/gql'; import { ProjectType } from '@/gql/graphql'; import { getDocsUrl } from '@/lib/docs-url'; -import { useClipboard, useToggle } from '@/lib/hooks'; +import { useToggle } from '@/lib/hooks'; import { useResetState } from '@/lib/hooks/use-reset-state'; import { useLastVisitedOrganizationWriter } from '@/lib/last-visited-org'; import { cn } from '@/lib/utils'; @@ -31,8 +32,6 @@ import { ProjectMigrationToast } from '../project/migration-toast'; import { ResourceNotFoundComponent } from '../resource-not-found'; import { Label } from '../ui/label'; import { Tabs, TabsContent, TabsList, TabsTrigger } from '../ui/tabs'; -import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '../ui/tooltip'; -import { useToast } from '../ui/use-toast'; import { TargetSelector } from './target-selector'; export enum Page { @@ -458,9 +457,12 @@ export function ConnectSchemaModal(props: { ) : (

To access your schema from Hive's CDN, use the following endpoint:

- - {composeEndpoint(selectedContract?.cdnUrl ?? target.cdnUrl, selectedArtifact)} - +

To authenticate,{' '}

- {'X-Hive-CDN-Key: '} +
)} @@ -541,12 +543,14 @@ function FederationModalContent(props: { following command.

{authenticateSection} - - {`docker run --name hive-gateway --rm -p 4000:4000 \\ +
+ '`} - + /> +

For more information please refer to our{' '} @@ -561,12 +565,12 @@ function FederationModalContent(props: { following command.

{authenticateSection} - - {`docker run --name hive-gateway --rm \\ + + />

For more information please refer to our{' '}

For other tooling you can access the raw supergraph by sending a HTTP request.

To access your schema from Hive's CDN, use the following endpoint:

- {`${props.cdnUrl}/supergraph`} +

Here is an example calling the endpoint using curl.

{authenticateSection} - - {`curl -H 'X-Hive-CDN-Key: ' \\ +
+ ' \\ ${props.cdnUrl}/supergraph`} - + /> +

For more information please refer to our{' '} ); } - -function CodeBlock(props: { children: string; className?: string }) { - const copy = useClipboard(); - const toast = useToast(); - - return ( -

-
- - - - - - -

Copy command to clipboard

-
-
-
-
-          {props.children}
-        
-
-
- ); -} diff --git a/packages/web/app/src/components/target/laboratory/connect-lab-modal.tsx b/packages/web/app/src/components/target/laboratory/connect-lab-modal.tsx index 200d17e0f..a4ec94f19 100644 --- a/packages/web/app/src/components/target/laboratory/connect-lab-modal.tsx +++ b/packages/web/app/src/components/target/laboratory/connect-lab-modal.tsx @@ -9,8 +9,9 @@ import { DialogHeader, DialogTitle, } from '@/components/ui/dialog'; +import { InputCopy } from '@/components/ui/input-copy'; import { Link } from '@/components/ui/link'; -import { CopyValue, Tag } from '@/components/v2'; +import { Tag } from '@/components/v2'; import { FragmentType, graphql, useFragment } from '@/gql'; import { getDocsUrl } from '@/lib/docs-url'; @@ -70,7 +71,7 @@ export const ConnectLabModalContent = (props: { ) : null} You can use the following endpoint: - + To authenticate, use the following HTTP headers, with a token that has `target:read` scope: diff --git a/packages/web/app/src/components/target/settings/registry-access-token.tsx b/packages/web/app/src/components/target/settings/registry-access-token.tsx index 1df51344c..d58d0df1d 100644 --- a/packages/web/app/src/components/target/settings/registry-access-token.tsx +++ b/packages/web/app/src/components/target/settings/registry-access-token.tsx @@ -15,9 +15,9 @@ import { } from '@/components/ui/dialog'; import { Form, FormControl, FormField, FormItem, FormMessage } from '@/components/ui/form'; import { Input } from '@/components/ui/input'; +import { InputCopy } from '@/components/ui/input-copy'; import { useToast } from '@/components/ui/use-toast'; import { Accordion } from '@/components/v2/accordion'; -import { CopyValue } from '@/components/v2/copy-value'; import { FragmentType, graphql, useFragment } from '@/gql'; import { TargetAccessScope } from '@/gql/graphql'; import { RegistryAccessScope } from '@/lib/access/common'; @@ -228,7 +228,7 @@ export function CreatedTokenContent(props: { Token successfully created! - + This is your unique API key and it is non-recoverable. If you lose this key, you will need to create a new one. diff --git a/packages/web/app/src/components/ui/input-copy.tsx b/packages/web/app/src/components/ui/input-copy.tsx new file mode 100644 index 000000000..b1defa7b5 --- /dev/null +++ b/packages/web/app/src/components/ui/input-copy.tsx @@ -0,0 +1,53 @@ +import { useCallback, useEffect, useState } from 'react'; +import { CheckIcon, CopyIcon } from 'lucide-react'; +import { Button } from '@/components/ui/button'; +import { Input } from '@/components/ui/input'; +import { useClipboard } from '@/lib/hooks'; + +export function InputCopy(props: { value: string }) { + const [isCopied, setIsCopied] = useState(false); + const copyToClipboard = useClipboard(); + + useEffect(() => { + if (!isCopied) return; + const timerId = setTimeout(() => { + setIsCopied(false); + }, 2000); + + return () => { + clearTimeout(timerId); + }; + }, [isCopied]); + + const handleClick = useCallback(async () => { + await copyToClipboard(props.value); + setIsCopied(true); + }, [copyToClipboard]); + + return ( +
+
+ +
+ +
+ ); +} diff --git a/packages/web/app/src/components/v2/copy-value.tsx b/packages/web/app/src/components/v2/copy-value.tsx deleted file mode 100644 index c1bb98095..000000000 --- a/packages/web/app/src/components/v2/copy-value.tsx +++ /dev/null @@ -1,51 +0,0 @@ -import { ReactElement, useCallback, useEffect, useState } from 'react'; -import { CheckIcon, CopyIcon } from '@/components/ui/icon'; -import { Input } from '@/components/v2'; -import { useClipboard } from '@/lib/hooks'; -import { Button } from '../ui/button'; - -export const CopyValue = ({ - value, - className, -}: { - value: string; - className?: string; -}): ReactElement => { - const [isCopied, setIsCopied] = useState(false); - const copyToClipboard = useClipboard(); - - useEffect(() => { - if (!isCopied) return; - const timerId = setTimeout(() => { - setIsCopied(false); - }, 2000); - - return () => { - clearTimeout(timerId); - }; - }, [isCopied]); - - const handleClick = useCallback(async () => { - await copyToClipboard(value); - setIsCopied(true); - }, [value, copyToClipboard]); - - return ( - - {isCopied ? : } - - } - /> - ); -}; diff --git a/packages/web/app/src/components/v2/index.ts b/packages/web/app/src/components/v2/index.ts index 11b3de0e4..388565f77 100644 --- a/packages/web/app/src/components/v2/index.ts +++ b/packages/web/app/src/components/v2/index.ts @@ -3,7 +3,6 @@ export { Autocomplete } from '@/components/v2/autocomplete'; export { Avatar } from '@/components/v2/avatar'; export { Card } from '@/components/v2/card'; export { Checkbox } from '@/components/v2/checkbox'; -export { CopyValue } from '@/components/v2/copy-value'; export { DataWrapper } from '@/components/v2/data-wrapper'; export { DiffEditor } from '@/components/v2/diff-editor'; export { Input } from '@/components/v2/input';