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.1 KB
Raw Blame
import { MakeLogicType, actions, kea, key, listeners, path, props, selectors } from 'kea'

import { AccessControlResourceType } from '~/types'

export type IngestionControlsLogicProps = {
    logicKey: string
    resourceType: AccessControlResourceType
    matchType: 'any' | 'all'
    onChangeMatchType: (matchType: 'any' | 'all') => void
}

// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface ingestionControlsLogicValues {
    logicKey: string
    matchType: 'all' | 'any'
    resourceType: AccessControlResourceType
}

// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface ingestionControlsLogicActions {
    onChangeMatchType: (matchType: 'all' | 'any') => {
        matchType: 'all' | 'any'
    }
}

// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface ingestionControlsLogicMeta {
    key: string
    __keaTypeGenInternalSelectorTypes: {
        logicKey: (logicKey: string) => string
        resourceType: (resourceType: AccessControlResourceType) => AccessControlResourceType
        matchType: (matchType: 'all' | 'any') => 'all' | 'any'
    }
}

export type ingestionControlsLogicType = MakeLogicType<
    ingestionControlsLogicValues,
    ingestionControlsLogicActions,
    IngestionControlsLogicProps,
    ingestionControlsLogicMeta
>

export const ingestionControlsLogic = kea<ingestionControlsLogicType>([
    props({} as IngestionControlsLogicProps),
    key((props) => props.logicKey),
    path((key) => ['lib', 'components', 'IngestionControls', 'ingestionControlsLogic', key]),
    actions({
        onChangeMatchType: (matchType: 'any' | 'all') => ({ matchType }),
    }),
    selectors({
        logicKey: [(_, p) => [p.logicKey], (logicKey: string) => logicKey],
        resourceType: [(_, p) => [p.resourceType], (resourceType: AccessControlResourceType) => resourceType],
        matchType: [(_, p) => [p.matchType], (matchType: 'all' | 'any') => matchType],
    }),
    listeners(({ props }) => ({
        onChangeMatchType: ({ matchType }) => {
            props.onChangeMatchType(matchType)
        },
    })),
])