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.

fix(frontend): remove fake-lazy GlobalModals require from entry bundle (#62923)

Paul D'Ambra1ee99f421839
diff --git a/frontend/src/layout/GlobalModals.tsx b/frontend/src/layout/GlobalModals.tsx
index 8d69a75161fe..0bd4d0f0fe4d 100644
--- a/frontend/src/layout/GlobalModals.tsx
+++ b/frontend/src/layout/GlobalModals.tsx
@@ -1,4 +1,4 @@
-import { actions, kea, path, reducers, useActions, useValues } from 'kea'
+import { useActions, useValues } from 'kea'
import { ItemSelectModal } from 'lib/components/FileSystem/ItemSelectModal/ItemSelectModal'
import { LinkToModal } from 'lib/components/FileSystem/LinkTo/LinkTo'
@@ -9,7 +9,6 @@ import { superpowersLogic } from 'lib/components/Superpowers/superpowersLogic'
import { TimeSensitiveAuthenticationModal } from 'lib/components/TimeSensitiveAuthentication/TimeSensitiveAuthentication'
import { GlobalCustomUnitModal } from 'lib/components/UnitPicker/GlobalCustomUnitModal'
import { UpgradeModal } from 'lib/components/UpgradeModal/UpgradeModal'
-import { bindModalToUrl } from 'lib/logic/bindModalToUrl'
import { TwoFactorSetupModal } from 'scenes/authentication/two-factor-setup/TwoFactorSetupModal'
import { PaymentEntryModal } from 'scenes/billing/PaymentEntryModal'
import { CreateOrganizationModal } from 'scenes/organization/CreateOrganizationModal'
@@ -25,43 +24,11 @@ import { promotedProductLogic } from '~/layout/panel-layout/ai-first/promotedPro
import { ComposeTicketModal } from 'products/conversations/frontend/components/ComposeTicket'
import { LogsViewerModal } from 'products/logs/frontend/components/LogsViewer/LogsViewerModal'
-import type { globalModalsLogicType } from './GlobalModalsType'
+import { globalModalsLogic } from './globalModalsLogic'
import { navigationLogic } from './navigation/navigationLogic'
import { ConfigureHomeModal } from './scenes/ConfigureHomeModal'
import { ConfigurePromotedProductModal } from './scenes/ConfigurePromotedProductModal'
-export const globalModalsLogic = kea<globalModalsLogicType>([
- path(['layout', 'navigation', 'globalModalsLogic']),
- actions({
- showCreateOrganizationModal: true,
- hideCreateOrganizationModal: true,
- showCreateProjectModal: true,
- hideCreateProjectModal: true,
- }),
- reducers({
- isCreateOrganizationModalShown: [
- false,
- {
- showCreateOrganizationModal: () => true,
- hideCreateOrganizationModal: () => false,
- },
- ],
- isCreateProjectModalShown: [
- false,
- {
- showCreateProjectModal: () => true,
- hideCreateProjectModal: () => false,
- },
- ],
- }),
- bindModalToUrl({
- urlKey: 'create-organization',
- openActionKey: 'showCreateOrganizationModal',
- closeActionKey: 'hideCreateOrganizationModal',
- isOpenKey: 'isCreateOrganizationModalShown',
- }),
-])
-
export function GlobalModals(): JSX.Element {
const { isCreateOrganizationModalShown, isCreateProjectModalShown } = useValues(globalModalsLogic)
const { hideCreateOrganizationModal, hideCreateProjectModal } = useActions(globalModalsLogic)
diff --git a/frontend/src/layout/globalModalsLogic.ts b/frontend/src/layout/globalModalsLogic.ts
new file mode 100644
index 000000000000..3f026a48b0d2
--- /dev/null
+++ b/frontend/src/layout/globalModalsLogic.ts
@@ -0,0 +1,37 @@
+import { actions, kea, path, reducers } from 'kea'
+
+import { bindModalToUrl } from 'lib/logic/bindModalToUrl'
+
+import type { globalModalsLogicType } from './globalModalsLogicType'
+
+export const globalModalsLogic = kea<globalModalsLogicType>([
+ path(['layout', 'navigation', 'globalModalsLogic']),
+ actions({
+ showCreateOrganizationModal: true,
+ hideCreateOrganizationModal: true,
+ showCreateProjectModal: true,
+ hideCreateProjectModal: true,
+ }),
+ reducers({
+ isCreateOrganizationModalShown: [
+ false,
+ {
+ showCreateOrganizationModal: () => true,
+ hideCreateOrganizationModal: () => false,
+ },
+ ],
+ isCreateProjectModalShown: [
+ false,
+ {
+ showCreateProjectModal: () => true,
+ hideCreateProjectModal: () => false,
+ },
+ ],
+ }),
+ bindModalToUrl({
+ urlKey: 'create-organization',
+ openActionKey: 'showCreateOrganizationModal',
+ closeActionKey: 'hideCreateOrganizationModal',
+ isOpenKey: 'isCreateOrganizationModalShown',
+ }),
+])
diff --git a/frontend/src/lib/components/Account/NewAccountMenu.tsx b/frontend/src/lib/components/Account/NewAccountMenu.tsx
index 237074a7a828..3f72b5fff391 100644
--- a/frontend/src/lib/components/Account/NewAccountMenu.tsx
+++ b/frontend/src/lib/components/Account/NewAccountMenu.tsx
@@ -30,7 +30,7 @@ import { isAuthenticatedTeam, teamLogic } from 'scenes/teamLogic'
import { urls } from 'scenes/urls'
import { userLogic } from 'scenes/userLogic'
-import { globalModalsLogic } from '~/layout/GlobalModals'
+import { globalModalsLogic } from '~/layout/globalModalsLogic'
import { AvailableFeature } from '~/types'
import { RenderKeybind } from '../AppShortcuts/AppShortcutMenu'
diff --git a/frontend/src/lib/components/Account/OrgCombobox.tsx b/frontend/src/lib/components/Account/OrgCombobox.tsx
index 263cdfb1b10d..f713e3e537fa 100644
--- a/frontend/src/lib/components/Account/OrgCombobox.tsx
+++ b/frontend/src/lib/components/Account/OrgCombobox.tsx
@@ -12,7 +12,7 @@ import { organizationLogic } from 'scenes/organizationLogic'
import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
import { userLogic } from 'scenes/userLogic'
-import { globalModalsLogic } from '~/layout/GlobalModals'
+import { globalModalsLogic } from '~/layout/globalModalsLogic'
import { AccessLevelIndicator } from '~/layout/navigation/AccessLevelIndicator'
import { AvailableFeature } from '~/types'
diff --git a/frontend/src/lib/components/Account/OrgSwitcher.tsx b/frontend/src/lib/components/Account/OrgSwitcher.tsx
index dacc715600a6..2d202afec89f 100644
--- a/frontend/src/lib/components/Account/OrgSwitcher.tsx
+++ b/frontend/src/lib/components/Account/OrgSwitcher.tsx
@@ -14,7 +14,7 @@ import { organizationLogic } from 'scenes/organizationLogic'
import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
import { userLogic } from 'scenes/userLogic'
-import { globalModalsLogic } from '~/layout/GlobalModals'
+import { globalModalsLogic } from '~/layout/globalModalsLogic'
import { KeyboardShortcut } from '~/layout/navigation-3000/components/KeyboardShortcut'
import { AccessLevelIndicator } from '~/layout/navigation/AccessLevelIndicator'
import { AvailableFeature, OrganizationBasicType } from '~/types'
diff --git a/frontend/src/lib/components/Account/ProjectCombobox.tsx b/frontend/src/lib/components/Account/ProjectCombobox.tsx
index 6d654d5ffdf6..0311e6cc6cab 100644
--- a/frontend/src/lib/components/Account/ProjectCombobox.tsx
+++ b/frontend/src/lib/components/Account/ProjectCombobox.tsx
@@ -15,7 +15,7 @@ import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
import { isAuthenticatedTeam, teamLogic } from 'scenes/teamLogic'
import { urls } from 'scenes/urls'
-import { globalModalsLogic } from '~/layout/GlobalModals'
+import { globalModalsLogic } from '~/layout/globalModalsLogic'
import { AvailableFeature } from '~/types'
import { pendingInvitesLogic } from './pendingInvitesLogic'
diff --git a/frontend/src/lib/components/Account/ProjectSwitcher.tsx b/frontend/src/lib/components/Account/ProjectSwitcher.tsx
index 1e5dc9c1e4ad..d8b4a3797209 100644
--- a/frontend/src/lib/components/Account/ProjectSwitcher.tsx
+++ b/frontend/src/lib/components/Account/ProjectSwitcher.tsx
@@ -15,7 +15,7 @@ import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
import { isAuthenticatedTeam, teamLogic } from 'scenes/teamLogic'
import { urls } from 'scenes/urls'
-import { globalModalsLogic } from '~/layout/GlobalModals'
+import { globalModalsLogic } from '~/layout/globalModalsLogic'
import { KeyboardShortcut } from '~/layout/navigation-3000/components/KeyboardShortcut'
import { AvailableFeature, TeamBasicType } from '~/types'
diff --git a/frontend/src/lib/components/TimeSensitiveAuthentication/modalInterruptionTrackingLogic.ts b/frontend/src/lib/components/TimeSensitiveAuthentication/modalInterruptionTrackingLogic.ts
index 3fab72dbaf00..416bd82e4ca9 100644
--- a/frontend/src/lib/components/TimeSensitiveAuthentication/modalInterruptionTrackingLogic.ts
+++ b/frontend/src/lib/components/TimeSensitiveAuthentication/modalInterruptionTrackingLogic.ts
@@ -1,5 +1,6 @@
import { actions, connect, kea, listeners, path, reducers } from 'kea'
+import { globalModalsLogic } from '~/layout/globalModalsLogic'
import { organizationLogic } from '~/scenes/organizationLogic'
import { projectLogic } from '~/scenes/projectLogic'
@@ -7,20 +8,10 @@ import type { modalInterruptionTrackingLogicType } from './modalInterruptionTrac
export const modalInterruptionTrackingLogic = kea<modalInterruptionTrackingLogicType>([
path(['lib', 'components', 'TimeSensitiveAuthentication', 'modalInterruptionTrackingLogic']),
- connect(() => {
- try {
- // Use lazy require to avoid circular dependencies
- const { globalModalsLogic } = require('~/layout/GlobalModals')
-
- return {
- values: [globalModalsLogic, ['isCreateOrganizationModalShown', 'isCreateProjectModalShown']],
- actions: [organizationLogic, ['createOrganization'], projectLogic, ['createProject']],
- }
- } catch {
- // Safe fallback for tests
- return {}
- }
- }),
+ connect(() => ({
+ values: [globalModalsLogic, ['isCreateOrganizationModalShown', 'isCreateProjectModalShown']],
+ actions: [organizationLogic, ['createOrganization'], projectLogic, ['createProject']],
+ })),
actions({
setInterruptedForm: (form: string | null) => ({ form }),
}),
@@ -34,13 +25,13 @@ export const modalInterruptionTrackingLogic = kea<modalInterruptionTrackingLogic
}),
listeners(({ actions, values }) => ({
createOrganization: () => {
- if ((values as any).isCreateOrganizationModalShown) {
+ if (values.isCreateOrganizationModalShown) {
actions.setInterruptedForm('create_organization_modal')
}
},
createProject: () => {
- if ((values as any).isCreateProjectModalShown) {
+ if (values.isCreateProjectModalShown) {
actions.setInterruptedForm('create_project_modal')
}
},