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(today): show repositories, access and members as settings rows (#109573)

Shy Alterb805e95de567
diff --git a/products/tasks/frontend/spaces/SpaceAccess.tsx b/products/tasks/frontend/spaces/SpaceAccess.tsx
index 1ffb0d8c645b..a8f5fb25ea41 100644
--- a/products/tasks/frontend/spaces/SpaceAccess.tsx
+++ b/products/tasks/frontend/spaces/SpaceAccess.tsx
@@ -1,129 +1,88 @@
import { useActions, useValues } from 'kea'
-import { useRef } from 'react'
import {
- Combobox,
- ComboboxChip,
- ComboboxChips,
- ComboboxChipsInput,
- ComboboxContent,
- ComboboxEmpty,
- ComboboxItem,
- ComboboxList,
- ComboboxValue,
- FieldDescription,
- Label,
+ Item,
+ ItemContent,
+ ItemDescription,
+ ItemGroup,
+ ItemMedia,
+ ItemTitle,
RadioGroup,
RadioGroupItem,
- Skeleton,
Text,
+ cn,
} from '@posthog/quill'
-import { useOnMountEffect } from 'lib/hooks/useOnMountEffect'
-import { fullName } from 'lib/utils/strings'
-import { membersLogic } from 'scenes/organization/membersLogic'
-
import { spaceSceneLogic } from './spaceSceneLogic'
+import { SpaceSettingsSection } from './SpaceSettingsSection'
-export function SpaceAccess({ id }: { id: string }): JSX.Element | null {
- const { space, savingSpace, members, membersLoading, creatorId } = useValues(spaceSceneLogic({ id }))
- const { updateSpace, setMemberIds } = useActions(spaceSceneLogic({ id }))
- const { meFirstMembers } = useValues(membersLogic)
- const { ensureAllMembersLoaded } = useActions(membersLogic)
- const anchor = useRef<HTMLDivElement>(null)
+const ACCESS_OPTIONS = [
+ {
+ value: 'public',
+ title: 'Everyone in the project',
+ description: 'Anyone in this project can see the space and its sessions.',
+ },
+ {
+ value: 'private',
+ title: 'Only members',
+ description: 'Only the people you add can see the space and its sessions.',
+ },
+] as const
- useOnMountEffect(ensureAllMembersLoaded)
+export function SpaceAccess({ id }: { id: string }): JSX.Element | null {
+ const { space, savingSpace } = useValues(spaceSceneLogic({ id }))
+ const { updateSpace } = useActions(spaceSceneLogic({ id }))
if (!space) {
return null
}
if (space.system_role === 'personal') {
return (
- <Text size="sm" variant="muted">
- Only you can see your personal space.
- </Text>
+ <SpaceSettingsSection label="Access">
+ <Text size="xs" variant="muted" className="px-0.5">
+ Only you can see this personal space.
+ </Text>
+ </SpaceSettingsSection>
)
}
- const isPrivate = space.channel_type === 'private'
const generalSpace = space.system_role === 'general'
- const names = new Map<number, string>([
- ...meFirstMembers.map((member) => [member.user.id, fullName(member.user)] as [number, string]),
- ...members.map((member) => [member.id, fullName(member)] as [number, string]),
- ])
- const memberIds = members.map((member) => member.id)
- const allIds = [...new Set([...meFirstMembers.map((member) => member.user.id), ...memberIds])]
+ const value = space.channel_type === 'private' ? 'private' : 'public'
return (
- <div className="flex flex-col gap-3">
+ <SpaceSettingsSection
+ label="Access"
+ description={generalSpace ? 'The general space is open to everyone in the project.' : undefined}
+ >
<RadioGroup
- value={isPrivate ? 'private' : 'public'}
+ value={value}
onValueChange={(channelType: 'public' | 'private') => updateSpace({ channel_type: channelType })}
disabled={generalSpace || savingSpace}
+ className="gap-0"
data-attr="today-space-settings-access"
>
- <div className="flex items-center gap-2">
- <RadioGroupItem value="public" id="space-access-public" />
- <Label htmlFor="space-access-public">Everyone in the project</Label>
- </div>
- <div className="flex items-center gap-2">
- <RadioGroupItem value="private" id="space-access-private" />
- <Label htmlFor="space-access-private">Only members</Label>
- </div>
- </RadioGroup>
- {generalSpace && <FieldDescription>The general space is open to everyone in the project.</FieldDescription>}
- {isPrivate &&
- (membersLoading && !members.length ? (
- <Skeleton className="h-8 w-full max-w-100" />
- ) : (
- <div className="flex flex-col gap-1">
- <Combobox
- multiple
- items={allIds}
- value={memberIds}
- onValueChange={(userIds: number[]) => setMemberIds(userIds)}
- itemToStringLabel={(userId: number) => names.get(userId) ?? ''}
+ <ItemGroup combined role="none">
+ {ACCESS_OPTIONS.map((option) => (
+ <Item
+ key={option.value}
+ variant="outline"
+ size="sm"
+ className={cn(
+ !generalSpace && 'cursor-pointer',
+ option.value === value && 'bg-fill-selected'
+ )}
+ render={<label htmlFor={`space-access-${option.value}`} />}
>
- <ComboboxChips ref={anchor} className="max-w-100" data-attr="today-space-settings-members">
- <ComboboxValue>
- {(userIds: number[]) => (
- <>
- {userIds.map((userId) =>
- userId === creatorId ? (
- <ComboboxChip
- key={userId}
- showRemove={false}
- title={`${names.get(userId) ?? ''} (creator)`}
- >
- <span>{names.get(userId) ?? ''}</span>{' '}
- <Text render={<span />} size="xs" variant="muted">
- Creator
- </Text>
- </ComboboxChip>
- ) : (
- <ComboboxChip key={userId}>{names.get(userId) ?? ''}</ComboboxChip>
- )
- )}
- <ComboboxChipsInput placeholder="Add people" aria-label="Add people" />
- </>
- )}
- </ComboboxValue>
- </ComboboxChips>
- <ComboboxContent anchor={anchor}>
- <ComboboxEmpty>No one matches that name.</ComboboxEmpty>
- <ComboboxList>
- {(userId: number) => (
- <ComboboxItem key={userId} value={userId} disabled={userId === creatorId}>
- {names.get(userId)}
- </ComboboxItem>
- )}
- </ComboboxList>
- </ComboboxContent>
- </Combobox>
- <FieldDescription>
- Any member can add or remove people. The creator always stays a member.
- </FieldDescription>
- </div>
- ))}
- </div>
+ <ItemMedia>
+ <RadioGroupItem value={option.value} id={`space-access-${option.value}`} />
+ </ItemMedia>
+ <ItemContent>
+ <ItemTitle>{option.title}</ItemTitle>
+ <ItemDescription>{option.description}</ItemDescription>
+ </ItemContent>
+ </Item>
+ ))}
+ </ItemGroup>
+ </RadioGroup>
+ </SpaceSettingsSection>
)
}
diff --git a/products/tasks/frontend/spaces/SpaceMembers.tsx b/products/tasks/frontend/spaces/SpaceMembers.tsx
new file mode 100644
index 000000000000..c6b4d467182e
--- /dev/null
+++ b/products/tasks/frontend/spaces/SpaceMembers.tsx
@@ -0,0 +1,154 @@
+import { useActions, useValues } from 'kea'
+
+import { IconX } from '@posthog/icons'
+import {
+ Avatar,
+ AvatarFallback,
+ Badge,
+ Button,
+ Combobox,
+ ComboboxContent,
+ ComboboxEmpty,
+ ComboboxInput,
+ ComboboxItem,
+ ComboboxList,
+ Item,
+ ItemActions,
+ ItemContent,
+ ItemDescription,
+ ItemGroup,
+ ItemMedia,
+ ItemTitle,
+ Skeleton,
+ Text,
+ Tooltip,
+ TooltipContent,
+ TooltipTrigger,
+} from '@posthog/quill'
+
+import { useOnMountEffect } from 'lib/hooks/useOnMountEffect'
+import { fullName } from 'lib/utils/strings'
+import { membersLogic } from 'scenes/organization/membersLogic'
+
+import { spaceSceneLogic } from './spaceSceneLogic'
+import { SpaceSettingsSection } from './SpaceSettingsSection'
+
+export function SpaceMembers({ id }: { id: string }): JSX.Element | null {
+ const { space, members, membersLoading, creatorId } = useValues(spaceSceneLogic({ id }))
+ const { setMemberIds } = useActions(spaceSceneLogic({ id }))
+ const { meFirstMembers } = useValues(membersLogic)
+ const { ensureAllMembersLoaded } = useActions(membersLogic)
+
+ useOnMountEffect(ensureAllMembersLoaded)
+
+ if (space?.channel_type !== 'private') {
+ return null
+ }
+ const names = new Map<number, string>([
+ ...meFirstMembers.map((member) => [member.user.id, fullName(member.user)] as [number, string]),
+ ...members.map((member) => [member.id, fullName(member)] as [number, string]),
+ ])
+ const memberIds = members.map((member) => member.id)
+ const allIds = [...new Set([...meFirstMembers.map((member) => member.user.id), ...memberIds])]
+
+ return (
+ <SpaceSettingsSection
+ label="Members"
+ description="Any member can add or remove people. The creator always stays a member."
+ action={
+ members.length ? (
+ <Text size="xs" variant="muted">
+ {members.length === 1 ? '1 member' : `${members.length} members`}
+ </Text>
+ ) : null
+ }
+ >
+ {membersLoading && !members.length ? (
+ <Skeleton className="h-24 w-full" />
+ ) : (
+ <div className="flex flex-col gap-2">
+ {/* A multiple picker, so picking a current member again removes them. */}
+ <Combobox
+ multiple
+ items={allIds}
+ value={memberIds}
+ onValueChange={(userIds: number[]) => setMemberIds(userIds)}
+ itemToStringLabel={(userId: number) => names.get(userId) ?? ''}
+ disabled={membersLoading}
+ >
+ <ComboboxInput
+ placeholder="Add people"
+ aria-label="Add people"
+ disabled={membersLoading}
+ data-attr="today-space-settings-members"
+ />
+ <ComboboxContent>
+ <ComboboxEmpty>No one matches that name.</ComboboxEmpty>
+ <ComboboxList>
+ {(userId: number) => (
+ <ComboboxItem key={userId} value={userId} disabled={userId === creatorId}>
+ {names.get(userId)}
+ </ComboboxItem>
+ )}
+ </ComboboxList>
+ </ComboboxContent>
+ </Combobox>
+ <ItemGroup combined>
+ {members.map((member) => {
+ const name = fullName(member)
+ return (
+ <Item
+ key={member.id}
+ variant="outline"
+ size="sm"
+ data-attr="today-space-settings-member"
+ >
+ <ItemMedia>
+ <Avatar size="sm">
+ <AvatarFallback>{name.charAt(0).toUpperCase()}</AvatarFallback>
+ </Avatar>
+ </ItemMedia>
+ <ItemContent className="min-w-0">
+ <ItemTitle className="max-w-full">
+ <span className="min-w-0 truncate">{name}</span>
+ </ItemTitle>
+ {member.email && <ItemDescription>{member.email}</ItemDescription>}
+ </ItemContent>
+ <ItemActions>
+ {member.id === creatorId ? (
+ <Badge>Creator</Badge>
+ ) : (
+ <Tooltip>
+ <TooltipTrigger
+ delay={0}
+ render={
+ <Button
+ size="icon-xs"
+ aria-label={`Remove ${name}`}
+ disabled={membersLoading}
+ onClick={() =>
+ setMemberIds(
+ memberIds.filter((userId) => userId !== member.id)
+ )
+ }
+ data-attr="today-space-settings-remove-member"
+ />
+ }
+ >
+ <IconX />
+ </TooltipTrigger>
+ <TooltipContent>
+ {membersLoading ? 'Saving your last change' : `Remove ${name}`}
+ </TooltipContent>
+ </Tooltip>
+ )}
+ </ItemActions>
+ </Item>
+ )
+ })}
+ </ItemGroup>
+ </div>
+ )}
+ </SpaceSettingsSection>
+ )
+}
diff --git a/products/tasks/frontend/spaces/SpaceRepositories.tsx b/products/tasks/frontend/spaces/SpaceRepositories.tsx
index 1aef288e85bb..12425521f12a 100644
--- a/products/tasks/frontend/spaces/SpaceRepositories.tsx
+++ b/products/tasks/frontend/spaces/SpaceRepositories.tsx
@@ -1,7 +1,21 @@
import { useActions, useValues } from 'kea'
-import { IconGithub } from '@posthog/icons'
-import { Button, Chip, ChipClose, Skeleton, Text } from '@posthog/quill'
+import { IconGitRepository, IconGithub, IconX } from '@posthog/icons'
+import {
+ Button,
+ Item,
+ ItemActions,
+ ItemContent,
+ ItemDescription,
+ ItemGroup,
+ ItemMedia,
+ ItemTitle,
+ Skeleton,
+ Text,
+ Tooltip,
+ TooltipContent,
+ TooltipTrigger,
+} from '@posthog/quill'
import api from 'lib/api'
import { GitHubRepositoryCombobox } from 'lib/integrations/GitHubRepositoryCombobox'
@@ -9,6 +23,7 @@ import { integrationsLogic } from 'lib/integrations/integrationsLogic'
import { LinkPrimitive } from 'lib/lemon-ui/Link'
import { spaceSceneLogic } from './spaceSceneLogic'
+import { SpaceSettingsSection } from './SpaceSettingsSection'
const MAX_REPOSITORIES = 10
@@ -20,71 +35,119 @@ export function SpaceRepositories({ id }: { id: string }): JSX.Element | null {
if (!space) {
return null
}
- const githubIntegrations = getIntegrationsByKind(['github'])
- const integrationId = space.github_integration ?? githubIntegrations[0]?.id
+ const integrationId = space.github_integration ?? getIntegrationsByKind(['github'])[0]?.id
const repositories = space.repositories
return (
- <div className="flex flex-col items-start gap-2">
- {repositories.length ? (
- <div className="flex flex-wrap gap-1">
- {repositories.map((repository) => (
- <Chip key={repository} data-attr="today-space-settings-repository">
- {repository}
- <ChipClose
- aria-label={`Remove ${repository}`}
- disabled={savingSpace}
- onClick={() =>
- updateSpace({ repositories: repositories.filter((r) => r !== repository) })
+ <SpaceSettingsSection
+ label="Repositories"
+ description="Sessions in this space start with these repositories checked out."
+ action={
+ integrationsLoading ? (
+ <Skeleton className="h-6 w-32" />
+ ) : !integrationId ? null : repositories.length < MAX_REPOSITORIES ? (
+ <div data-attr="today-space-settings-add-repository">
+ <GitHubRepositoryCombobox
+ integrationId={integrationId}
+ value=""
+ placeholder="Add repository"
+ disabled={savingSpace}
+ onChange={(repository) => {
+ if (repository && !repositories.includes(repository)) {
+ updateSpace({
+ repositories: [...repositories, repository],
+ github_integration: integrationId,
+ })
}
- />
- </Chip>
- ))}
- </div>
- ) : (
- <Text size="sm" variant="muted">
- No repositories yet.
- </Text>
- )}
- {integrationsLoading ? (
- <Skeleton className="h-8 w-60" />
- ) : !integrationId ? (
- <Button
- variant="outline"
- render={
- <LinkPrimitive
- to={api.integrations.authorizeUrl({ kind: 'github', next: window.location.pathname })}
- disableClientSideRouting
+ }}
/>
- }
- data-attr="today-space-settings-connect-github"
- >
- <IconGithub />
- Connect GitHub
- </Button>
- ) : repositories.length < MAX_REPOSITORIES ? (
- <div className="w-full max-w-100">
- <GitHubRepositoryCombobox
- integrationId={integrationId}
- value=""
- placeholder="Add a repository"
- disabledReason={savingSpace ? 'Saving your last change' : undefined}
- onChange={(repository) => {
- if (repository && !repositories.includes(repository)) {
- updateSpace({
- repositories: [...repositories, repository],
- github_integration: integrationId,
- })
- }
- }}
- fullWidth
- />
- </div>
- ) : (
- <Text size="sm" variant="muted">
- A space can have up to {MAX_REPOSITORIES} repositories.
- </Text>
- )}
- </div>
+ </div>
+ ) : (
+ <Text size="xs" variant="muted">
+ {`Up to ${MAX_REPOSITORIES} repositories`}
+ </Text>
+ )
+ }
+ >
+ <ItemGroup combined>
+ {repositories.map((repository) => (
+ <Item key={repository} variant="outline" size="sm" data-attr="today-space-settings-repository">
+ <ItemMedia variant="icon" className="text-muted-foreground">
+ <IconGitRepository />
+ </ItemMedia>
+ <ItemContent className="min-w-0">
+ <ItemTitle className="max-w-full">
+ <span className="min-w-0 truncate">{repository}</span>
+ </ItemTitle>
+ </ItemContent>
+ <ItemActions>
+ <Tooltip>
+ <TooltipTrigger
+ delay={0}
+ render={
+ <Button
+ size="icon-xs"
+ aria-label={`Remove ${repository}`}
+ disabled={savingSpace}
+ onClick={() =>
+ updateSpace({
+ repositories: repositories.filter((r) => r !== repository),
+ })
+ }
+ data-attr="today-space-settings-remove-repository"
+ />
+ }
+ >
+ <IconX />
+ </TooltipTrigger>
+ <TooltipContent>
+ {savingSpace ? 'Saving your last change' : `Remove ${repository}`}
+ </TooltipContent>
+ </Tooltip>
+ </ItemActions>
+ </Item>
+ ))}
+ {!integrationsLoading && !integrationId ? (
+ <Item variant="outline" size="sm">
+ <ItemMedia variant="icon" className="text-muted-foreground">
+ <IconGithub />
+ </ItemMedia>
+ <ItemContent className="min-w-56">
+ <ItemTitle>GitHub isn’t connected</ItemTitle>
+ <ItemDescription>Connect GitHub to pick repositories for this space.</ItemDescription>
+ </ItemContent>
+ <ItemActions>
+ <Button
+ variant="outline"
+ size="sm"
+ render={
+ <LinkPrimitive
+ to={api.integrations.authorizeUrl({
+ kind: 'github',
+ next: window.location.pathname,
+ })}
+ disableClientSideRouting
+ />
+ }
+ data-attr="today-space-settings-connect-github"
+ >
+ <IconGithub />
+ Connect GitHub
+ </Button>
+ </ItemActions>
+ </Item>
+ ) : (
+ !repositories.length && (
+ <Item variant="outline" size="sm">
+ <ItemContent>
+ <ItemDescription>
+ No repositories yet. Sessions start without code checked out.
+ </ItemDescription>
+ </ItemContent>
+ </Item>
+ )
+ )}
+ </ItemGroup>
+ </SpaceSettingsSection>
)
}
diff --git a/products/tasks/frontend/spaces/SpaceSettings.tsx b/products/tasks/frontend/spaces/SpaceSettings.tsx
index 2f10979e4591..8fd91ee3c144 100644
--- a/products/tasks/frontend/spaces/SpaceSettings.tsx
+++ b/products/tasks/frontend/spaces/SpaceSettings.tsx
@@ -38,6 +38,7 @@ import {
import { spaceLabel } from '~/layout/today/todaySpacesLogic'
import { SpaceAccess } from './SpaceAccess'
+import { SpaceMembers } from './SpaceMembers'
import { SpaceRepositories } from './SpaceRepositories'
import {
AUTO_ARCHIVE_MAX_DAYS,
@@ -133,15 +134,9 @@ export function SpaceSettings({ id }: { id: string }): JSX.Element {
</ItemGroup>
</SpaceSettingsSection>
- <SpaceSettingsSection
- label="Repositories"
- description="Sessions in this space start with these repositories checked out."
- >
- <SpaceRepositories id={id} />
- </SpaceSettingsSection>
- <SpaceSettingsSection label="Access">
- <SpaceAccess id={id} />
- </SpaceSettingsSection>
+ <SpaceRepositories id={id} />
+ <SpaceAccess id={id} />
+ <SpaceMembers id={id} />
<SpaceSettingsSection label="Sessions">
<ItemGroup combined>