-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(issue-details): Add people section to sidebar (#79609)
this pr removes participants/viewers from the header and moves them into their own section in the sidebar ![Screenshot 2024-10-23 at 9 50 05 AM](https://github.com/user-attachments/assets/6737bd6c-4450-4cc4-920a-7c89629f62f8)
- Loading branch information
1 parent
c5ee901
commit 5355d93
Showing
5 changed files
with
113 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,11 +4,9 @@ import {OrganizationFixture} from 'sentry-fixture/organization'; | |
import {ProjectFixture} from 'sentry-fixture/project'; | ||
import {RouterFixture} from 'sentry-fixture/routerFixture'; | ||
import {TeamFixture} from 'sentry-fixture/team'; | ||
import {UserFixture} from 'sentry-fixture/user'; | ||
|
||
import {render, screen} from 'sentry-test/reactTestingLibrary'; | ||
|
||
import type {TeamParticipant, UserParticipant} from 'sentry/types/group'; | ||
import {IssueCategory} from 'sentry/types/group'; | ||
import {formatAbbreviatedNumber} from 'sentry/utils/formatters'; | ||
import StreamlinedGroupHeader from 'sentry/views/issueDetails/streamline/header'; | ||
|
@@ -56,36 +54,10 @@ describe('StreamlinedGroupHeader', () => { | |
}); | ||
|
||
it('shows all elements of header', async () => { | ||
const teams: TeamParticipant[] = [{...TeamFixture(), type: 'team'}]; | ||
const users: UserParticipant[] = [ | ||
{ | ||
...UserFixture({ | ||
id: '2', | ||
name: 'John Smith', | ||
email: '[email protected]', | ||
}), | ||
type: 'user', | ||
}, | ||
{ | ||
...UserFixture({ | ||
id: '3', | ||
name: 'Sohn Jmith', | ||
email: '[email protected]', | ||
}), | ||
type: 'user', | ||
}, | ||
]; | ||
|
||
const participantGroup = { | ||
...group, | ||
participants: [...teams, ...users], | ||
seenBy: users, | ||
}; | ||
|
||
render( | ||
<StreamlinedGroupHeader | ||
{...defaultProps} | ||
group={participantGroup} | ||
group={group} | ||
project={project} | ||
event={null} | ||
/>, | ||
|
@@ -110,9 +82,6 @@ describe('StreamlinedGroupHeader', () => { | |
screen.getByRole('button', {name: 'Modify issue assignee'}) | ||
).toBeInTheDocument(); | ||
|
||
expect(screen.getByText('Participants')).toBeInTheDocument(); | ||
expect(screen.getByText('Viewers')).toBeInTheDocument(); | ||
|
||
expect( | ||
screen.queryByRole('button', {name: 'Switch to the old issue experience'}) | ||
).not.toBeInTheDocument(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
static/app/views/issueDetails/streamline/peopleSection.spec.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import {GroupFixture} from 'sentry-fixture/group'; | ||
import {TeamFixture} from 'sentry-fixture/team'; | ||
import {UserFixture} from 'sentry-fixture/user'; | ||
|
||
import {render, screen} from 'sentry-test/reactTestingLibrary'; | ||
|
||
import type {TeamParticipant, UserParticipant} from 'sentry/types/group'; | ||
import PeopleSection from 'sentry/views/issueDetails/streamline/peopleSection'; | ||
|
||
describe('PeopleSection', () => { | ||
const group = GroupFixture(); | ||
|
||
it('displays participants and viewers', async () => { | ||
const teams: TeamParticipant[] = [{...TeamFixture(), type: 'team'}]; | ||
const users: UserParticipant[] = [ | ||
{ | ||
...UserFixture({ | ||
id: '2', | ||
name: 'John Smith', | ||
email: '[email protected]', | ||
}), | ||
type: 'user', | ||
}, | ||
{ | ||
...UserFixture({ | ||
id: '3', | ||
name: 'Sohn Jmith', | ||
email: '[email protected]', | ||
}), | ||
type: 'user', | ||
}, | ||
]; | ||
|
||
const participantGroup = { | ||
...group, | ||
participants: [...teams, ...users], | ||
seenBy: users, | ||
}; | ||
|
||
render(<PeopleSection group={participantGroup} />); | ||
|
||
expect(await screen.findByText('participating')).toBeInTheDocument(); | ||
expect(await screen.findByText('viewed')).toBeInTheDocument(); | ||
}); | ||
|
||
it('does not display anything if there are no participants or viewers', () => { | ||
render(<PeopleSection group={group} />); | ||
|
||
expect(screen.queryByText('participating')).not.toBeInTheDocument(); | ||
expect(screen.queryByText('viewed')).not.toBeInTheDocument(); | ||
}); | ||
}); |
49 changes: 49 additions & 0 deletions
49
static/app/views/issueDetails/streamline/peopleSection.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import {useMemo} from 'react'; | ||
|
||
import {Flex} from 'sentry/components/container/flex'; | ||
import ParticipantList from 'sentry/components/group/streamlinedParticipantList'; | ||
import {t} from 'sentry/locale'; | ||
import {space} from 'sentry/styles/space'; | ||
import type {Group, TeamParticipant, UserParticipant} from 'sentry/types/group'; | ||
import {useUser} from 'sentry/utils/useUser'; | ||
import {SidebarSectionTitle} from 'sentry/views/issueDetails/streamline/sidebar'; | ||
|
||
export default function PeopleSection({group}: {group: Group}) { | ||
const activeUser = useUser(); | ||
const {userParticipants, teamParticipants, viewers} = useMemo(() => { | ||
return { | ||
userParticipants: group.participants.filter( | ||
(p): p is UserParticipant => p.type === 'user' | ||
), | ||
teamParticipants: group.participants.filter( | ||
(p): p is TeamParticipant => p.type === 'team' | ||
), | ||
viewers: group.seenBy.filter(user => activeUser.id !== user.id), | ||
}; | ||
}, [group, activeUser.id]); | ||
|
||
const hasParticipants = group.participants.length > 0; | ||
const hasViewers = viewers.length > 0; | ||
|
||
if (!hasParticipants && !hasViewers) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<div> | ||
<SidebarSectionTitle>{t('People')}</SidebarSectionTitle> | ||
{hasParticipants && ( | ||
<Flex gap={space(0.5)} align="center"> | ||
<ParticipantList users={userParticipants} teams={teamParticipants} /> | ||
{t('participating')} | ||
</Flex> | ||
)} | ||
{hasViewers && ( | ||
<Flex gap={space(0.5)} align="center"> | ||
<ParticipantList users={viewers} /> | ||
{t('viewed')} | ||
</Flex> | ||
)} | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters