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.

921 B
Raw Blame
import { IconPlusSmall } from '@posthog/icons'

import { ButtonPrimitive, ButtonPrimitiveProps } from 'lib/ui/Button/ButtonPrimitives'

import { SceneDataAttrKeyProps } from '../utils'

type SceneAddToDashboardButtonProps = SceneDataAttrKeyProps &
    Pick<ButtonPrimitiveProps, 'disabledReasons'> & {
        dashboard?: {
            onClick?: () => void
        }
    }

export function SceneAddToDashboardButton({
    dataAttrKey,
    dashboard,
    disabledReasons,
}: SceneAddToDashboardButtonProps): JSX.Element | null {
    if (!dashboard) {
        return null
    }

    return (
        <ButtonPrimitive
            menuItem
            onClick={() => {
                dashboard.onClick?.()
            }}
            data-attr={`${dataAttrKey}-add-to-dashboard-button`}
            disabledReasons={disabledReasons}
        >
            <IconPlusSmall /> Add to dashboard
        </ButtonPrimitive>
    )
}