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.

3.1 KB
Raw Blame
import { useActions, useValues } from 'kea'
import { router } from 'kea-router'

import { IconX } from '@posthog/icons'
import { LemonBanner, LemonButton } from '@posthog/lemon-ui'

import { queryDatabaseLogic } from 'scenes/data-warehouse/editor/sidebar/queryDatabaseLogic'
import { teamLogic } from 'scenes/teamLogic'
import { urls } from 'scenes/urls'

import { ProductIntentContext, ProductKey } from '~/queries/schema/schema-general'

import { SourceIcon } from 'products/data_warehouse/frontend/shared/components/SourceIcon'

import { panelLayoutLogic } from '../panelLayoutLogic'

export const SyncMoreNotice = (): JSX.Element | null => {
    const { hasNonPosthogSources, syncMoreNoticeDismissed, databaseLoading } = useValues(queryDatabaseLogic)
    const { setSyncMoreNoticeDismissed } = useActions(queryDatabaseLogic)
    const { addProductIntent } = useActions(teamLogic)
    const { showLayoutPanel, clearActivePanelIdentifier } = useActions(panelLayoutLogic)

    if (hasNonPosthogSources || syncMoreNoticeDismissed || databaseLoading) {
        return null
    }

    return (
        <LemonBanner type="info" className="h-[265px] min-h-[auto] z-10">
            <div
                data-attr="sql-editor-source-empty-state"
                className="p-4 text-center flex flex-col justify-center items-center relative"
            >
                <LemonButton
                    type="tertiary"
                    size="small"
                    onClick={() => setSyncMoreNoticeDismissed(true)}
                    className="absolute top-0 right-0"
                    icon={<IconX />}
                />
                <div className="mb-4 flex justify-center gap-6">
                    <SourceIcon type="Postgres" size="small" disableTooltip={true} />
                    <SourceIcon type="Stripe" size="small" disableTooltip={true} />
                    <SourceIcon type="GoogleAds" size="small" disableTooltip={true} />
                </div>
                <h4 className="mb-2">No data warehouse sources connected</h4>
                {/* eslint-disable-next-line react/forbid-dom-props */}
                <p className="text-muted mb-4 text-xs px-2 break-words w" style={{ whiteSpace: 'normal' }}>
                    Import data from external sources like Postgres, Stripe, or other databases to enrich your
                    analytics.
                </p>
                <LemonButton
                    type="primary"
                    onClick={() => {
                        addProductIntent({
                            product_type: ProductKey.DATA_WAREHOUSE,
                            intent_context: ProductIntentContext.SQL_EDITOR_EMPTY_STATE,
                        })
                        showLayoutPanel(false)
                        clearActivePanelIdentifier()
                        router.actions.push(urls.dataWarehouseSourceNew())
                    }}
                    center
                    size="small"
                    id="data-warehouse-sql-editor-add-data-source"
                >
                    Add data source
                </LemonButton>
            </div>
        </LemonBanner>
    )
}