From 77dad9ef642ff70c7680399545dd1369beb5a553 Mon Sep 17 00:00:00 2001 From: Tuval Simha Date: Sun, 18 Aug 2024 21:32:50 +0300 Subject: [PATCH] (7)Drop V2: Connect Lab Modal (#5320) --- .../target/laboratory/connect-lab-modal.tsx | 137 ++++++++++++------ .../src/stories/connect-lab-modal.stories.tsx | 50 +++++++ 2 files changed, 139 insertions(+), 48 deletions(-) create mode 100644 packages/web/app/src/stories/connect-lab-modal.stories.tsx 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 05892d72e..200d17e0f 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 @@ -1,9 +1,16 @@ import { type ReactElement } from 'react'; -import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert'; import { Button } from '@/components/ui/button'; -import { Heading } from '@/components/ui/heading'; +import { Callout } from '@/components/ui/callout'; +import { + Dialog, + DialogContent, + DialogDescription, + DialogFooter, + DialogHeader, + DialogTitle, +} from '@/components/ui/dialog'; import { Link } from '@/components/ui/link'; -import { CopyValue, Modal, Tag } from '@/components/v2'; +import { CopyValue, Tag } from '@/components/v2'; import { FragmentType, graphql, useFragment } from '@/gql'; import { getDocsUrl } from '@/lib/docs-url'; @@ -20,52 +27,86 @@ export const ConnectLabModal = (props: { isCDNEnabled: FragmentType | null; }): ReactElement => { const docsUrl = getDocsUrl('/management/targets#registry-access-tokens'); - const isCDNEnabled = useFragment(Laboratory_IsCDNEnabledFragment, props.isCDNEnabled); + const isCDNEnabled = useFragment( + Laboratory_IsCDNEnabledFragment, + props.isCDNEnabled, + )?.isCDNEnabled; return ( - - Use GraphQL Schema Externally -

- Hive allow you to consume and use the Laboratory schema with your configured mocks while - developing. -

- {isCDNEnabled?.isCDNEnabled ? ( - - High-availability CDN - - If you want to consume the GraphQL schema for a tool like GraphQL Code Generator, we - instead recommend using the high-availability CDN instead. - - - ) : null} - You can use the following endpoint: - - - To authenticate, use the following HTTP headers, with a token that has `target:read` scope: - - - X-Hive-Key: - - YOUR_TOKEN_HERE - - -

- Read the{' '} - - Managing Tokens - {' '} - chapter in our documentation to create a Registry Access Token. -

- -
+ + ); +}; + +export const ConnectLabModalContent = (props: { + isOpen: boolean; + close: () => void; + endpoint: string; + isCDNEnabled?: boolean; + docsUrl: string; +}) => { + return ( + + + + Use GraphQL Schema Externally + + Hive allow you to consume and use the Laboratory schema with your configured mocks while + developing. + + + {props?.isCDNEnabled ? ( +
+

High-availability CDN:

+ + If you want to consume the GraphQL schema for a tool like GraphQL Code Generator, we + instead recommend using the high-availability CDN instead. + +
+ ) : null} + You can use the following endpoint: + + + To authenticate, use the following HTTP headers, with a token that has `target:read` + scope: + + + X-Hive-Key: + + YOUR_TOKEN_HERE + + +

+ Read the{' '} + + Managing Tokens + {' '} + chapter in our documentation to create a Registry Access Token. +

+ + + +
+
); }; diff --git a/packages/web/app/src/stories/connect-lab-modal.stories.tsx b/packages/web/app/src/stories/connect-lab-modal.stories.tsx new file mode 100644 index 000000000..f7db6f674 --- /dev/null +++ b/packages/web/app/src/stories/connect-lab-modal.stories.tsx @@ -0,0 +1,50 @@ +import { ConnectLabModalContent } from '@/components/target/laboratory/connect-lab-modal'; +import { Meta, StoryFn, StoryObj } from '@storybook/react'; + +const meta: Meta = { + title: 'Modals/Connect Lab Modal', + component: ConnectLabModalContent, + argTypes: { + isOpen: { + control: 'boolean', + }, + close: { + action: 'close', + }, + docsUrl: { + control: 'text', + }, + endpoint: { + control: 'text', + }, + isCDNEnabled: { + control: 'boolean', + }, + }, +}; + +export default meta; + +type Story = StoryObj; + +const Template: StoryFn = args => { + return ; +}; + +export const isCDNEnabled: Story = Template.bind({}); +isCDNEnabled.args = { + isOpen: true, + close: () => console.log('Close'), + docsUrl: 'https://example.com', + endpoint: 'https://example.com', + isCDNEnabled: true, +}; + +export const isCDNDisabled: Story = Template.bind({}); +isCDNDisabled.args = { + isOpen: true, + close: () => console.log('Close'), + docsUrl: 'https://example.com', + endpoint: 'https://example.com', + isCDNEnabled: false, +};