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.0 KB
Raw Blame
import { MakeLogicType, afterMount, connect, kea, path } from 'kea'

import { exportsLogic } from 'lib/components/ExportButton/exportsLogic'

import type { ExportedAssetType, ExporterFormat, SidePanelTab } from '../../../../../types'
import { sidePanelStateLogic } from '../../sidePanelStateLogic'

// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface sidePanelExportsLogicValues {
    assetFormat: ExporterFormat | null // exportsLogic
    exports: ExportedAssetType[] // exportsLogic
    exportsLoading: boolean // exportsLogic
    freshUndownloadedExports: ExportedAssetType[] // exportsLogic
}

// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface sidePanelExportsLogicActions {
    downloadExport: (exportedAsset: ExportedAssetType) => {
        exportedAsset: ExportedAssetType
    } // exportsLogic
    loadExports: () => {
        value: true
    } // exportsLogic
    removeFresh: (exportedAsset: ExportedAssetType) => {
        exportedAsset: ExportedAssetType
    } // exportsLogic
    setAssetFormat: (format: ExporterFormat | null) => {
        format: ExporterFormat | null
    } // exportsLogic
    openSidePanel: (
        tab: SidePanelTab,
        options?: string | undefined
    ) => {
        options: string | undefined
        tab: SidePanelTab
    } // sidePanelStateLogic
}

export type sidePanelExportsLogicType = MakeLogicType<sidePanelExportsLogicValues, sidePanelExportsLogicActions>

export const sidePanelExportsLogic = kea<sidePanelExportsLogicType>([
    path(['scenes', 'navigation', 'sidepanel', 'sidePanelExportsLogic']),
    connect(() => ({
        values: [exportsLogic, ['exports', 'freshUndownloadedExports', 'assetFormat', 'exportsLoading']],
        actions: [
            sidePanelStateLogic,
            ['openSidePanel'],
            exportsLogic,
            ['loadExports', 'removeFresh', 'downloadExport', 'setAssetFormat'],
        ],
    })),
    afterMount(({ actions }) => {
        actions.loadExports()
    }),
])