0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-11-21 13:39:22 +01:00

Add paths to logics (#6945)

* add typegen with path writing support

* toolbar paths

* scene paths

* all other paths

* revert deleted comments

* add two missing paths
This commit is contained in:
Marius Andra 2021-11-09 08:59:21 +01:00 committed by GitHub
parent b11c4421ee
commit 26a3b06445
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
106 changed files with 139 additions and 15 deletions

3
.kearc
View File

@ -1,6 +1,7 @@
{
"tsConfigPath": "./tsconfig.json",
"rootPath": "./frontend/src",
"typesPath": "./frontend/src"
"typesPath": "./frontend/src",
"writePaths": true
}

View File

@ -4,6 +4,7 @@ import { featureFlagLogic } from '../../lib/logic/featureFlagLogic'
import { lemonadeLogicType } from './lemonadeLogicType'
export const lemonadeLogic = kea<lemonadeLogicType>({
path: ['layout', 'lemonade', 'lemonadeLogic'],
connect: {
values: [featureFlagLogic, ['featureFlags']],
},

View File

@ -19,6 +19,7 @@ type WarningType =
| null
export const navigationLogic = kea<navigationLogicType<WarningType>>({
path: ['layout', 'navigation', 'navigationLogic'],
actions: {
setMenuCollapsed: (collapsed: boolean) => ({ collapsed }),
collapseMenu: () => {},

View File

@ -13,6 +13,7 @@ interface AnnotationsLogicProps {
}
export const annotationsLogic = kea<annotationsLogicType<AnnotationsLogicProps>>({
path: (key) => ['lib', 'components', 'Annotations', 'annotationsLogic', key],
props: {} as AnnotationsLogicProps,
key: (props) => (props.pageKey ? `${props.pageKey}_annotations` : 'annotations_default'),
connect: {

View File

@ -10,6 +10,7 @@ import { teamLogic } from 'scenes/teamLogic'
const defaultValue = 'https://'
export const appUrlsLogic = kea<appUrlsLogicType>({
path: ['lib', 'components', 'AppEditorLink', 'appUrlsLogic'],
connect: {
values: [teamLogic, ['currentTeam', 'currentTeamId']],
},

View File

@ -11,6 +11,7 @@ interface IBackTo {
}
const backToLogic = kea<backToLogicType<IBackTo>>({
path: ['lib', 'components', 'BackTo'],
actions: {
setBackTo: (payload) => ({ payload }),
},

View File

@ -9,6 +9,7 @@ function isFunnelVizType(filter: FunnelVizType | ChartDisplayType): filter is Fu
}
export const chartFilterLogic = kea<chartFilterLogicType>({
path: ['lib', 'components', 'ChartFilter', 'chartFilterLogic'],
actions: () => ({
setChartFilter: (filter: ChartDisplayType | FunnelVizType) => ({ filter }),
}),

View File

@ -121,6 +121,7 @@ export const commandPaletteLogic = kea<
RegExpCommandPairs
>
>({
path: ['lib', 'components', 'CommandPalette', 'commandPaletteLogic'],
connect: {
actions: [personalAPIKeysLogic, ['createKey']],
values: [teamLogic, ['currentTeam'], userLogic, ['user']],

View File

@ -5,6 +5,7 @@ import { InsightType, ViewType } from '~/types'
import { compareFilterLogicType } from './compareFilterLogicType'
export const compareFilterLogic = kea<compareFilterLogicType>({
path: ['lib', 'components', 'CompareFilter', 'compareFilterLogic'],
actions: () => ({
setCompare: (compare: boolean) => ({ compare }),
setDisabled: (disabled: boolean) => ({ disabled }),

View File

@ -14,6 +14,7 @@ import clsx from 'clsx'
const HELP_UTM_TAGS = '?utm_medium=in-product&utm_campaign=help-button-top'
export const helpButtonLogic = kea<helpButtonLogicType>({
path: ['lib', 'components', 'HelpButton', 'HelpButton'],
connect: {
actions: [eventUsageLogic, ['reportHelpButtonViewed']],
},

View File

@ -5,6 +5,7 @@ import { intervalFilterLogicType } from './intervalFilterLogicType'
import { IntervalKeyType } from 'lib/components/IntervalFilter/intervals'
export const intervalFilterLogic = kea<intervalFilterLogicType>({
path: ['lib', 'components', 'IntervalFilter', 'intervalFilterLogic'],
actions: () => ({
setIntervalFilter: (filter: IntervalKeyType) => ({ filter }),
setDateFrom: (dateFrom: string) => ({ dateFrom }),

View File

@ -6,6 +6,7 @@ import { personalAPIKeysLogicType } from './personalAPIKeysLogicType'
import { copyToClipboard } from 'lib/utils'
export const personalAPIKeysLogic = kea<personalAPIKeysLogicType>({
path: ['lib', 'components', 'PersonalAPIKeys', 'personalAPIKeysLogic'],
loaders: ({ values }) => ({
keys: [
[] as PersonalAPIKeyType[],

View File

@ -6,6 +6,7 @@ import { taxonomicPropertyFilterLogicType } from './taxonomicPropertyFilterLogic
import { cohortsModel } from '~/models/cohortsModel'
export const taxonomicPropertyFilterLogic = kea<taxonomicPropertyFilterLogicType>({
path: (key) => ['lib', 'components', 'PropertyFilters', 'components', 'taxonomicPropertyFilterLogic', key],
props: {} as TaxonomicPropertyFilterLogicProps,
key: (props) => `${props.pageKey}-${props.filterIndex}`,

View File

@ -8,6 +8,7 @@ import { isValidPropertyFilter, parseProperties } from 'lib/components/PropertyF
import { PropertyFilterLogicProps } from 'lib/components/PropertyFilters/types'
export const propertyFilterLogic = kea<propertyFilterLogicType>({
path: (key) => ['lib', 'components', 'PropertyFilters', 'propertyFilterLogic', key],
props: {} as PropertyFilterLogicProps,
key: (props) => props.pageKey,

View File

@ -2,6 +2,7 @@ import { kea } from 'kea'
import { propertySelectLogicType } from './propertyNamesSelectLogicType'
export const propertySelectLogic = kea<propertySelectLogicType>({
path: (key) => ['lib', 'components', 'PropertyNamesSelect', 'propertyNamesSelectLogic', key],
props: {
propertySelectLogicKey: '' as string,

View File

@ -19,6 +19,7 @@ const filterColumns = (columnFilter: string, columns: string[]): string[] =>
: columns
export const columnConfiguratorLogic = kea<columnConfiguratorLogicType<ColumnConfiguratorLogicProps>>({
path: ['lib', 'components', 'ResizableTable', 'columnConfiguratorLogic'],
props: { availableColumns: [], selectedColumns: [] } as ColumnConfiguratorLogicProps,
actions: {
selectColumn: (column: string) => ({ column }),

View File

@ -4,6 +4,7 @@ import { router } from 'kea-router'
import { ColumnChoice } from '~/types'
export const tableConfigLogic = kea<tableConfigLogicType>({
path: ['lib', 'components', 'ResizableTable', 'tableConfigLogic'],
actions: {
showModal: true,
hideModal: false,

View File

@ -6,6 +6,7 @@ import { eventUsageLogic } from 'lib/utils/eventUsageLogic'
import { saveToDashboardModalLogicType } from './saveToDashboardModalLogicType'
export const saveToDashboardModalLogic = kea<saveToDashboardModalLogicType>({
path: (key) => ['lib', 'components', 'SaveToDashboard', 'saveToDashboardModalLogic', key],
props: {} as {
id?: number
fromDashboard?: number

View File

@ -33,6 +33,7 @@ const apiCache: Record<string, EventDefinitionStorage> = {}
const apiCacheTimers: Record<string, number> = {}
export const infiniteListLogic = kea<infiniteListLogicType>({
path: (key) => ['lib', 'components', 'TaxonomicFilter', 'infiniteListLogic', key],
props: {} as InfiniteListLogicProps,
key: (props) => `${props.taxonomicFilterLogicKey}-${props.listGroupType}`,

View File

@ -18,6 +18,7 @@ import { groupsModel } from '~/models/groupsModel'
import { groupPropertiesModel } from '~/models/groupPropertiesModel'
export const taxonomicFilterLogic = kea<taxonomicFilterLogicType>({
path: (key) => ['lib', 'components', 'TaxonomicFilter', 'taxonomicFilterLogic', key],
props: {} as TaxonomicFilterLogicProps,
key: (props) => `${props.taxonomicFilterLogicKey}`,
connect: { values: [teamLogic, ['currentTeamId'], groupsModel, ['groupTypes']] },

View File

@ -2,6 +2,7 @@ import { kea } from 'kea'
import { visibilitySensorLogicType } from './visibilitySensorLogicType'
export const visibilitySensorLogic = kea<visibilitySensorLogicType>({
path: (key) => ['lib', 'components', 'VisibilitySensor', 'visibilitySensorLogic', key],
props: {} as {
id: string
offset?: number

View File

@ -24,6 +24,7 @@ interface NPSPayload {
}
const npsLogic = kea<npsLogicType<NPSPayload, Step>>({
path: ['lib', 'experimental', 'NPSPrompt'],
selectors: {
featureFlagEnabled: [
() => [featureFlagLogic.selectors.featureFlags],

View File

@ -12,6 +12,7 @@ import { Modal, Input, Form } from 'antd'
// actions:
// - prompt({ title, placeholder, value, error, success, failure })
export const prompt = kea({
path: (key) => ['lib', 'logic', 'prompt', key],
key: (props) => props.key,
actions: () => ({

View File

@ -37,6 +37,7 @@ export const searchItems = (sources: SelectedItem[], search: string): SelectedIt
}
export const selectBoxLogic = kea<selectBoxLogicType>({
path: ['lib', 'logic', 'selectBoxLogic'],
props: {} as {
items: SelectBoxItem[]
updateFilter: (type: any, id: string | number, name: string) => void

View File

@ -146,6 +146,7 @@ function sanitizeFilterParams(filters: Partial<FilterType>): Record<string, any>
export const eventUsageLogic = kea<
eventUsageLogicType<DashboardEventSource, GraphSeriesAddedSource, RecordingWatchedSource>
>({
path: ['lib', 'utils', 'eventUsageLogic'],
connect: () => [preflightLogic],
actions: {
reportAnnotationViewed: (annotations: AnnotationType[] | null) => ({ annotations }),

View File

@ -8,6 +8,7 @@ interface ActionsModelProps {
}
export const actionsModel = kea<actionsModelType<ActionsModelProps>>({
path: ['models', 'actionsModel'],
props: {} as ActionsModelProps,
loaders: ({ props }) => ({
actions: {

View File

@ -8,6 +8,7 @@ import { AnnotationScope, AnnotationType } from '~/types'
import { teamLogic } from '../scenes/teamLogic'
export const annotationsModel = kea<annotationsModelType>({
path: ['models', 'annotationsModel'],
actions: {
createGlobalAnnotation: (content: string, date_marker: string, dashboard_item?: number) => ({
content,

View File

@ -6,6 +6,7 @@ import { CohortType } from '~/types'
const POLL_TIMEOUT = 5000
export const cohortsModel = kea<cohortsModelType>({
path: ['models', 'cohortsModel'],
actions: () => ({
setPollTimeout: (pollTimeout: number | null) => ({ pollTimeout }),
updateCohort: (cohort: CohortType) => ({ cohort }),

View File

@ -11,6 +11,7 @@ import { urls } from 'scenes/urls'
import { teamLogic } from '../scenes/teamLogic'
export const dashboardItemsModel = kea<dashboardItemsModelType>({
path: ['models', 'dashboardItemsModel'],
actions: () => ({
renameDashboardItem: (item: DashboardItemType) => ({ item }),
renameDashboardItemSuccess: (item: DashboardItemType) => ({ item }),

View File

@ -17,6 +17,7 @@ interface EventsGroupedInterface {
}
export const eventDefinitionsModel = kea<eventDefinitionsModelType<EventDefinitionStorage, EventsGroupedInterface>>({
path: ['models', 'eventDefinitionsModel'],
actions: () => ({
updateDescription: (id: string, description: string | null, type: string) => ({ id, description, type }),
updateEventDefinition: (eventDefinition: EventDefinition) => ({ eventDefinition }),

View File

@ -19,6 +19,7 @@ const parseSavedFunnel = (result: Record<string, any>): SavedFunnel => {
}
export const funnelsModel = kea<funnelsModelType>({
path: ['models', 'funnelsModel'],
loaders: ({ values, actions }) => ({
funnels: {
__default: [] as SavedFunnel[],

View File

@ -6,6 +6,7 @@ import { teamLogic } from 'scenes/teamLogic'
import { groupsModel } from './groupsModel'
export const groupPropertiesModel = kea<groupPropertiesModelType>({
path: ['models', 'groupPropertiesModel'],
connect: {
values: [teamLogic, ['currentTeamId'], groupsModel, ['groupsEnabled']],
},

View File

@ -9,6 +9,7 @@ import { TaxonomicFilterGroupType } from 'lib/components/TaxonomicFilter/types'
import { preflightLogic } from 'scenes/PreflightCheck/logic'
export const groupsModel = kea<groupsModelType>({
path: ['models', 'groupsModel'],
connect: {
values: [
teamLogic,

View File

@ -11,6 +11,7 @@ import { modelsType } from './indexType'
/** "Models" are logics that are persistently mounted (start with app) */
export const models = kea<modelsType>({
path: ['models', 'index'],
connect: [
actionsModel,
annotationsModel,

View File

@ -4,6 +4,7 @@ import api from 'lib/api'
import { PersonProperty } from '~/types'
export const personPropertiesModel = kea<personPropertiesModelType>({
path: ['models', 'personPropertiesModel'],
loaders: {
personProperties: [
[] as Array<PersonProperty>,

View File

@ -16,6 +16,7 @@ interface PropertyDefinitionStorage {
export const propertyDefinitionsModel = kea<
propertyDefinitionsModelType<PropertyDefinitionStorage, PropertySelectOption>
>({
path: ['models', 'propertyDefinitionsModel'],
actions: () => ({
updatePropertyDefinition: (property: PropertyDefinition) => ({ property }),
}),

View File

@ -22,6 +22,7 @@ import { SideBar } from '../layout/lemonade/SideBar/SideBar'
import { appScenes } from 'scenes/appScenes'
export const appLogic = kea<appLogicType>({
path: ['scenes', 'App'],
actions: {
enableDelayedSpinner: true,
ignoreFeatureFlags: true,

View File

@ -8,6 +8,7 @@ import { getAppContext } from 'lib/utils/getAppContext'
type PreflightMode = 'experimentation' | 'live'
export const preflightLogic = kea<preflightLogicType<PreflightMode>>({
path: ['scenes', 'PreflightCheck', 'preflightLogic'],
loaders: {
preflight: [
null as PreflightStatus | null,

View File

@ -18,6 +18,7 @@ interface ActionLogicProps {
}
const actionLogic = kea<actionLogicType<ActionLogicProps>>({
path: (key) => ['scenes', 'actions', 'actionLogic', key],
props: {} as ActionLogicProps,
key: (props) => props.id || 'new',
actions: () => ({

View File

@ -17,6 +17,7 @@ export interface ActionEditLogicProps {
}
export const actionEditLogic = kea<actionEditLogicType<ActionEditLogicProps, ActionEditType>>({
path: (key) => ['scenes', 'actions', 'actionEditLogic', key],
props: {} as ActionEditLogicProps,
key: (props) => props.id || 'new',
actions: () => ({

View File

@ -7,6 +7,7 @@ import { AnnotationType } from '~/types'
import { teamLogic } from '../teamLogic'
export const annotationsTableLogic = kea<annotationsTableLogicType>({
path: ['scenes', 'annotations', 'logic'],
loaders: ({ actions }) => ({
annotations: {
__default: [],

View File

@ -22,6 +22,7 @@ interface AcceptInvitePayloadInterface {
}
export const inviteSignupLogic = kea<inviteSignupLogicType<AcceptInvitePayloadInterface, ErrorInterface>>({
path: ['scenes', 'authentication', 'inviteSignupLogic'],
actions: {
setError: (payload: ErrorInterface) => ({ payload }),
},

View File

@ -14,6 +14,7 @@ export function afterLoginRedirect(): string {
}
export const loginLogic = kea<loginLogicType<AuthenticateResponseType>>({
path: ['scenes', 'authentication', 'loginLogic'],
loaders: {
authenticateResponse: [
null as AuthenticateResponseType | null,

View File

@ -20,6 +20,7 @@ interface ValidatedTokenResponseType extends ResponseType {
export const passwordResetLogic = kea<
passwordResetLogicType<ResetResponseType, ResponseType, ValidatedTokenResponseType>
>({
path: ['scenes', 'authentication', 'passwordResetLogic'],
loaders: ({ values }) => ({
resetResponse: [
null as ResetResponseType | null,

View File

@ -11,6 +11,7 @@ interface AccountResponse {
}
export const signupLogic = kea<signupLogicType<AccountResponse>>({
path: ['scenes', 'authentication', 'signupLogic'],
actions: {
setInitialEmail: (email: string) => ({ email }),
setFormSubmitted: (submitted: boolean) => ({ submitted }),

View File

@ -16,6 +16,7 @@ export enum BillingAlertType {
}
export const billingLogic = kea<billingLogicType<BillingAlertType>>({
path: ['scenes', 'billing', 'billingLogic'],
actions: {
registerInstrumentationProps: true,
},

View File

@ -10,6 +10,7 @@ export enum SubscriptionStatus {
}
export const billingSubscribedLogic = kea<billingSubscribedLogicType<SubscriptionStatus>>({
path: ['scenes', 'billing', 'billingSubscribedLogic'],
connect: {
actions: [sceneLogic, ['setScene']],
values: [billingLogic, ['billing']],

View File

@ -35,6 +35,7 @@ const NEW_COHORT: CohortType = {
}
const cohortsUrlLogic = kea<cohortsUrlLogicType>({
path: ['scenes', 'cohorts', 'cohortsUrlLogic'],
actions: {
setOpenCohort: (cohort: CohortType | null) => ({ cohort }),
},

View File

@ -41,6 +41,7 @@ export const cohortLogic = kea<cohortLogicType>({
cohort: CohortType
},
key: (props) => props.cohort.id || 'new',
path: (key) => ['scenes', 'cohorts', 'cohortLogic', key],
connect: [cohortsModel],
actions: () => ({

View File

@ -24,6 +24,7 @@ export interface DashboardLogicProps {
export const AUTO_REFRESH_INITIAL_INTERVAL_SECONDS = 300
export const dashboardLogic = kea<dashboardLogicType<DashboardLogicProps>>({
path: (key) => ['scenes', 'dashboard', 'dashboardLogic', key],
connect: {
values: [teamLogic, ['currentTeamId']],
logic: [dashboardsModel, dashboardItemsModel, eventUsageLogic],
@ -226,7 +227,14 @@ export const dashboardLogic = kea<dashboardLogicType<DashboardLogicProps>>({
setRefreshStatuses: (_, { ids, loading }) =>
Object.fromEntries(
ids.map((id) => [id, loading ? { loading: true } : { refreshed: true }])
) as Record<number, { loading?: boolean; refreshed?: boolean; error?: boolean }>,
) as Record<
number,
{
loading?: boolean
refreshed?: boolean
error?: boolean
}
>,
setRefreshError: (state, { id }) => ({
...state,
[id]: { error: true },

View File

@ -7,6 +7,7 @@ import { uniqueBy } from 'lib/utils'
import { urls } from 'scenes/urls'
export const dashboardsLogic = kea<dashboardsLogicType>({
path: ['scenes', 'dashboard', 'dashboardsLogic'],
actions: {
addNewDashboard: true,
setNewDashboardDrawer: (shown: boolean) => ({ shown }),

View File

@ -19,6 +19,7 @@ const tabUrls: Record<EventsTab, string> = {
}
const eventsTabsLogic = kea<eventsTabsLogicType<EventsTab>>({
path: ['scenes', 'events', 'eventsTabsLogic'],
actions: {
setTab: (tab: EventsTab) => ({ tab }),
},

View File

@ -10,6 +10,7 @@ import { propertyDefinitionsModel } from '~/models/propertyDefinitionsModel'
import { teamLogic } from '../../teamLogic'
export const definitionDrawerLogic = kea<definitionDrawerLogicType>({
path: ['scenes', 'events', 'definitions', 'definitionDrawerLogic'],
actions: () => ({
openDrawer: (type: string, id: string) => ({ type, id }),
setDrawerType: (type: string) => ({ type }),

View File

@ -53,6 +53,7 @@ export interface ApiError {
}
export const eventsTableLogic = kea<eventsTableLogicType<ApiError, EventsTableLogicProps, OnFetchEventsSuccess>>({
path: (key) => ['scenes', 'events', 'eventsTableLogic', key],
props: {} as EventsTableLogicProps,
// Set a unique key based on the fixed filters.
// This way if we move back/forward between /events and /person/ID, the logic is reloaded.
@ -64,7 +65,11 @@ export const eventsTableLogic = kea<eventsTableLogicType<ApiError, EventsTableLo
values: [teamLogic, ['currentTeamId']],
},
actions: {
setProperties: (properties: AnyPropertyFilter[] | AnyPropertyFilter): { properties: AnyPropertyFilter[] } => {
setProperties: (
properties: AnyPropertyFilter[] | AnyPropertyFilter
): {
properties: AnyPropertyFilter[]
} => {
// there seem to be multiple representations of "empty" properties
// the page does not work with some of those representations
// this action normalises them

View File

@ -38,6 +38,7 @@ const EMPTY_MULTIVARIATE_OPTIONS: MultivariateFlagOptions = {
}
export const featureFlagLogic = kea<featureFlagLogicType>({
path: ['scenes', 'feature-flags', 'featureFlagLogic'],
connect: {
values: [teamLogic, ['currentTeamId']],
},

View File

@ -5,6 +5,7 @@ import { FeatureFlagType } from '~/types'
import { teamLogic } from '../teamLogic'
export const featureFlagsLogic = kea<featureFlagsLogicType>({
path: ['scenes', 'feature-flags', 'featureFlagsLogic'],
connect: {
values: [teamLogic, ['currentTeamId']],
},

View File

@ -8,6 +8,7 @@ import { organizationLogic } from 'scenes/organizationLogic'
import { teamLogic } from 'scenes/teamLogic'
export const ingestionLogic = kea<ingestionLogicType>({
path: ['scenes', 'ingestion', 'ingestionLogic'],
connect: {
actions: [teamLogic, ['updateCurrentTeamSuccess']],
},

View File

@ -45,6 +45,7 @@ export interface EntityFilterProps {
export const entityFilterLogic = kea<entityFilterLogicType<BareEntity, EntityFilterProps, LocalFilter>>({
props: {} as EntityFilterProps,
key: (props) => props.typeKey,
path: (key) => ['scenes', 'insights', 'ActionFilter', 'entityFilterLogic', key],
connect: {
values: [actionsModel, ['actions']],
},

View File

@ -12,6 +12,7 @@ export interface RenameModalProps {
export const renameModalLogic = kea<renameModalLogicType<RenameModalProps>>({
props: {} as RenameModalProps,
key: (props) => props.typeKey,
path: (key) => ['scenes', 'insights', 'ActionFilter', 'renameModalLogic', key],
connect: {
actions: [entityFilterLogic, ['selectFilter']],
},

View File

@ -4,6 +4,7 @@ import { histogramLogicType } from './histogramLogicType'
import { FunnelLayout } from 'lib/constants'
export const histogramLogic = kea<histogramLogicType>({
path: ['scenes', 'insights', 'Histogram', 'histogramLogic'],
actions: {
setConfig: (config: HistogramConfig) => ({ config }),
},

View File

@ -10,6 +10,7 @@ interface UrlParams {
}
export const insightDateFilterLogic = kea<insightDateFilterLogicType>({
path: ['scenes', 'insights', 'InsightDateFilter', 'insightDateFilterLogic'],
actions: () => ({
setDates: (dateFrom: string | Dayjs | undefined, dateTo: string | Dayjs | undefined) => ({
dateFrom,

View File

@ -40,6 +40,7 @@ const updateInsightState = (
/* insightHistoryLogic - Handles all logic for saved insights and recent history */
export const insightHistoryLogic = kea<insightHistoryLogicType>({
path: ['scenes', 'insights', 'InsightHistoryPanel', 'insightHistoryLogic'],
connect: {
values: [teamLogic, ['currentTeamId']],
},

View File

@ -9,6 +9,7 @@ import { router } from 'kea-router'
const FUNNEL_COMMAND_SCOPE = 'funnels'
export const funnelCommandLogic = kea<funnelCommandLogicType>({
path: ['scenes', 'insights', 'InsightTabs', 'FunnelTab', 'funnelCommandLogic'],
connect: [commandPaletteLogic],
events: {
afterMount: () => {

View File

@ -4,6 +4,7 @@ import { insightsTableLogicType } from './insightsTableLogicType'
export type CalcColumnState = 'total' | 'average' | 'median'
export const insightsTableLogic = kea<insightsTableLogicType<CalcColumnState>>({
path: ['scenes', 'insights', 'InsightsTable', 'insightsTableLogic'],
props: {} as {
hasMathUniqueFilter: boolean
},

View File

@ -9,6 +9,7 @@ import { dateMapping } from 'lib/utils'
const INSIGHT_COMMAND_SCOPE = 'insights'
export const insightCommandLogic = kea<insightCommandLogicType>({
path: ['scenes', 'insights', 'insightCommandLogic'],
connect: [commandPaletteLogic, compareFilterLogic, insightDateFilterLogic],
events: () => ({
afterMount: () => {

View File

@ -48,6 +48,7 @@ export const defaultFilterTestAccounts = (): boolean => {
export const insightLogic = kea<insightLogicType>({
props: {} as InsightLogicProps,
key: keyForInsightLogicProps('new'),
path: (key) => ['scenes', 'insights', 'insightLogic', key],
connect: {
values: [teamLogic, ['currentTeamId']],

View File

@ -8,6 +8,7 @@ import { cleanFilters } from 'scenes/insights/utils/cleanFilters'
import { insightRouterLogicType } from './insightRouterLogicType'
export const insightRouterLogic = kea<insightRouterLogicType>({
path: ['scenes', 'insights', 'insightRouterLogic'],
actions: {
loadInsight: (id: string) => ({ id }),
setError: true,

View File

@ -6,6 +6,7 @@ import { APIErrorType, LicenseType } from '~/types'
import { preflightLogic } from '../../PreflightCheck/logic'
export const licenseLogic = kea<licenseLogicType>({
path: ['scenes', 'instance', 'Licenses', 'licenseLogic'],
connect: {
values: [preflightLogic, ['preflight']],
},

View File

@ -7,6 +7,7 @@ interface AccountResponse {
}
export const signupLogic = kea<signupLogicType<AccountResponse>>({
path: ['scenes', 'onboarding', 'signupLogic'],
loaders: () => ({
account: [
null as AccountResponse | null,

View File

@ -8,6 +8,7 @@ import { OrganizationType, TeamType } from '~/types'
import { onboardingSetupLogicType } from './onboardingSetupLogicType'
export const onboardingSetupLogic = kea<onboardingSetupLogicType>({
path: ['scenes', 'onboarding', 'onboardingSetupLogic'],
actions: {
switchToNonDemoProject: (dest) => ({ dest }),
setProjectModalShown: (shown) => ({ shown }),

View File

@ -7,6 +7,7 @@ import { router } from 'kea-router'
import { urls } from 'scenes/urls'
export const personalizationLogic = kea<personalizationLogicType>({
path: ['scenes', 'onboarding', 'personalizationLogic'],
connect: {
actions: [organizationLogic, ['updateOrganizationSuccess', 'loadCurrentOrganizationSuccess']],
},

View File

@ -17,6 +17,7 @@ interface InviteRowState {
const EMPTY_INVITE: InviteRowState = { target_email: '', first_name: '', isValid: true }
export const bulkInviteLogic = kea<bulkInviteLogicType<InviteRowState>>({
path: ['scenes', 'organization', 'Settings', 'bulkInviteLogic'],
actions: {
updateInviteAtIndex: (payload, index: number) => ({ payload, index }),
deleteInviteAtIndex: (index: number) => ({ index }),

View File

@ -9,6 +9,7 @@ import { eventUsageLogic } from 'lib/utils/eventUsageLogic'
import { preflightLogic } from 'scenes/PreflightCheck/logic'
export const invitesLogic = kea<invitesLogicType>({
path: ['scenes', 'organization', 'Settings', 'invitesLogic'],
loaders: ({ values }) => ({
invites: {
__default: [] as OrganizationInviteType[],

View File

@ -11,6 +11,7 @@ import { userLogic } from 'scenes/userLogic'
import { membershipLevelToName } from '../../../lib/utils/permissioning'
export const membersLogic = kea<membersLogicType>({
path: ['scenes', 'organization', 'Settings', 'membersLogic'],
actions: {
changeMemberAccessLevel: (member: OrganizationMemberType, level: OrganizationMembershipLevel) => ({
member,

View File

@ -12,6 +12,7 @@ export type OrganizationUpdatePayload = Partial<
>
export const organizationLogic = kea<organizationLogicType<OrganizationUpdatePayload>>({
path: ['scenes', 'organizationLogic'],
actions: {
deleteOrganization: (organization: OrganizationType) => ({ organization }),
deleteOrganizationSuccess: true,

View File

@ -35,6 +35,7 @@ interface PathNode {
}
export const pathsLogic = kea<pathsLogicType<PathNode>>({
path: (key) => ['scenes', 'paths', 'pathsLogic', key],
props: {} as InsightLogicProps,
key: keyForInsightLogicProps(DEFAULT_PATH_LOGIC_KEY),

View File

@ -21,6 +21,7 @@ type PersonIds = NonNullable<PersonType['id']>[]
export const mergeSplitPersonLogic = kea<mergeSplitPersonLogicType<ActivityType, PersonIds, SplitPersonLogicProps>>({
props: {} as SplitPersonLogicProps,
key: (props) => props.person.id,
path: (key) => ['scenes', 'persons', 'mergeSplitPersonLogic', key || 'new'],
connect: {
actions: [personsLogic, ['setListFilters', 'loadPersons', 'setPerson', 'setSplitMergeModalShown']],
values: [personsLogic, ['persons']],

View File

@ -19,6 +19,7 @@ interface PersonPaginatedResponse {
const FILTER_ALLOWLIST: string[] = ['is_identified', 'search', 'cohort']
export const personsLogic = kea<personsLogicType<PersonPaginatedResponse>>({
path: ['scenes', 'persons', 'personsLogic'],
connect: {
actions: [eventUsageLogic, ['reportPersonDetailViewed']],
values: [featureFlagLogic, ['featureFlags'], teamLogic, ['currentTeam']],

View File

@ -18,6 +18,7 @@ export const interfaceJobsLogic = kea<interfaceJobsLogicType>({
key: (props) => {
return `${props.pluginId}_${props.jobName}`
},
path: (key) => ['scenes', 'plugins', 'edit', 'interface-jobs', 'interfaceJobsLogic', key],
connect: {
actions: [pluginsLogic, ['showPluginLogs']],
},

View File

@ -14,6 +14,7 @@ export const LOGS_PORTION_LIMIT = 50
export const pluginLogsLogic = kea<pluginLogsLogicType<PluginLogsProps>>({
props: {} as PluginLogsProps,
key: ({ pluginConfigId }: PluginLogsProps) => pluginConfigId,
path: (key) => ['scenes', 'plugins', 'plugin', 'pluginLogsLogic', key],
connect: {
values: [teamLogic, ['currentTeamId']],
},

View File

@ -35,6 +35,7 @@ function capturePluginEvent(event: string, plugin: PluginType, type?: PluginInst
}
export const pluginsLogic = kea<pluginsLogicType<PluginForm, PluginSection>>({
path: ['scenes', 'plugins', 'pluginsLogic'],
actions: {
editPlugin: (id: number | null, pluginConfigChanges: Record<string, any> = {}) => ({ id, pluginConfigChanges }),
savePluginConfig: (pluginConfigChanges: Record<string, any>) => ({ pluginConfigChanges }),

View File

@ -21,6 +21,7 @@ import { teamLogic } from '../../teamLogic'
export const MINIMUM_IMPLICIT_ACCESS_LEVEL = OrganizationMembershipLevel.Admin
export const teamMembersLogic = kea<teamMembersLogicType>({
path: ['scenes', 'project', 'Settings', 'teamMembersLogic'],
actions: {
changeUserAccessLevel: (user: UserBasicType, newLevel: TeamMembershipLevel) => ({
user,

View File

@ -10,6 +10,7 @@ function adjustDiscordWebhook(webhookUrl: string): string {
}
export const webhookIntegrationLogic = kea<webhookIntegrationLogicType>({
path: ['scenes', 'project', 'Settings', 'webhookIntegrationLogic'],
loaders: ({ actions }) => ({
testedWebhook: [
null as string | null,

View File

@ -33,6 +33,7 @@ const DEFAULT_RETENTION_LOGIC_KEY = 'default_retention_key'
export const retentionTableLogic = kea<retentionTableLogicType>({
props: {} as InsightLogicProps,
key: keyForInsightLogicProps(DEFAULT_RETENTION_LOGIC_KEY),
path: (key) => ['scenes', 'retention', 'retentionTableLogic', key],
connect: (props: InsightLogicProps) => ({
values: [insightLogic(props), ['filters', 'insight', 'insightLoading'], actionsModel, ['actions']],
actions: [insightLogic(props), ['loadResultsSuccess']],

View File

@ -46,6 +46,7 @@ function cleanFilters(values: Partial<SavedInsightFilters>): SavedInsightFilters
}
export const savedInsightsLogic = kea<savedInsightsLogicType<InsightsResult, SavedInsightFilters>>({
path: ['scenes', 'saved-insights', 'savedInsightsLogic'],
connect: {
values: [teamLogic, ['currentTeamId']],
logic: [eventUsageLogic],
@ -218,7 +219,16 @@ export const savedInsightsLogic = kea<savedInsightsLogicType<InsightsResult, Sav
},
}),
actionToUrl: ({ values }) => {
const changeUrl = (): [string, Record<string, any>, Record<string, any>, { replace: true }] | void => {
const changeUrl = ():
| [
string,
Record<string, any>,
Record<string, any>,
{
replace: true
}
]
| void => {
const nextValues = cleanFilters(values.filters)
const urlValues = cleanFilters(router.values.searchParams)
if (!objectsEqual(nextValues, urlValues)) {

View File

@ -18,6 +18,7 @@ export interface DurationFilterProps {
const TIME_MULTIPLIERS = { seconds: 1, minutes: 60, hours: 3600 }
export const DurationFilterLogic = kea<DurationFilterLogicType<DurationFilterProps, TimeUnit>>({
path: (key) => ['scenes', 'session-recordings', 'DurationFilterLogic', key],
key: (props) => props.pageKey || 'global',
props: {} as DurationFilterProps,
actions: {

View File

@ -21,6 +21,7 @@ import {
import dayjs from 'dayjs'
export const seekbarLogic = kea<seekbarLogicType>({
path: ['scenes', 'session-recordings', 'player', 'seekbarLogic'],
connect: {
values: [
sessionRecordingPlayerLogic,

View File

@ -19,6 +19,7 @@ export function getOffsetTime(zeroOffsetTime: number, meta: playerMetaData): num
}
export const sessionRecordingPlayerLogic = kea<sessionRecordingPlayerLogicType>({
path: ['scenes', 'session-recordings', 'player', 'sessionRecordingPlayerLogic'],
connect: {
logic: [eventUsageLogic],
values: [

View File

@ -23,6 +23,7 @@ export const parseMetadataResponse = (metadata: Record<string, any>): Partial<Se
}
export const sessionRecordingLogic = kea<sessionRecordingLogicType>({
path: ['scenes', 'session-recordings', 'sessionRecordingLogic'],
connect: {
logic: [eventUsageLogic],
values: [teamLogic, ['currentTeamId']],

View File

@ -47,6 +47,7 @@ export const DEFAULT_ENTITY_FILTERS = {
}
export const sessionRecordingsTableLogic = kea<sessionRecordingsTableLogicType<PersonUUID, SessionRecordingId>>({
path: (key) => ['scenes', 'session-recordings', 'sessionRecordingsTableLogic', key],
key: (props) => props.personUUID || 'global',
props: {} as {
personUUID?: PersonUUID

View File

@ -34,6 +34,7 @@ const convertToNewSessionPlayerDataType = (legacyData: LEGACY_SessionPlayerData)
}
export const LEGACY_sessionsPlayLogic = kea<LEGACY_sessionsPlayLogicType>({
path: ['scenes', 'sessions', 'LEGACY_sessionsPlayLogic'],
connect: {
logic: [eventUsageLogic],
values: [

View File

@ -20,6 +20,7 @@ export interface SavedFilter {
type FilterPropertyType = SessionsPropertyFilter['type']
export const sessionsFiltersLogic = kea<sessionsFiltersLogicType<FilterPropertyType, FilterSelector, SavedFilter>>({
path: ['scenes', 'sessions', 'filters', 'sessionsFiltersLogic'],
actions: () => ({
openFilterSelect: (selector: FilterSelector) => ({ selector }),
closeFilterSelect: true,

View File

@ -28,10 +28,11 @@ interface Params {
}
export const sessionsTableLogic = kea<sessionsTableLogicType<SessionRecordingId>>({
key: (props) => props.personIds || 'global',
props: {} as {
personIds?: string[]
},
key: (props) => props.personIds || 'global',
path: (key) => ['scenes', 'sessions', 'sessionsTableLogic', Array.isArray(key) ? key.join(',') : key],
connect: {
values: [sessionsFiltersLogic, ['filters']],
actions: [sessionsFiltersLogic, ['setAllFilters', 'removeFilter']],

View File

@ -10,6 +10,7 @@ import { organizationLogic } from './organizationLogic'
import { getAppContext } from '../lib/utils/getAppContext'
export const teamLogic = kea<teamLogicType>({
path: ['scenes', 'teamLogic'],
actions: {
deleteTeam: (team: TeamType) => ({ team }),
deleteTeamSuccess: true,

View File

@ -88,6 +88,7 @@ export function parsePeopleParams(peopleParams: PeopleParamType, filters: Partia
}
export const personsModalLogic = kea<personsModalLogicType<PersonModalParams>>({
path: ['scenes', 'trends', 'personsModalLogic'],
actions: () => ({
setSearchTerm: (term: string) => ({ term }),
setCohortModalVisible: (visible: boolean) => ({ visible }),

View File

@ -10,6 +10,7 @@ import { isTrendsInsight, keyForInsightLogicProps } from 'scenes/insights/shared
export const trendsLogic = kea<trendsLogicType>({
props: {} as InsightLogicProps,
key: keyForInsightLogicProps('all_trends'),
path: (key) => ['scenes', 'trends', 'trendsLogic', key],
connect: (props: InsightLogicProps) => ({
values: [insightLogic(props), ['filters', 'insight', 'insightLoading']],

View File

@ -9,6 +9,7 @@ import { getAppContext } from 'lib/utils/getAppContext'
import { teamLogic } from './teamLogic'
export const userLogic = kea<userLogicType>({
path: ['scenes', 'userLogic'],
connect: {
values: [teamLogic, ['currentTeam']],
},

View File

@ -6,6 +6,7 @@ import Fuse from 'fuse.js'
import { toolbarFetch } from '~/toolbar/utils'
export const actionsLogic = kea<actionsLogicType>({
path: ['toolbar', 'actions', 'actionsLogic'],
actions: {
setSearchTerm: (searchTerm: string) => ({ searchTerm }),
},

View File

@ -22,6 +22,7 @@ function newAction(element: HTMLElement | null, dataAttributes: string[] = []):
type ActionFormInstance = FormInstance<ActionForm>
export const actionsTabLogic = kea<actionsTabLogicType<ActionFormInstance>>({
path: ['toolbar', 'actions', 'actionsTabLogic'],
actions: {
setForm: (form: ActionFormInstance) => ({ form }),
selectAction: (id: number | null) => ({ id: id || null }),

View File

@ -16,6 +16,7 @@ type ActionElementMap = Map<HTMLElement, ActionElementWithMetadata[]>
type ElementMap = Map<HTMLElement, ElementWithMetadata>
export const elementsLogic = kea<elementsLogicType<ActionElementMap, ElementMap>>({
path: ['toolbar', 'elements', 'elementsLogic'],
actions: {
enableInspect: true,
disableInspect: true,

Some files were not shown because too many files have changed in this diff Show More