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(flags): show a restore banner on a deleted feature flag (#96282)

posthog[bot]45aa5d0f8a8d
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index 61a5fa654f05..e55985512585 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -9730,6 +9730,10 @@ snapshots:
hash: v1.k794b7964.1074de0d6b43c97997e4cf0805a72c6d6421d705c19302d513843b20fcd228a6.iLBmTqiDcsehqfv8-kOyDSMaUBDhMJzv8zv-BXpxmPQ
scenes-app-experiments-setup-context--setup-context-drawer-narrow--light:
hash: v1.k794b7964.cc999db118582bdb5f64351350f6013fc380f65ff7f029699b999ec6ec88d165.fgI_0tKTAlU-s75XAXeOKhCSc5GAiqMeTvCcgYcPFrg
+ scenes-app-feature-flags--deleted-feature-flag--dark:
+ hash: v1.k794b7964.3795bb1f396527c180bfcef4de823b5064fc13a2ed44cd4ef60abe7cb88002bb.bDHlqsOUbRivTPIRkkukSBdGNT9qfo4LPtuL5GSKvyI
+ scenes-app-feature-flags--deleted-feature-flag--light:
+ hash: v1.k794b7964.0e7e762946624e513cd91315999f4eec08f741351e5305537f752ca23f73d043.iZUHrQEikVJFEDf5HnL6ffOYuQZJr5lCturFKuLetiI
scenes-app-feature-flags--edit-encrypted-remote-config-feature-flag--dark:
hash: v1.k794b7964.8504bd833db23615979e665b2e02508a6a6d8650fe64ba2bd8ab16509e6b5f2c.Mr1CI-569yDB1Rd7c08A7B-_0GSnEHXA0wNvR22TNF4
scenes-app-feature-flags--edit-encrypted-remote-config-feature-flag--light:
diff --git a/frontend/src/lib/utils/deleteWithUndo.tsx b/frontend/src/lib/utils/deleteWithUndo.tsx
index 1c2c60eca91b..7fe011f77e90 100644
--- a/frontend/src/lib/utils/deleteWithUndo.tsx
+++ b/frontend/src/lib/utils/deleteWithUndo.tsx
@@ -13,6 +13,8 @@ export async function deleteWithUndo<T extends Record<string, any>>({
endpoint: string
object: T
idField?: keyof T
+ /** The name the toast shows. It defaults to `object.name`, which the request body also sends. */
+ label?: string
callback?: (undo: boolean, object: T) => void
}): Promise<void> {
try {
@@ -24,7 +26,7 @@ export async function deleteWithUndo<T extends Record<string, any>>({
props.callback?.(undo, props.object)
lemonToast[undo ? 'success' : 'info'](
<>
- <b>{props.object.name || <i>{props.object.derived_name || 'Unnamed'}</i>}</b> has been{' '}
+ <b>{props.label || props.object.name || <i>{props.object.derived_name || 'Unnamed'}</i>}</b> has been{' '}
{undo ? 'restored' : 'deleted'}
</>,
{
diff --git a/frontend/src/scenes/feature-flags/FeatureFlag.tsx b/frontend/src/scenes/feature-flags/FeatureFlag.tsx
index 4748b96250ce..4d8caf409618 100644
--- a/frontend/src/scenes/feature-flags/FeatureFlag.tsx
+++ b/frontend/src/scenes/feature-flags/FeatureFlag.tsx
@@ -136,6 +136,7 @@ export function FeatureFlag({ id }: FeatureFlagLogicProps): JSX.Element {
accessDeniedToFeatureFlag,
earlyAccessFeaturesList,
featureFlagActiveUpdateLoading,
+ featureFlagRestoreLoading,
dependentFlags,
} = useValues(featureFlagLogic)
const { featureFlags } = useValues(enabledFeaturesLogic)
@@ -408,8 +409,6 @@ export function FeatureFlag({ id }: FeatureFlagLogicProps): JSX.Element {
{({ disabledReason }) => (
<ButtonPrimitive
menuItem
- disabled={!!disabledReason || featureFlagActiveUpdateLoading}
- {...(disabledReason && { tooltip: disabledReason })}
data-attr={
featureFlag.archived ? 'unarchive-feature-flag' : 'archive-feature-flag'
}
@@ -422,9 +421,12 @@ export function FeatureFlag({ id }: FeatureFlagLogicProps): JSX.Element {
)
}
}}
+ // ButtonPrimitive ignores `disabled` when `disabledReasons` is set.
disabledReasons={{
+ ...(disabledReason ? { [disabledReason]: true } : {}),
"You have only 'View' access for this feature flag. To make changes, please contact the flag's creator.":
!featureFlag.can_edit,
+ 'Updating…': featureFlagActiveUpdateLoading,
}}
>
{featureFlag.archived ? <IconRewind /> : <IconArchive />}
@@ -441,8 +443,6 @@ export function FeatureFlag({ id }: FeatureFlagLogicProps): JSX.Element {
<ButtonPrimitive
menuItem
variant="danger"
- disabled={!!disabledReason}
- {...(disabledReason && { tooltip: disabledReason })}
data-attr={featureFlag.deleted ? 'restore-feature-flag' : 'delete-feature-flag'}
onClick={() => {
if (featureFlag.deleted) {
@@ -456,8 +456,10 @@ export function FeatureFlag({ id }: FeatureFlagLogicProps): JSX.Element {
}
}}
disabledReasons={{
+ ...(disabledReason ? { [disabledReason]: true } : {}),
"You have only 'View' access for this feature flag. To make changes, please contact the flag's creator.":
!featureFlag.can_edit,
+ 'Restoring…': featureFlagRestoreLoading,
}}
>
{featureFlag.deleted ? <IconRewind /> : <IconTrash />}
@@ -472,6 +474,26 @@ export function FeatureFlag({ id }: FeatureFlagLogicProps): JSX.Element {
<PendingChangeRequestBanner resourceType="feature_flag" resourceId={featureFlag.id} />
)}
+ {featureFlag.deleted && (
+ <LemonBanner
+ type="error"
+ action={
+ featureFlag.can_edit
+ ? {
+ children: 'Restore',
+ onClick: () => restoreFeatureFlag(featureFlag),
+ loading: featureFlagRestoreLoading,
+ 'data-attr': 'restore-feature-flag-banner',
+ }
+ : undefined
+ }
+ >
+ This feature flag is deleted. It's hidden from the flag list and can't be evaluated.{' '}
+ {featureFlag.can_edit
+ ? 'Restore it to use it again.'
+ : 'Ask someone with edit access to restore it.'}
+ </LemonBanner>
+ )}
{featureFlag.archived && (
<LemonBanner
type="warning"
@@ -544,7 +566,7 @@ export function FeatureFlag({ id }: FeatureFlagLogicProps): JSX.Element {
{({ disabledReason }) => (
<SceneMenuBarItem
variant="destructive"
- disabled={!!disabledReason}
+ disabled={!!disabledReason || featureFlagRestoreLoading}
data-attr={
featureFlag.deleted
? `${RESOURCE_TYPE}-menubar-restore`
@@ -722,7 +744,7 @@ function UsageTab({ featureFlag }: { featureFlag: FeatureFlagType }): JSX.Elemen
if (featureFlag.deleted) {
return (
<div data-attr="feature-flag-usage-deleted-banner">
- <LemonBanner type="error">This feature flag has been deleted.</LemonBanner>
+ <LemonBanner type="info">Usage data is not shown for a deleted feature flag.</LemonBanner>
</div>
)
}
diff --git a/frontend/src/scenes/feature-flags/FeatureFlags.stories.tsx b/frontend/src/scenes/feature-flags/FeatureFlags.stories.tsx
index 120d0612a8da..96d62edf04f8 100644
--- a/frontend/src/scenes/feature-flags/FeatureFlags.stories.tsx
+++ b/frontend/src/scenes/feature-flags/FeatureFlags.stories.tsx
@@ -12,6 +12,7 @@ import featureFlags from './__mocks__/feature_flags.json'
import { featureFlagLogic } from './featureFlagLogic'
const STALE_FLAG_ID = 1498
+const DELETED_FLAG_ID = 1526
const meta: Meta = {
component: App,
@@ -51,6 +52,9 @@ const meta: Meta = {
],
'/api/projects/:team_id/feature_flags/:flagId/': ({ params }) => {
const flag = featureFlags.results.find((r) => r.id === Number(params['flagId']))
+ if (flag?.id === DELETED_FLAG_ID) {
+ return [200, { ...flag, deleted: true, can_edit: true }]
+ }
if (flag?.id !== STALE_FLAG_ID) {
return [200, flag]
}
@@ -201,6 +205,12 @@ export const StaleFeatureFlagWithAiAssessment: Story = {
},
}
+export const DeletedFeatureFlag: Story = {
+ parameters: {
+ pageUrl: urls.featureFlag(DELETED_FLAG_ID),
+ },
+}
+
export const FeatureFlagNotFound: Story = {
parameters: {
pageUrl: urls.featureFlag(1111111111111),
diff --git a/frontend/src/scenes/feature-flags/FeatureFlags.tsx b/frontend/src/scenes/feature-flags/FeatureFlags.tsx
index 2bf3a35678b8..f5e9e42bba12 100644
--- a/frontend/src/scenes/feature-flags/FeatureFlags.tsx
+++ b/frontend/src/scenes/feature-flags/FeatureFlags.tsx
@@ -312,7 +312,8 @@ function FeatureFlagRowActions({ featureFlag }: { featureFlag: FeatureFlagType }
openFeatureFlagDeleteDialog(featureFlag, () => {
void deleteWithUndo({
endpoint: `projects/${currentProjectId}/feature_flags`,
- object: { name: featureFlag.key, id: featureFlag.id },
+ object: { id: featureFlag.id },
+ label: featureFlag.key,
callback: () => loadFeatureFlags(),
}).catch((e) => {
lemonToast.error(`Failed to delete feature flag: ${e.detail}`)
diff --git a/frontend/src/scenes/feature-flags/featureFlagLogic.test.ts b/frontend/src/scenes/feature-flags/featureFlagLogic.test.ts
index ea5733b5bf1d..3cb7f44e11b0 100644
--- a/frontend/src/scenes/feature-flags/featureFlagLogic.test.ts
+++ b/frontend/src/scenes/feature-flags/featureFlagLogic.test.ts
@@ -7,10 +7,13 @@ import {
MOCK_TEAM_ID,
} from 'lib/api.mock'
+import { render } from '@testing-library/react'
import { router } from 'kea-router'
import { expectLogic, partial } from 'kea-test-utils'
import posthog from 'posthog-js'
+import { lemonToast as sharedLemonToast } from '@posthog/lemon-ui'
+
import api from 'lib/api'
import { dayjs } from 'lib/dayjs'
import { LemonDialog } from 'lib/lemon-ui/LemonDialog'
@@ -21,6 +24,7 @@ import { teamLogic } from 'scenes/teamLogic'
import { urls } from 'scenes/urls'
import { resumeKeaLoadersErrors, silenceKeaLoadersErrors } from '~/initKea'
+import { deleteFromTree, refreshTreeItem } from '~/layout/panel-layout/ProjectTree/projectTreeLogic'
import { useMocks } from '~/mocks/jest'
import { initKeaTests } from '~/test/init'
import {
@@ -97,6 +101,12 @@ jest.mock('lib/lemon-ui/LemonToast/LemonToast', () => ({
},
}))
+jest.mock('~/layout/panel-layout/ProjectTree/projectTreeLogic', () => ({
+ ...jest.requireActual('~/layout/panel-layout/ProjectTree/projectTreeLogic'),
+ deleteFromTree: jest.fn(),
+ refreshTreeItem: jest.fn(),
+}))
+
const MOCK_FEATURE_FLAG = {
...NEW_FLAG,
id: 1,
@@ -2858,6 +2868,75 @@ describe('featureFlagLogic', () => {
})
})
+ describe('deleting and restoring', () => {
+ let updateSpy: jest.SpyInstance
+
+ beforeEach(() => {
+ updateSpy = jest.spyOn(api, 'update')
+ })
+
+ afterEach(() => {
+ updateSpy.mockRestore()
+ })
+
+ it('deletes the flag without overwriting its description, and Undo keeps it in the list', async () => {
+ updateSpy.mockResolvedValue({ ...MOCK_FEATURE_FLAG, deleted: true })
+ // deleteWithUndo imports its toast from @posthog/lemon-ui, which the LemonToast mock above does not reach.
+ const toastSpy = jest.spyOn(sharedLemonToast, 'info').mockReturnValue('toast-id')
+ const successToastSpy = jest.spyOn(sharedLemonToast, 'success').mockReturnValue('toast-id')
+ try {
+ await expectLogic(logic, () => logic.actions.deleteFeatureFlag(MOCK_FEATURE_FLAG))
+ .toDispatchActions(['deleteFlag'])
+ .toFinishAllListeners()
+
+ // A `name` in the body overwrites the flag's description.
+ expect(updateSpy.mock.calls[0][1]).toEqual({ id: MOCK_FEATURE_FLAG.id, deleted: true })
+ const [message, options] = toastSpy.mock.calls[0]
+ expect(render(message as JSX.Element).container.textContent).toBe(
+ `${MOCK_FEATURE_FLAG.key} has been deleted`
+ )
+
+ await expectLogic(logic, async () => {
+ await options?.button?.action()
+ }).toNotHaveDispatchedActions(['deleteFlag'])
+ } finally {
+ toastSpy.mockRestore()
+ successToastSpy.mockRestore()
+ }
+ })
+
+ it('puts the restored flag back in the files tree', async () => {
+ updateSpy.mockResolvedValue({ ...MOCK_FEATURE_FLAG, deleted: false })
+
+ await expectLogic(logic, () => logic.actions.restoreFeatureFlag(MOCK_FEATURE_FLAG))
+ .toDispatchActions(['restoreFeatureFlag'])
+ .toMatchValues({ featureFlagRestoreLoading: true })
+ .toDispatchActions(['restoreFeatureFlagSuccess'])
+ .toMatchValues({ featureFlagRestoreLoading: false })
+ .toFinishAllListeners()
+
+ // Refreshing alone keeps a stale entry beside the new one, and deleting alone drops the flag.
+ expect(deleteFromTree).toHaveBeenCalledWith('feature_flag', String(MOCK_FEATURE_FLAG.id))
+ expect(refreshTreeItem).toHaveBeenCalledWith('feature_flag', String(MOCK_FEATURE_FLAG.id))
+ expect(jest.mocked(deleteFromTree).mock.invocationCallOrder[0]).toBeLessThan(
+ jest.mocked(refreshTreeItem).mock.invocationCallOrder[0]
+ )
+ expect(updateSpy.mock.calls[0][1]).toEqual({ deleted: false })
+ expect(lemonToast.success).toHaveBeenCalledWith(`${MOCK_FEATURE_FLAG.key} has been restored`)
+ })
+
+ it('stops loading and leaves the tree alone when the restore fails', async () => {
+ updateSpy.mockRejectedValue(new Error('nope'))
+
+ await expectLogic(logic, () => logic.actions.restoreFeatureFlag(MOCK_FEATURE_FLAG))
+ .toFinishAllListeners()
+ .toMatchValues({ featureFlagRestoreLoading: false })
+
+ expect(refreshTreeItem).not.toHaveBeenCalled()
+ expect(lemonToast.error).toHaveBeenCalled()
+ })
+ })
+
describe('updateFeatureFlagArchived archive telemetry', () => {
// One test here rejects the archive request on purpose; kea-loaders would log the failure
beforeEach(silenceKeaLoadersErrors)
diff --git a/frontend/src/scenes/feature-flags/featureFlagLogic.ts b/frontend/src/scenes/feature-flags/featureFlagLogic.ts
index fa600e24a658..e23530899279 100644
--- a/frontend/src/scenes/feature-flags/featureFlagLogic.ts
+++ b/frontend/src/scenes/feature-flags/featureFlagLogic.ts
@@ -954,6 +954,8 @@ export interface featureFlagLogicValues {
featureFlagMissing: boolean
featureFlagRefresh: FeatureFlagType | null
featureFlagRefreshLoading: boolean
+ featureFlagRestore: FeatureFlagType | null
+ featureFlagRestoreLoading: boolean
featureFlagTouched: boolean
featureFlagTouches: Record<string, boolean>
featureFlagValidationErrors: DeepPartialMap<
@@ -1490,8 +1492,20 @@ export interface featureFlagLogicActions {
resetScheduleFormExpanded: () => {
value: true
}
- restoreFeatureFlag: (featureFlag: Partial<FeatureFlagType>) => {
- featureFlag: Partial<FeatureFlagType>
+ restoreFeatureFlag: (featureFlag: Partial<FeatureFlagType>) => Partial<FeatureFlagType>
+ restoreFeatureFlagFailure: (
+ error: string,
+ errorObject?: any
+ ) => {
+ error: string
+ errorObject?: any
+ }
+ restoreFeatureFlagSuccess: (
+ featureFlagRestore: FeatureFlagType | null,
+ payload?: Partial<FeatureFlagType>
+ ) => {
+ featureFlagRestore: FeatureFlagType | null
+ payload?: Partial<FeatureFlagType>
}
resumeRecurringScheduledChange: (scheduledChangeId: number) => {
scheduledChangeId: number
@@ -2191,7 +2205,6 @@ export const featureFlagLogic = kea<featureFlagLogicType>([
setSelectedTab: (tab: FeatureFlagsTab) => ({ tab }),
setFeatureFlagMissing: true,
deleteFeatureFlag: (featureFlag: Partial<FeatureFlagType>) => ({ featureFlag }),
- restoreFeatureFlag: (featureFlag: Partial<FeatureFlagType>) => ({ featureFlag }),
setRemoteConfigEnabled: (enabled: boolean) => ({ enabled }),
resetEncryptedPayload: () => ({}),
setMultivariateEnabled: (enabled: boolean) => ({ enabled }),
@@ -3256,6 +3269,33 @@ export const featureFlagLogic = kea<featureFlagLogicType>([
},
},
],
+ featureFlagRestore: [
+ null as FeatureFlagType | null,
+ {
+ restoreFeatureFlag: async (featureFlag: Partial<FeatureFlagType>) => {
+ try {
+ // nosemgrep: prefer-codegen-api -- The generated partial update request type has no `deleted` field.
+ const restoredFlag = await api.update(
+ `api/projects/${values.currentProjectId}/feature_flags/${featureFlag.id}`,
+ { deleted: false }
+ )
+ // Restore gives the flag a new tree entry. A delete from another tab or the API leaves the old entry in this tab's tree.
+ deleteFromTree('feature_flag', String(featureFlag.id))
+ refreshTreeItem('feature_flag', String(featureFlag.id))
+ actions.loadFeatureFlag()
+ // The flag is no longer deleted, so its real verdict may differ from the retained
+ // DELETED one. Refetch it so the banner reflects the restored flag.
+ actions.loadFeatureFlagStatus()
+ // A deleted flag that an experiment uses has a tombstoned key. The response carries the restored key.
+ lemonToast.success(`${restoredFlag.key} has been restored`)
+ return restoredFlag
+ } catch (error: any) {
+ lemonToast.error(error?.detail || "Couldn't restore this feature flag. Try again.")
+ return null
+ }
+ },
+ },
+ ],
// Silent background refresh used when the overview paints instantly from the list
// cache on mount. Has its own loading key so it never triggers the page skeleton,
// while reconciling the flag (notably `active`) with the server — otherwise a stale
@@ -4046,12 +4086,13 @@ export const featureFlagLogic = kea<featureFlagLogicType>([
deleteFeatureFlag: async ({ featureFlag }) => {
await deleteWithUndo({
endpoint: `projects/${values.currentProjectId}/feature_flags`,
- object: { name: featureFlag.key, id: featureFlag.id },
+ object: { id: featureFlag.id },
+ label: featureFlag.key,
callback: (undo) => {
- featureFlag.id && actions.deleteFlag(featureFlag.id)
if (undo) {
refreshTreeItem('feature_flag', String(featureFlag.id))
} else {
+ featureFlag.id && actions.deleteFlag(featureFlag.id)
deleteFromTree('feature_flag', String(featureFlag.id))
}
// Load latest change so a backwards navigation shows the flag as deleted
@@ -4060,24 +4101,6 @@ export const featureFlagLogic = kea<featureFlagLogicType>([
},
})
},
- restoreFeatureFlag: async ({ featureFlag }) => {
- await deleteWithUndo({
- endpoint: `projects/${values.currentProjectId}/feature_flags`,
- object: { name: featureFlag.key, id: featureFlag.id },
- undo: true,
- callback: (undo) => {
- if (undo) {
- deleteFromTree('feature_flag', String(featureFlag.id))
- } else {
- refreshTreeItem('feature_flag', String(featureFlag.id))
- }
- actions.loadFeatureFlag()
- // The flag is no longer deleted, so its real verdict may differ from the retained
- // DELETED one. Refetch it so the banner reflects the restored flag.
- actions.loadFeatureFlagStatus()
- },
- })
- },
setMultivariateEnabled: async ({ enabled }) => {
if (enabled) {
actions.setMultivariateOptions(EMPTY_MULTIVARIATE_OPTIONS)
diff --git a/products/feature_flags/frontend/emptyState/featureFlagsSetupLogic.test.ts b/products/feature_flags/frontend/emptyState/featureFlagsSetupLogic.test.ts
index 6d2d7d8112d0..46dcb830871b 100644
--- a/products/feature_flags/frontend/emptyState/featureFlagsSetupLogic.test.ts
+++ b/products/feature_flags/frontend/emptyState/featureFlagsSetupLogic.test.ts
@@ -1,6 +1,8 @@
+import { getContext } from 'kea'
import { expectLogic } from 'kea-test-utils'
import { productSetupStatusLogic } from 'lib/components/ProductEmptyState/productSetupStatusLogic'
+import { featureFlagsLogic } from 'scenes/feature-flags/featureFlagsLogic'
import { ProductKey } from '~/queries/schema/schema-general'
import { initKeaTests } from '~/test/init'
@@ -39,6 +41,38 @@ describe('featureFlagsSetupLogic', () => {
expect(productSetupStatusLogic({ productKey: ProductKey.FEATURE_FLAGS }).values.status).toBe(expected)
})
+ // Undo of a project's only deleted flag reloads the flag list without remounting the gate.
+ // Once a flag has been seen, a list reload must not send more count requests.
+ it.each([
+ [0, 'needs-setup', 4],
+ [1, 'has-data', 2],
+ ])(
+ 'on a flag list reload after mounting with %i live flags (%s), makes %i count requests and ends has-data',
+ async (liveAtMount, statusAtMount, countRequests) => {
+ let live = liveAtMount
+ mockFeatureFlagsList.mockImplementation((_projectId, params) =>
+ Promise.resolve({ count: params?.archived ? 0 : live, next: null, previous: null, results: [] })
+ )
+ const logic = featureFlagsSetupLogic()
+ logic.mount()
+ await expectLogic(logic).toFinishAllListeners()
+ expect(productSetupStatusLogic({ productKey: ProductKey.FEATURE_FLAGS }).values.status).toBe(statusAtMount)
+
+ live = 1
+ getContext().store.dispatch(
+ featureFlagsLogic.actionCreators.loadFeatureFlagsSuccess({
+ count: 1,
+ next: null,
+ previous: null,
+ results: [],
+ })
+ )
+ await expectLogic(logic).toFinishAllListeners()
+ expect(mockFeatureFlagsList).toHaveBeenCalledTimes(countRequests)
+ expect(productSetupStatusLogic({ productKey: ProductKey.FEATURE_FLAGS }).values.status).toBe('has-data')
+ }
+ )
+
it('fails open to unknown when the count query fails before any answer', async () => {
mockFeatureFlagsList.mockRejectedValue(new Error('network down'))
const logic = featureFlagsSetupLogic()
diff --git a/products/feature_flags/frontend/emptyState/featureFlagsSetupLogic.ts b/products/feature_flags/frontend/emptyState/featureFlagsSetupLogic.ts
index 3ba6c140551b..264368037551 100644
--- a/products/feature_flags/frontend/emptyState/featureFlagsSetupLogic.ts
+++ b/products/feature_flags/frontend/emptyState/featureFlagsSetupLogic.ts
@@ -3,6 +3,7 @@ import { loaders } from 'kea-loaders'
import { productSetupStatusLogic } from 'lib/components/ProductEmptyState/productSetupStatusLogic'
import type { ProductSetupStatus } from 'lib/components/ProductEmptyState/types'
+import { featureFlagsLogic } from 'scenes/feature-flags/featureFlagsLogic'
import { teamLogic } from 'scenes/teamLogic'
import { ProductKey } from '~/queries/schema/schema-general'
@@ -81,6 +82,13 @@ export const featureFlagsSetupLogic = kea<featureFlagsSetupLogicType>([
],
})),
listeners(({ actions, values }) => ({
+ // Undo of a deleted flag brings it back without remounting the gate, so no count runs on its own.
+ // The flag list reloads after Undo, and that reload is the signal to count again.
+ [featureFlagsLogic.actionTypes.loadFeatureFlagsSuccess]: () => {
+ if (values.setupStatus !== 'has-data') {
+ actions.loadFlagCount()
+ }
+ },
loadFlagCountSuccess: ({ flagCount }) => {
actions.setDetectedStatus(flagCount !== null && flagCount > 0 ? 'has-data' : 'needs-setup')
},