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.

1.9 KB
Raw Blame
import { useValues } from 'kea'

import { LemonBanner, Link } from '@posthog/lemon-ui'

import { materializationJobsLogic } from 'scenes/data-warehouse/saved_queries/materializationJobsLogic'
import { urls } from 'scenes/urls'

import { DataQualityChecksPanel } from 'products/data_quality/frontend/DataQualityChecksPanel'
import { dataQualityGateLogic } from 'products/data_quality/frontend/dataQualityGateLogic'

import { nodeDetailSceneLogic } from './nodeDetailSceneLogic'

function GateNotice(): JSX.Element | null {
    const { gateConfig, gateReadable } = useValues(dataQualityGateLogic)

    if (!gateReadable || !gateConfig) {
        return null
    }

    return (
        <LemonBanner type="info">
            {gateConfig.gate_materialization_on_checks
                ? 'This project blocks materialization on failing error-severity checks.'
                : 'This project materializes this view even when an error-severity check fails.'}{' '}
            <Link to={urls.settings('environment-data-quality')} data-attr="node-detail-tests-gate-settings">
                Change this in data quality settings
            </Link>
        </LemonBanner>
    )
}

export function NodeDetailViewTests({ id, subjectId }: { id: string; subjectId: string }): JSX.Element {
    const { savedQuery } = useValues(nodeDetailSceneLogic({ id }))
    const { lastSuccessfulSyncAt } = useValues(materializationJobsLogic({ viewId: subjectId }))

    return (
        <div className="flex flex-col gap-4">
            <DataQualityChecksPanel
                subjectType="view"
                subjectId={subjectId}
                columns={savedQuery?.columns ?? []}
                dataLastSyncedAt={savedQuery?.is_materialized ? lastSuccessfulSyncAt : undefined}
                hideTitle
                notice={savedQuery?.is_materialized ? <GateNotice /> : undefined}
            />
        </div>
    )
}