diff --git a/code/core/src/manager/components/preview/tools/share.stories.tsx b/code/core/src/manager/components/preview/tools/share.stories.tsx index 7884890e1a29..fe0b80327030 100644 --- a/code/core/src/manager/components/preview/tools/share.stories.tsx +++ b/code/core/src/manager/components/preview/tools/share.stories.tsx @@ -41,12 +41,31 @@ type Story = StoryObj; export const Default: Story = { beforeEach: () => { + const originalConfigType = global.CONFIG_TYPE; global.STORYBOOK_NETWORK_ADDRESS = 'http://127.0.0.1:6006'; + global.CONFIG_TYPE = 'DEVELOPMENT'; + + return () => { + global.CONFIG_TYPE = originalConfigType; + }; }, play: async ({ userEvent, canvas }) => { await waitFor(async () => { await userEvent.click(canvas.getByRole('button')); - await expect(await screen.findByText('Scan me')).toBeVisible(); + await expect(await screen.findByText('Scan to open')).toBeVisible(); }); }, }; + +export const Production: Story = { + ...Default, + beforeEach: () => { + const originalConfigType = global.CONFIG_TYPE; + global.STORYBOOK_NETWORK_ADDRESS = 'http://127.0.0.1:6006'; + global.CONFIG_TYPE = 'PRODUCTION'; + + return () => { + global.CONFIG_TYPE = originalConfigType; + }; + }, +}; diff --git a/code/core/src/manager/components/preview/tools/share.tsx b/code/core/src/manager/components/preview/tools/share.tsx index b374ab5ab1e7..2549a76461fa 100644 --- a/code/core/src/manager/components/preview/tools/share.tsx +++ b/code/core/src/manager/components/preview/tools/share.tsx @@ -82,11 +82,13 @@ function ShareMenu({ storyId, queryParams, qrUrl, + isDevelopment, }: { baseUrl: string; storyId: string; queryParams: Record; qrUrl: string; + isDevelopment: boolean; }) { const api = useStorybookApi(); const shortcutKeys = api.getShortcutKeys(); @@ -129,8 +131,12 @@ function ShareMenu({ - Scan me - Must be on the same network as this device. + Scan to open + + {isDevelopment + ? 'Device must be on the same network.' + : 'View story on another device.'} + ), @@ -138,9 +144,9 @@ function ShareMenu({ ]); return baseLinks; - }, [baseUrl, storyId, queryParams, copied, qrUrl, enableShortcuts, copyStoryLink]); + }, [baseUrl, storyId, queryParams, copied, qrUrl, enableShortcuts, copyStoryLink, isDevelopment]); - return ; + return ; } export const shareTool: Addon_BaseType = { @@ -152,15 +158,18 @@ export const shareTool: Addon_BaseType = { return ( {({ baseUrl, storyId, queryParams }) => { + const isDevelopment = global.CONFIG_TYPE === 'DEVELOPMENT'; const storyUrl = global.STORYBOOK_NETWORK_ADDRESS - ? `${global.STORYBOOK_NETWORK_ADDRESS}${window.location.search}` + ? new URL(window.location.search, global.STORYBOOK_NETWORK_ADDRESS).href : window.location.href; return storyId ? ( } + tooltip={ + + } >