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.4 KB
Raw Blame
import { useActions, useValues } from 'kea'

import { LemonButton } from '@posthog/lemon-ui'

import { Spinner } from 'lib/lemon-ui/Spinner'

import { ToolbarMenu } from '~/toolbar/floating/components/bar/ToolbarMenu'

import { productToursLogic } from '../../../shared/product-tours/productToursLogic'

export function ProductToursToolbarMenu(): JSX.Element {
    const { newTour, selectTour } = useActions(productToursLogic)
    const { tours, toursLoading } = useValues(productToursLogic)

    return (
        <ToolbarMenu>
            <ToolbarMenu.Header>
                <span>Product tours</span>
            </ToolbarMenu.Header>
            <ToolbarMenu.Body>
                <div className="p-2 space-y-3">
                    <LemonButton type="primary" fullWidth onClick={() => newTour()}>
                        Create new tour
                    </LemonButton>

                    {toursLoading ? (
                        <div className="flex justify-center py-4">
                            <Spinner />
                        </div>
                    ) : tours.length > 0 ? (
                        <div className="space-y-1">
                            <div className="text-xs font-medium text-muted uppercase">Existing tours</div>
                            {tours
                                .filter((tour) => !tour.archived && tour.content?.type !== 'announcement')
                                .map((tour) => (
                                    <LemonButton
                                        key={tour.id}
                                        fullWidth
                                        type="secondary"
                                        size="small"
                                        onClick={() => selectTour(tour.id)}
                                    >
                                        <span className="truncate">{tour.name}</span>
                                        <span className="text-muted text-xs ml-auto">
                                            {tour.content?.steps?.length ?? 0} steps
                                        </span>
                                    </LemonButton>
                                ))}
                        </div>
                    ) : (
                        <p className="text-muted text-sm text-center py-2">No tours yet</p>
                    )}
                </div>
            </ToolbarMenu.Body>
        </ToolbarMenu>
    )
}