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.6 KB
Raw Blame
import { IconPauseFilled, IconXCircle } from '@posthog/icons'
import { Tooltip } from '@posthog/lemon-ui'

import type { DataWarehouseSavedQuerySummary } from 'scenes/data-warehouse/saved_queries/dataWarehouseViewsLogic'

import { servingSuspension, suspendedScheduleMessage } from './suspension'

export function MaterializationStatusIcon({ view }: { view: DataWarehouseSavedQuerySummary }): JSX.Element | null {
    if (!view.is_materialized) {
        return null
    }
    const suspension = servingSuspension(view.suspended)
    if (suspension) {
        return (
            <Tooltip
                title={
                    <div className="flex flex-col gap-1">
                        <div>{suspendedScheduleMessage('view')}</div>
                        <div className="opacity-75 line-clamp-4">{suspension.reason}</div>
                    </div>
                }
            >
                <IconPauseFilled className="shrink-0 text-warning" />
            </Tooltip>
        )
    }
    if (view.status === 'Failed') {
        return (
            <Tooltip
                title={
                    <div className="flex flex-col gap-1">
                        <div>
                            The last materialization run failed. Scheduled runs are suspended if it keeps failing.
                        </div>
                        {view.latest_error ? <div className="opacity-75 line-clamp-4">{view.latest_error}</div> : null}
                    </div>
                }
            >
                <IconXCircle className="shrink-0 text-danger" />
            </Tooltip>
        )
    }
    return null
}