Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

2.7 KB
Raw Blame
import type { Meta, StoryObj } from '@storybook/react'
import { useActions, useValues } from 'kea'
import { router } from 'kea-router'

import { useOnMountEffect } from 'lib/hooks/useOnMountEffect'
import { teamLogic } from 'scenes/teamLogic'
import { urls } from 'scenes/urls'

import { mswDecorator, useStorybookMocks } from '~/mocks/browser'
import { TeamPublicType } from '~/types'

import { ToolbarLaunch } from './ToolbarLaunch'

type Story = StoryObj<{}>
const meta: Meta = {
    title: 'Scenes-Other/ToolbarLaunch',
    parameters: {
        layout: 'fullscreen',
        testOptions: {
            includeNavigationInSnapshot: true,
        },
        viewMode: 'story',
        mockDate: '2024-01-01',
    },
    decorators: [
        mswDecorator({
            post: {
                '/api/environments/:environment_id/query/:kind/': () => [
                    200,
                    {
                        results: [
                            ['https://posthog.com', 150],
                            ['https://app.posthog.com', 100],
                            ['https://docs.posthog.com', 75],
                        ],
                    },
                ],
            },
        }),
    ],
    render: () => {
        useOnMountEffect(() => router.actions.push(urls.dashboards()))

        return <ToolbarLaunch />
    },
}
export default meta

export const Default: Story = {
    args: {},
}

export const NoUrlsTemplate: Story = {
    render: () => {
        const { currentTeam } = useValues(teamLogic)
        const { loadCurrentTeamSuccess } = useActions(teamLogic)

        useOnMountEffect(() => {
            const team = { ...currentTeam, app_urls: [] }
            loadCurrentTeamSuccess(team as TeamPublicType)
        })

        useOnMountEffect(() => router.actions.push(urls.dashboards()))

        return <ToolbarLaunch />
    },
}

export const NoSuggestionsTemplate: Story = {
    render: () => {
        useStorybookMocks({
            post: { '/api/environments/:environment_id/query/:kind/': () => [200, { results: [] }] },
        })

        useOnMountEffect(() => router.actions.push(urls.dashboards()))

        return <ToolbarLaunch />
    },
}

export const EmptyStateTemplate: Story = {
    render: () => {
        const { currentTeam } = useValues(teamLogic)
        const { loadCurrentTeamSuccess } = useActions(teamLogic)

        useOnMountEffect(() => {
            const team = { ...currentTeam, app_urls: [] }
            loadCurrentTeamSuccess(team as TeamPublicType)
        })

        useStorybookMocks({
            post: { '/api/environments/:environment_id/query/:kind/': () => [200, { results: [] }] },
        })

        useOnMountEffect(() => router.actions.push(urls.dashboards()))

        return <ToolbarLaunch />
    },
}