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(conversations): skip admin-only picker loads for non-admins (#127989)

Alex V144acce0c76a
diff --git a/products/conversations/frontend/scenes/settings/TeamsSection.tsx b/products/conversations/frontend/scenes/settings/TeamsSection.tsx
index 3a8971849831..432d22e3f8a7 100644
--- a/products/conversations/frontend/scenes/settings/TeamsSection.tsx
+++ b/products/conversations/frontend/scenes/settings/TeamsSection.tsx
@@ -162,7 +162,7 @@ function AddTeamsChannelRow({ adminRestrictionReason }: AddTeamsChannelRowProps)
type="secondary"
size="small"
onClick={loadTeamsTeamsWithToken}
- disabledReason={teamsTeamsLoading ? 'Loading...' : undefined}
+ disabledReason={adminRestrictionReason || (teamsTeamsLoading ? 'Loading...' : undefined)}
>
Refresh
</LemonButton>
diff --git a/products/conversations/frontend/scenes/settings/supportSettingsLogic.test.ts b/products/conversations/frontend/scenes/settings/supportSettingsLogic.test.ts
index 8122c8e50653..eef654b260e4 100644
--- a/products/conversations/frontend/scenes/settings/supportSettingsLogic.test.ts
+++ b/products/conversations/frontend/scenes/settings/supportSettingsLogic.test.ts
@@ -1,8 +1,8 @@
-import { MOCK_DEFAULT_TEAM } from 'lib/api.mock'
+import { MOCK_DEFAULT_ORGANIZATION, MOCK_DEFAULT_PROJECT, MOCK_DEFAULT_TEAM } from 'lib/api.mock'
import { expectLogic } from 'kea-test-utils'
-import { FEATURE_FLAGS } from 'lib/constants'
+import { FEATURE_FLAGS, OrganizationMembershipLevel } from 'lib/constants'
import { lemonToast } from 'lib/lemon-ui/LemonToast/LemonToast'
import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
@@ -779,4 +779,45 @@ describe('supportSettingsLogic', () => {
expect(logic.values.accountPropertyOptions).toEqual(OPTIONS)
})
})
+
+ describe('admin-only picker lists on mount', () => {
+ it.each([
+ {
+ level: OrganizationMembershipLevel.Admin,
+ expectedRequests: ['github/repos', 'teams/channels', 'teams/teams'],
+ },
+ { level: OrganizationMembershipLevel.Member, expectedRequests: [] },
+ ])('membership level $level requests $expectedRequests', async ({ level, expectedRequests }) => {
+ const requests: string[] = []
+ const record = (name: string, body: Record<string, unknown>) => () => {
+ requests.push(name)
+ return [200, body]
+ }
+ useMocks({
+ get: {
+ '/api/conversations/v1/email/status': { configs: [] },
+ '/api/projects/:team_id/conversations/ai_reply_playbook/': PLAYBOOK_GET,
+ },
+ post: {
+ '/api/conversations/v1/github/repos': record('github/repos', { repos: [] }),
+ '/api/conversations/v1/teams/teams': record('teams/teams', { teams: [] }),
+ '/api/conversations/v1/teams/channels': record('teams/channels', { channels: [] }),
+ },
+ })
+ initKeaTests(
+ true,
+ {
+ ...MOCK_DEFAULT_TEAM,
+ conversations_settings: { github_enabled: true, teams_enabled: true, teams_team_id: 't1' },
+ } as unknown as TeamType,
+ MOCK_DEFAULT_PROJECT,
+ { ...MOCK_DEFAULT_ORGANIZATION, membership_level: level }
+ )
+ logic = supportSettingsLogic()
+ logic.mount()
+ await expectLogic(logic).toFinishAllListeners()
+
+ expect(requests.sort()).toEqual(expectedRequests)
+ })
+ })
})
diff --git a/products/conversations/frontend/scenes/settings/supportSettingsLogic.ts b/products/conversations/frontend/scenes/settings/supportSettingsLogic.ts
index 3835e1bc4c11..2ae94ce91865 100644
--- a/products/conversations/frontend/scenes/settings/supportSettingsLogic.ts
+++ b/products/conversations/frontend/scenes/settings/supportSettingsLogic.ts
@@ -8,6 +8,7 @@ import { ApiError } from 'lib/api-error'
import { FEATURE_FLAGS } from 'lib/constants'
import { lemonToast } from 'lib/lemon-ui/LemonToast/LemonToast'
import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
+import { organizationLogic } from 'scenes/organizationLogic'
import { teamLogic } from 'scenes/teamLogic'
import { SlackChannelType, UserBasicType } from '~/types'
@@ -68,6 +69,7 @@ function emailSettingsErrorMessage(error: unknown, fallback: string): string {
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface supportSettingsLogicValues {
featureFlags: FeatureFlagsSet // featureFlagLogic
+ isAdminOrOwner: boolean | null // organizationLogic
currentTeam: TeamPublicType | TeamType | null // teamLogic
currentTeamLoading: boolean // teamLogic
accountPropertyOptions: AIContextAccountPropertyApi[]
@@ -697,7 +699,14 @@ export type supportSettingsLogicType = MakeLogicType<
export const supportSettingsLogic = kea<supportSettingsLogicType>([
path(['products', 'conversations', 'frontend', 'scenes', 'settings', 'supportSettingsLogic']),
connect(() => ({
- values: [teamLogic, ['currentTeam', 'currentTeamLoading'], featureFlagLogic, ['featureFlags']],
+ values: [
+ teamLogic,
+ ['currentTeam', 'currentTeamLoading'],
+ featureFlagLogic,
+ ['featureFlags'],
+ organizationLogic,
+ ['isAdminOrOwner'],
+ ],
actions: [
teamLogic,
[
@@ -2080,7 +2089,9 @@ export const supportSettingsLogic = kea<supportSettingsLogicType>([
if (values.slackConnected) {
actions.loadSlackChannelsWithToken()
}
- if (values.teamsConnected) {
+ // These picker lists come from admin-only endpoints. The saved selection renders from team settings.
+ const isAdmin = !!values.isAdminOrOwner
+ if (values.teamsConnected && isAdmin) {
actions.loadTeamsTeamsWithToken()
const teamsTeamId = values.teamsTeamId
if (teamsTeamId) {
@@ -2095,7 +2106,7 @@ export const supportSettingsLogic = kea<supportSettingsLogicType>([
actions.loadEmailConfigs()
// Load GitHub integrations for the connect picker
actions.loadGithubIntegrations()
- if (values.githubConnected) {
+ if (values.githubConnected && isAdmin) {
actions.loadGithubRepos()
}
actions.loadPlaybook()