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.

feat(early-access-features): waitlist count column and inline assignee editing (#76750)

Joe Martin9ca491abd6ff
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index 6ed820a629d9..0d72ac22cfb5 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -6003,9 +6003,9 @@ snapshots:
scenes-app-feature-flags-new-feature-flag-menu--default--light:
hash: v1.k794b7964.c58d12ddf9499563916bb71f41ff70dce9db471379ef2215c8b57a0ac88aa76c.jl03AgPo8iB46wC9k3xNkQwobb5SLJcSwYnOphJUt8Y
scenes-app-features--features-list--dark:
- hash: v1.k794b7964.2ff24ed72e9bf4edb6d09e52a3d8991eb066f76d1a3d0d4b51380991ee938de1.S_zLwHN-sBexiwsZTKzYUEUvxsgYXBBZr7-C2MI6yfs
+ hash: v1.k794b7964.1b1bbf79d9e0033065f8369f89f9b7abe8db7a7694c800718a664be79d6fb999.Zfs6DpPi2hNyE-n0iiT3GF9TR1lChLpRz9R_vxyhuAg
scenes-app-features--features-list--light:
- hash: v1.k794b7964.2674e373d1160fbbfdb9a19a9c58784d5844a82b63fc71d32a614036faecbe9d.q9GyBN3PQJc2iUmR8pSQyvrNDZEaNSoEN-3I0cUNDYk
+ hash: v1.k794b7964.7b36b974461d5ba35ed239b2042e95d3d694e0cd19c26bb536ea418a0597c8b7.1KBS0d3TygedJFATRHLHioFrBBMqD7EFnrejaF6FYJc
scenes-app-features--new-feature-flag--dark:
hash: v1.k794b7964.63525b4477e45f45dd5f6d3899ea40fbcddbe0740984e77ce85fdc30fda6889e.1ThZLV0EP8iSDYLCz1SRoPAAhA-vxBD8nY8Y-jL-2UA
scenes-app-features--new-feature-flag--light:
diff --git a/frontend/src/initKea.ts b/frontend/src/initKea.ts
index c8ac43565a8f..e705a67a0270 100644
--- a/frontend/src/initKea.ts
+++ b/frontend/src/initKea.ts
@@ -37,6 +37,7 @@ const ERROR_FILTER_ALLOW_LIST = [
'loadSimilarIssues', // Gracefully handled in the similar issues list
'resolveFingerprint', // Retried while the error finishes ingesting; the fingerprint scene surfaces its own state
'saveEarlyAccessFeature', // Field-level errors handled in earlyAccessFeatureLogic
+ 'loadWaitlistResponsesCount', // Soft-fails to a dash on the features list when survey access is missing
'loadExistingSubscription', // Background eligibility check for the dashboard subscribe nudge
'loadFreeTierSubscriptionCount', // Background free-tier limit check for the dashboard subscribe nudge
'sendNudgeNotification', // Background delivery request for the dashboard subscribe nudge
diff --git a/frontend/src/lib/api.ts b/frontend/src/lib/api.ts
index 32d088a40214..7a8d9c15ea79 100644
--- a/frontend/src/lib/api.ts
+++ b/frontend/src/lib/api.ts
@@ -5188,7 +5188,9 @@ const api = {
},
async update(
featureId: EarlyAccessFeatureType['id'],
- data: Pick<EarlyAccessFeatureType, 'name' | 'description' | 'stage' | 'documentation_url'> & {
+ data: Partial<
+ Pick<EarlyAccessFeatureType, 'name' | 'description' | 'stage' | 'documentation_url' | 'assignee'>
+ > & {
rollout_to_all?: boolean
}
): Promise<EarlyAccessFeatureType> {
diff --git a/products/early_access_features/backend/api.py b/products/early_access_features/backend/api.py
index 40ff60cee052..47cba007ce64 100644
--- a/products/early_access_features/backend/api.py
+++ b/products/early_access_features/backend/api.py
@@ -288,7 +288,9 @@ class EarlyAccessFeatureSerializer(UserAccessControlSerializerMixin, serializers
user_data = UserBasicSerializer(request.user).data if request.user else None
serialized_previous = MinimalEarlyAccessFeatureSerializer(instance).data
- if instance.stage != stage:
+ # A PATCH that omits stage (e.g. an inline assignee edit) leaves stage as None here; guard so
+ # it doesn't read as a move to a null stage and enqueue a spurious stage-change task.
+ if stage is not None and instance.stage != stage:
send_events_for_early_access_feature_stage_change.delay(str(instance.id), instance.stage, stage)
# The branches below each mutate the linked flag's enrollment filters, so they require
diff --git a/products/early_access_features/backend/test/test_early_access_feature.py b/products/early_access_features/backend/test/test_early_access_feature.py
index eda09bb7ece5..c9ae2e574859 100644
--- a/products/early_access_features/backend/test/test_early_access_feature.py
+++ b/products/early_access_features/backend/test/test_early_access_feature.py
@@ -1128,6 +1128,30 @@ class TestEarlyAccessFeature(APIBaseTest):
"beta",
)
+ @patch("posthog.tasks.early_access_feature.send_events_for_early_access_feature_stage_change.delay")
+ def test_send_events_for_early_access_feature_stage_change_skips_when_stage_omitted(self, mock_celery_task):
+ response = self.client.post(
+ f"/api/projects/{self.team.id}/early_access_feature/",
+ data={
+ "name": "CeleryTestFeature",
+ "description": "Test firing celery task",
+ "stage": EarlyAccessFeature.Stage.CONCEPT,
+ },
+ format="json",
+ )
+ feature_id = response.json()["id"]
+
+ # A PATCH that only changes the assignee omits stage; it must not read as a move to a null
+ # stage and enqueue a spurious stage-change task.
+ response = self.client.patch(
+ f"/api/projects/{self.team.id}/early_access_feature/{feature_id}",
+ data={"assignee": None},
+ format="json",
+ )
+
+ assert response.status_code == status.HTTP_200_OK, response.json()
+ mock_celery_task.assert_not_called()
+
def test_create_early_access_feature_in_specific_folder(self):
response = self.client.post(
f"/api/projects/{self.team.id}/early_access_feature/",
diff --git a/products/early_access_features/frontend/EarlyAccessFeatures.stories.tsx b/products/early_access_features/frontend/EarlyAccessFeatures.stories.tsx
index 41e3d5c4d681..b1a59ed8e8fd 100644
--- a/products/early_access_features/frontend/EarlyAccessFeatures.stories.tsx
+++ b/products/early_access_features/frontend/EarlyAccessFeatures.stories.tsx
@@ -53,8 +53,10 @@ const EARLY_ACCESS_FEATURE_RESULT = [
},
name: 'dddd',
description: 'dedd',
- stage: 'alpha',
+ stage: 'concept',
documentation_url: '',
+ payload: { survey_id: '0187c22c-06d9-0000-34fe-daa2e2afb504' },
+ assignee: { type: 'user', id: 1 },
created_at: '2023-04-27T10:04:37.977401Z',
created_by: {
id: 1,
@@ -125,20 +127,23 @@ const meta: Meta = {
decorators: [
mswDecorator({
get: {
- '/api/projects/:team_id/early-access-feature': {
+ '/api/projects/:team_id/early_access_feature': {
count: 2,
results: EARLY_ACCESS_FEATURE_RESULT as any[],
next: null,
previous: null,
},
- '/api/projects/:team_id/early-access-feature/not-found/': [
+ '/api/projects/:team_id/early_access_feature/not-found/': [
404,
{
detail: 'Not found.',
},
],
- '/api/projects/:team_id/early-access-feature/:flagId/':
+ '/api/projects/:team_id/early_access_feature/:flagId/':
EARLY_ACCESS_FEATURE_RESULT[0] as EarlyAccessFeatureType,
+ '/api/projects/:team_id/surveys/responses_count': {
+ '0187c22c-06d9-0000-34fe-daa2e2afb504': 5,
+ },
},
}),
],
diff --git a/products/early_access_features/frontend/EarlyAccessFeatures.tsx b/products/early_access_features/frontend/EarlyAccessFeatures.tsx
index 250664e6eaca..1789f13ea70b 100644
--- a/products/early_access_features/frontend/EarlyAccessFeatures.tsx
+++ b/products/early_access_features/frontend/EarlyAccessFeatures.tsx
@@ -1,7 +1,7 @@
import { useActions, useValues } from 'kea'
import { router } from 'kea-router'
-import { LemonButton, LemonInput, LemonTable, LemonTag } from '@posthog/lemon-ui'
+import { LemonButton, LemonInput, LemonTable, LemonTag, Link, Spinner, Tooltip } from '@posthog/lemon-ui'
import { ProductIntroduction } from 'lib/components/ProductIntroduction/ProductIntroduction'
import { Shortcut } from 'lib/components/Shortcuts/Shortcut'
@@ -19,9 +19,17 @@ import { SceneTitleSection } from '~/layout/scenes/components/SceneTitleSection'
import { ProductKey } from '~/queries/schema/schema-general'
import { AccessControlLevel, AccessControlResourceType, EarlyAccessFeatureType } from '~/types'
-import { AssigneeDisplay, AssigneeResolver } from 'products/error_tracking/frontend/components/Assignee/AssigneeDisplay'
+import {
+ AssigneeIconDisplay,
+ AssigneeLabelDisplay,
+ AssigneeResolver,
+} from 'products/error_tracking/frontend/components/Assignee/AssigneeDisplay'
+import { AssigneeSelect } from 'products/error_tracking/frontend/components/Assignee/AssigneeSelect'
-import { earlyAccessFeaturesLogic } from './earlyAccessFeaturesLogic'
+import { earlyAccessFeaturesLogic, waitlistSurveyId } from './earlyAccessFeaturesLogic'
+
+// Features with no waitlist survey sort below a real count of 0.
+const NO_WAITLIST_SORT_VALUE = -1
export const scene: SceneExport = {
component: EarlyAccessFeatures,
@@ -39,8 +47,15 @@ const STAGES_IN_ORDER: Record<EarlyAccessFeatureType['stage'], number> = {
}
export function EarlyAccessFeatures(): JSX.Element {
- const { filteredEarlyAccessFeatures, earlyAccessFeaturesLoading, searchTerm } = useValues(earlyAccessFeaturesLogic)
- const { setSearchTerm } = useActions(earlyAccessFeaturesLogic)
+ const {
+ filteredEarlyAccessFeatures,
+ earlyAccessFeaturesLoading,
+ searchTerm,
+ waitlistResponsesCount,
+ waitlistResponsesCountLoading,
+ waitlistResponsesCountFailed,
+ } = useValues(earlyAccessFeaturesLogic)
+ const { setSearchTerm, updateFeatureAssignee } = useActions(earlyAccessFeaturesLogic)
const shouldShowEmptyState = filteredEarlyAccessFeatures.length == 0 && !earlyAccessFeaturesLoading && !searchTerm
// Creating an early access feature requires editor access to the resource.
@@ -140,16 +155,92 @@ export function EarlyAccessFeatures(): JSX.Element {
},
sorter: (a, b) => STAGES_IN_ORDER[a.stage] - STAGES_IN_ORDER[b.stage],
},
+ {
+ title: 'Waitlist',
+ key: 'waitlist',
+ tooltip: 'People who signed up to the waitlist survey for this feature',
+ render(_, feature) {
+ const surveyId = waitlistSurveyId(feature)
+ if (surveyId === null) {
+ return <span className="text-secondary">–</span>
+ }
+ if (waitlistResponsesCountLoading) {
+ return <Spinner />
+ }
+ if (waitlistResponsesCountFailed) {
+ return (
+ <Tooltip title="Couldn't load waitlist signups">
+ <span className="text-secondary">–</span>
+ </Tooltip>
+ )
+ }
+ const count = waitlistResponsesCount[surveyId] ?? 0
+ return (
+ <Link
+ to={urls.survey(surveyId)}
+ aria-label={`${count} waitlist signups for ${feature.name}`}
+ >
+ {count}
+ </Link>
+ )
+ },
+ sorter: (a, b) => {
+ const getCount = (feature: EarlyAccessFeatureType): number => {
+ const surveyId = waitlistSurveyId(feature)
+ return surveyId !== null
+ ? (waitlistResponsesCount[surveyId] ?? 0)
+ : NO_WAITLIST_SORT_VALUE
+ }
+ return getCount(a) - getCount(b)
+ },
+ },
{
title: 'Assignee',
key: 'assignee',
- render(_, { assignee }) {
+ render(_, feature) {
+ const assigneeEditDisabledReason = getAccessControlDisabledReason(
+ AccessControlResourceType.EarlyAccessFeature,
+ AccessControlLevel.Editor,
+ feature.user_access_level
+ )
+ // AssigneeSelect opens its dropdown from a wrapper the disabled button
+ // can't gate, so viewers get a read-only display instead of a live trigger.
+ if (assigneeEditDisabledReason) {
+ return (
+ <AssigneeResolver assignee={feature.assignee ?? null}>
+ {({ assignee: resolvedAssignee }) => (
+ <Tooltip title={assigneeEditDisabledReason}>
+ <span className="flex items-center gap-1">
+ <AssigneeIconDisplay
+ assignee={resolvedAssignee}
+ size="small"
+ />
+ <AssigneeLabelDisplay
+ assignee={resolvedAssignee}
+ size="small"
+ />
+ </span>
+ </Tooltip>
+ )}
+ </AssigneeResolver>
+ )
+ }
return (
- <AssigneeResolver assignee={assignee ?? null}>
- {({ assignee: resolvedAssignee }) => (
- <AssigneeDisplay assignee={resolvedAssignee} size="small" />
+ <AssigneeSelect
+ assignee={feature.assignee ?? null}
+ onChange={(assignee) => updateFeatureAssignee(feature.id, assignee)}
+ >
+ {(displayAssignee) => (
+ <LemonButton
+ type="tertiary"
+ size="small"
+ data-attr="early-access-feature-list-assignee"
+ >
+ <AssigneeIconDisplay assignee={displayAssignee} size="small" />
+ <AssigneeLabelDisplay assignee={displayAssignee} size="small" />
+ </LemonButton>
)}
- </AssigneeResolver>
+ </AssigneeSelect>
)
},
},
diff --git a/products/early_access_features/frontend/earlyAccessFeaturesLogic.test.ts b/products/early_access_features/frontend/earlyAccessFeaturesLogic.test.ts
new file mode 100644
index 000000000000..f4a11766809c
--- /dev/null
+++ b/products/early_access_features/frontend/earlyAccessFeaturesLogic.test.ts
@@ -0,0 +1,204 @@
+import { MOCK_TEAM_ID } from 'lib/api.mock'
+
+/* oxlint-disable react-hooks/rules-of-hooks -- useMocks is a test helper, not a React hook */
+import { expectLogic } from 'kea-test-utils'
+
+import { useMocks } from '~/mocks/jest'
+import { initKeaTests } from '~/test/init'
+import { EarlyAccessFeatureStage, EarlyAccessFeatureType, FeatureFlagBasicType } from '~/types'
+
+import { earlyAccessFeaturesLogic } from './earlyAccessFeaturesLogic'
+
+const FEATURE_FLAG: FeatureFlagBasicType = {
+ id: 1,
+ team_id: MOCK_TEAM_ID,
+ key: 'my-flag',
+ name: '',
+ filters: { groups: [] },
+ deleted: false,
+ active: true,
+ ensure_experience_continuity: null,
+}
+
+const mockFeature = (overrides: Partial<EarlyAccessFeatureType> = {}): EarlyAccessFeatureType => ({
+ id: 'abc-123',
+ feature_flag: FEATURE_FLAG,
+ name: 'My feature',
+ description: '',
+ stage: EarlyAccessFeatureStage.Concept,
+ documentation_url: '',
+ created_at: '2024-01-01T00:00:00Z',
+ ...overrides,
+})
+
+// Guards the list scene's two mutations of server state: the chained waitlist-count fetch (wrong
+// survey_ids, a dropped chain, or a survey failure flagged so the cell shows a dash not a fake 0)
+// and the inline assignee PATCH (wrong body/route, and that a failure reverts only the edited row
+// without a full-list reload that would clobber a concurrent edit).
+describe('earlyAccessFeaturesLogic', () => {
+ let logic: ReturnType<typeof earlyAccessFeaturesLogic.build>
+
+ beforeEach(() => {
+ initKeaTests()
+ })
+
+ afterEach(() => {
+ logic?.unmount()
+ })
+
+ it('loads waitlist response counts for features that have a waitlist survey', async () => {
+ let responsesCountUrl: string | null = null
+ useMocks({
+ get: {
+ '/api/projects/:team_id/early_access_feature': {
+ count: 2,
+ results: [
+ mockFeature({ id: 'feature-1', payload: { survey_id: 'survey-1' } }),
+ mockFeature({ id: 'feature-2', stage: EarlyAccessFeatureStage.Beta }),
+ ],
+ },
+ '/api/projects/:team_id/surveys/responses_count': ({ request }) => {
+ responsesCountUrl = request.url
+ return [200, { 'survey-1': 42 }]
+ },
+ },
+ })
+
+ logic = earlyAccessFeaturesLogic()
+ logic.mount()
+
+ await expectLogic(logic).toDispatchActions([
+ 'loadEarlyAccessFeaturesSuccess',
+ 'loadWaitlistResponsesCountSuccess',
+ ])
+
+ // Only the feature with a waitlist survey contributes an id
+ expect(new URL(responsesCountUrl!).searchParams.get('survey_ids')).toEqual('survey-1')
+ expect(logic.values.waitlistResponsesCount).toEqual({ 'survey-1': 42 })
+ })
+
+ it('skips the responses count request when no feature has a waitlist survey', async () => {
+ let responsesCountCalled = false
+ useMocks({
+ get: {
+ '/api/projects/:team_id/early_access_feature': {
+ count: 1,
+ results: [mockFeature({ stage: EarlyAccessFeatureStage.Beta })],
+ },
+ '/api/projects/:team_id/surveys/responses_count': () => {
+ responsesCountCalled = true
+ return [200, {}]
+ },
+ },
+ })
+
+ logic = earlyAccessFeaturesLogic()
+ logic.mount()
+
+ await expectLogic(logic).toDispatchActions(['loadEarlyAccessFeaturesSuccess']).toFinishAllListeners()
+
+ expect(responsesCountCalled).toBe(false)
+ })
+
+ it('flags the failure and keeps an empty counts map when the responses count request fails', async () => {
+ useMocks({
+ get: {
+ '/api/projects/:team_id/early_access_feature': {
+ count: 1,
+ results: [mockFeature({ payload: { survey_id: 'survey-1' } })],
+ },
+ '/api/projects/:team_id/surveys/responses_count': () => [500, {}],
+ },
+ })
+
+ logic = earlyAccessFeaturesLogic()
+ logic.mount()
+
+ // Fails soft: users without survey access still get a working features list, but the cell
+ // shows a dash rather than a fabricated 0
+ await expectLogic(logic).toDispatchActions([
+ 'loadEarlyAccessFeaturesSuccess',
+ 'loadWaitlistResponsesCountFailure',
+ ])
+
+ expect(logic.values.waitlistResponsesCount).toEqual({})
+ expect(logic.values.waitlistResponsesCountFailed).toBe(true)
+ })
+
+ it('updates the assignee optimistically, PATCHes it, and does not reload the list', async () => {
+ let listRequests = 0
+ let patchedId: string | null = null
+ let patchBody: any = null
+ useMocks({
+ get: {
+ '/api/projects/:team_id/early_access_feature': () => {
+ listRequests++
+ return [
+ 200,
+ {
+ count: 1,
+ results: [mockFeature({ id: 'feature-1', stage: EarlyAccessFeatureStage.Beta })],
+ },
+ ]
+ },
+ },
+ patch: {
+ '/api/projects/:team_id/early_access_feature/:id': async ({ request, params }) => {
+ patchedId = params.id as string
+ patchBody = await request.json()
+ return [200, mockFeature({ id: 'feature-1', assignee: patchBody.assignee })]
+ },
+ },
+ })
+
+ logic = earlyAccessFeaturesLogic()
+ logic.mount()
+ await expectLogic(logic).toDispatchActions(['loadEarlyAccessFeaturesSuccess'])
+
+ logic.actions.updateFeatureAssignee('feature-1', { type: 'user', id: 7 })
+ // The optimistic write applies synchronously, before the request resolves
+ expect(logic.values.earlyAccessFeatures[0].assignee).toEqual({ type: 'user', id: 7 })
+
+ await expectLogic(logic).toFinishAllListeners()
+ expect(patchedId).toEqual('feature-1')
+ expect(patchBody).toEqual({ assignee: { type: 'user', id: 7 } })
+ // A successful edit must not refetch the list
+ expect(listRequests).toBe(1)
+ })
+
+ it('reverts only the edited row when the assignee update fails', async () => {
+ let listRequests = 0
+ useMocks({
+ get: {
+ '/api/projects/:team_id/early_access_feature': () => {
+ listRequests++
+ return [
+ 200,
+ {
+ count: 1,
+ results: [
+ mockFeature({ id: 'feature-1', stage: EarlyAccessFeatureStage.Beta, assignee: null }),
+ ],
+ },
+ ]
+ },
+ },
+ patch: {
+ '/api/projects/:team_id/early_access_feature/:id': () => [500, {}],
+ },
+ })
+
+ logic = earlyAccessFeaturesLogic()
+ logic.mount()
+ await expectLogic(logic).toDispatchActions(['loadEarlyAccessFeaturesSuccess'])
+
+ logic.actions.updateFeatureAssignee('feature-1', { type: 'user', id: 7 })
+ // Optimistic write lands first
+ expect(logic.values.earlyAccessFeatures[0].assignee).toEqual({ type: 'user', id: 7 })
+
+ await expectLogic(logic).toFinishAllListeners()
+ // Then reverts to the previous value for just this row — no full-list reload
+ expect(logic.values.earlyAccessFeatures[0].assignee).toBeNull()
+ expect(listRequests).toBe(1)
+ })
+})
diff --git a/products/early_access_features/frontend/earlyAccessFeaturesLogic.ts b/products/early_access_features/frontend/earlyAccessFeaturesLogic.ts
index 407366a4f377..1b8f0717fb27 100644
--- a/products/early_access_features/frontend/earlyAccessFeaturesLogic.ts
+++ b/products/early_access_features/frontend/earlyAccessFeaturesLogic.ts
@@ -1,14 +1,22 @@
-import { MakeLogicType, actions, afterMount, kea, path, reducers, selectors } from 'kea'
+import { MakeLogicType, actions, afterMount, kea, listeners, path, reducers, selectors } from 'kea'
import { loaders } from 'kea-loaders'
+import { lemonToast } from '@posthog/lemon-ui'
+
import api from 'lib/api'
import { createFeaturePreviewSearch } from 'lib/utils/fuseSearch'
import { urls } from 'scenes/urls'
-import { Breadcrumb, EarlyAccessFeatureType } from '~/types'
+import { Breadcrumb, EarlyAccessFeatureAssignee, EarlyAccessFeatureType } from '~/types'
const search = createFeaturePreviewSearch<EarlyAccessFeatureType>()
+// The waitlist survey id lives in the untyped `payload` bag, so pin its shape in one place.
+export const waitlistSurveyId = (feature: EarlyAccessFeatureType): string | null => {
+ const surveyId = feature.payload?.survey_id
+ return typeof surveyId === 'string' ? surveyId : null
+}
+
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface earlyAccessFeaturesLogicValues {
breadcrumbs: Breadcrumb[]
@@ -16,6 +24,9 @@ export interface earlyAccessFeaturesLogicValues {
earlyAccessFeaturesLoading: boolean
filteredEarlyAccessFeatures: EarlyAccessFeatureType[]
searchTerm: string
+ waitlistResponsesCount: Record<string, number>
+ waitlistResponsesCountFailed: boolean
+ waitlistResponsesCountLoading: boolean
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
@@ -35,9 +46,42 @@ export interface earlyAccessFeaturesLogicActions {
earlyAccessFeatures: EarlyAccessFeatureType[]
payload?: any
}
+ loadWaitlistResponsesCount: (surveyIds: string) => string
+ loadWaitlistResponsesCountFailure: (
+ error: string,
+ errorObject?: any
+ ) => {
+ error: string
+ errorObject?: any
+ }
+ loadWaitlistResponsesCountSuccess: (
+ waitlistResponsesCount: {
+ [key: string]: number
+ },
+ payload?: string
+ ) => {
+ waitlistResponsesCount: {
+ [key: string]: number
+ }
+ payload?: string
+ }
+ setFeatureAssignee: (
+ id: EarlyAccessFeatureType['id'],
+ assignee: EarlyAccessFeatureAssignee | null
+ ) => {
+ assignee: EarlyAccessFeatureAssignee | null
+ id: string
+ }
setSearchTerm: (searchTerm: string) => {
searchTerm: string
}
+ updateFeatureAssignee: (
+ id: EarlyAccessFeatureType['id'],
+ assignee: EarlyAccessFeatureAssignee | null
+ ) => {
+ assignee: EarlyAccessFeatureAssignee | null
+ id: string
+ }
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
@@ -62,6 +106,14 @@ export const earlyAccessFeaturesLogic = kea<earlyAccessFeaturesLogicType>([
actions({
setSearchTerm: (searchTerm: string) => ({ searchTerm }),
+ setFeatureAssignee: (id: EarlyAccessFeatureType['id'], assignee: EarlyAccessFeatureAssignee | null) => ({
+ id,
+ assignee,
+ }),
+ updateFeatureAssignee: (id: EarlyAccessFeatureType['id'], assignee: EarlyAccessFeatureAssignee | null) => ({
+ id,
+ assignee,
+ }),
}),
loaders({
@@ -72,6 +124,12 @@ export const earlyAccessFeaturesLogic = kea<earlyAccessFeaturesLogicType>([
return response.results
},
},
+ waitlistResponsesCount: {
+ __default: {} as Record<string, number>,
+ loadWaitlistResponsesCount: async (surveyIds: string) => {
+ return await api.surveys.getResponsesCount(surveyIds)
+ },
+ },
}),
reducers({
@@ -81,6 +139,17 @@ export const earlyAccessFeaturesLogic = kea<earlyAccessFeaturesLogicType>([
setSearchTerm: (_, { searchTerm }) => searchTerm,
},
],
+ earlyAccessFeatures: {
+ setFeatureAssignee: (state, { id, assignee }) =>
+ state.map((feature) => (feature.id === id ? { ...feature, assignee } : feature)),
+ },
+ waitlistResponsesCountFailed: [
+ false,
+ {
+ loadWaitlistResponsesCount: () => false,
+ loadWaitlistResponsesCountFailure: () => true,
+ },
+ ],
}),
selectors({
@@ -104,6 +173,27 @@ export const earlyAccessFeaturesLogic = kea<earlyAccessFeaturesLogicType>([
],
}),
+ listeners(({ actions, values }) => ({
+ loadEarlyAccessFeaturesSuccess: ({ earlyAccessFeatures }) => {
+ const surveyIds = earlyAccessFeatures.map(waitlistSurveyId).filter((id): id is string => id !== null)
+ if (surveyIds.length > 0) {
+ actions.loadWaitlistResponsesCount(surveyIds.join(','))
+ }
+ },
+ updateFeatureAssignee: async ({ id, assignee }) => {
+ // Read the value before the optimistic write so a failure reverts only this row,
+ // without clobbering a concurrent edit on another row via a full-list reload.
+ const previousAssignee = values.earlyAccessFeatures.find((feature) => feature.id === id)?.assignee ?? null
+ actions.setFeatureAssignee(id, assignee)
+ try {
+ await api.earlyAccessFeatures.update(id, { assignee })
+ } catch {
+ lemonToast.error('Failed to update assignee')
+ actions.setFeatureAssignee(id, previousAssignee)
+ }
+ },
+ })),
+
afterMount(({ actions }) => {
actions.loadEarlyAccessFeatures()
}),