File tree Expand file tree Collapse file tree 13 files changed +184
-4
lines changed
Expand file tree Collapse file tree 13 files changed +184
-4
lines changed Original file line number Diff line number Diff line change 1+ import { Icon } from '@rocket.chat/fuselage' ;
2+ import { useTranslation } from 'react-i18next' ;
3+
4+ const InvitationBadge = ( ) => {
5+ const { t } = useTranslation ( ) ;
6+
7+ return (
8+ < Icon
9+ role = 'status'
10+ name = 'mail'
11+ mbs = { 2 }
12+ size = 'x20'
13+ color = 'info'
14+ title = { t ( 'Message_request' ) }
15+ aria-hidden = 'false'
16+ aria-label = { t ( 'Message_request' ) }
17+ />
18+ ) ;
19+ } ;
20+
21+ export default InvitationBadge ;
Original file line number Diff line number Diff line change @@ -58,4 +58,16 @@ describe('SidebarItemBadges', () => {
5858
5959 expect ( screen . queryByTestId ( 'omnichannel-badges' ) ) . not . toBeInTheDocument ( ) ;
6060 } ) ;
61+
62+ it ( 'should render InvitationBadge when subscription has status INVITED' , ( ) => {
63+ render ( < SidebarItemBadges room = { createRoomWithSubscription ( { status : 'INVITED' } ) } /> , { wrapper : appRoot } ) ;
64+
65+ expect ( screen . getByRole ( 'status' , { name : 'Message request' } ) ) . toBeInTheDocument ( ) ;
66+ } ) ;
67+
68+ it ( 'should not render InvitationBadge when subscription does not have status INVITED' , ( ) => {
69+ render ( < SidebarItemBadges room = { createRoomWithSubscription ( ) } /> , { wrapper : appRoot } ) ;
70+
71+ expect ( screen . queryByRole ( 'status' , { name : 'Message request' } ) ) . not . toBeInTheDocument ( ) ;
72+ } ) ;
6173} ) ;
Original file line number Diff line number Diff line change 11import type { IRoom , ISubscription } from '@rocket.chat/core-typings' ;
2- import { isOmnichannelRoom } from '@rocket.chat/core-typings' ;
2+ import { isInviteSubscription , isOmnichannelRoom } from '@rocket.chat/core-typings' ;
33import { Margins } from '@rocket.chat/fuselage' ;
44
5+ import InvitationBadge from './InvitationBadge' ;
56import OmnichannelBadges from './OmnichannelBadges' ;
67import UnreadBadge from './UnreadBadge' ;
78import { useUnreadDisplay } from '../hooks/useUnreadDisplay' ;
@@ -19,6 +20,8 @@ const SidebarItemBadges = ({ room, roomTitle }: SidebarItemBadgesProps) => {
1920 { showUnread && < UnreadBadge title = { unreadTitle } roomTitle = { roomTitle } variant = { unreadVariant } total = { unreadCount . total } /> }
2021
2122 { isOmnichannelRoom ( room ) && < OmnichannelBadges room = { room } /> }
23+
24+ { isInviteSubscription ( room ) && < InvitationBadge /> }
2225 </ Margins >
2326 ) ;
2427} ;
Original file line number Diff line number Diff line change 1+ import { Icon } from '@rocket.chat/fuselage' ;
2+ import { useTranslation } from 'react-i18next' ;
3+
4+ const InvitationBadge = ( ) => {
5+ const { t } = useTranslation ( ) ;
6+
7+ return (
8+ < Icon
9+ role = 'status'
10+ name = 'mail'
11+ mbs = { 2 }
12+ size = 'x20'
13+ color = 'info'
14+ title = { t ( 'Message_request' ) }
15+ aria-hidden = 'false'
16+ aria-label = { t ( 'Message_request' ) }
17+ />
18+ ) ;
19+ } ;
20+
21+ export default InvitationBadge ;
Original file line number Diff line number Diff line change @@ -50,4 +50,16 @@ describe('SidebarItemBadges', () => {
5050
5151 expect ( screen . queryByTestId ( 'omnichannel-badges' ) ) . not . toBeInTheDocument ( ) ;
5252 } ) ;
53+
54+ it ( 'should render InvitationBadge when subscription has status INVITED' , ( ) => {
55+ render ( < SidebarItemBadges room = { createFakeSubscription ( { status : 'INVITED' } ) } /> , { wrapper : appRoot } ) ;
56+
57+ expect ( screen . getByRole ( 'status' , { name : 'Message request' } ) ) . toBeInTheDocument ( ) ;
58+ } ) ;
59+
60+ it ( 'should not render InvitationBadge when subscription does not have status INVITED' , ( ) => {
61+ render ( < SidebarItemBadges room = { createFakeSubscription ( ) } /> , { wrapper : appRoot } ) ;
62+
63+ expect ( screen . queryByRole ( 'status' , { name : 'Message request' } ) ) . not . toBeInTheDocument ( ) ;
64+ } ) ;
5365} ) ;
Original file line number Diff line number Diff line change 1- import { isOmnichannelRoom } from '@rocket.chat/core-typings' ;
1+ import { isInviteSubscription , isOmnichannelRoom } from '@rocket.chat/core-typings' ;
22import type { SubscriptionWithRoom } from '@rocket.chat/ui-contexts' ;
33
4+ import InvitationBadge from './InvitationBadge' ;
45import OmnichannelBadges from './OmnichannelBadges' ;
56import UnreadBadge from './UnreadBadge' ;
67import { useUnreadDisplay } from '../hooks/useUnreadDisplay' ;
@@ -18,6 +19,8 @@ const SidebarItemBadges = ({ room, roomTitle }: SidebarItemBadgesProps) => {
1819 { showUnread && < UnreadBadge title = { unreadTitle } roomTitle = { roomTitle } variant = { unreadVariant } total = { unreadCount . total } /> }
1920
2021 { isOmnichannelRoom ( room ) && < OmnichannelBadges room = { room } /> }
22+
23+ { isInviteSubscription ( room ) && < InvitationBadge /> }
2124 </ >
2225 ) ;
2326} ;
Original file line number Diff line number Diff line change 1+ import { SidebarV2ItemBadge } from '@rocket.chat/fuselage' ;
2+ import { useTranslation } from 'react-i18next' ;
3+
4+ type UnreadBadgeProps = {
5+ title : string ;
6+ roomTitle ?: string ;
7+ variant : 'primary' | 'warning' | 'danger' | 'secondary' ;
8+ total : number ;
9+ } ;
10+
11+ const UnreadBadge = ( { title, variant, total, roomTitle } : UnreadBadgeProps ) => {
12+ const { t } = useTranslation ( ) ;
13+
14+ return (
15+ < SidebarV2ItemBadge
16+ variant = { variant }
17+ title = { title }
18+ role = 'status'
19+ aria-label = { t ( '__unreadTitle__from__roomTitle__' , { unreadTitle : title , roomTitle } ) }
20+ >
21+ < span aria-hidden > { total } </ span >
22+ </ SidebarV2ItemBadge >
23+ ) ;
24+ } ;
25+
26+ export default UnreadBadge ;
Original file line number Diff line number Diff line change 1+ import { Icon } from '@rocket.chat/fuselage' ;
2+ import { useTranslation } from 'react-i18next' ;
3+
4+ const InvitationBadge = ( ) => {
5+ const { t } = useTranslation ( ) ;
6+
7+ return (
8+ < Icon
9+ role = 'status'
10+ name = 'mail'
11+ mbs = { 2 }
12+ size = 'x20'
13+ color = 'info'
14+ title = { t ( 'Message_request' ) }
15+ aria-hidden = 'false'
16+ aria-label = { t ( 'Message_request' ) }
17+ />
18+ ) ;
19+ } ;
20+
21+ export default InvitationBadge ;
Original file line number Diff line number Diff line change @@ -33,4 +33,16 @@ describe('SidebarItemBadges', () => {
3333
3434 expect ( screen . queryByRole ( 'status' , { name : 'Test Room' } ) ) . not . toBeInTheDocument ( ) ;
3535 } ) ;
36+
37+ it ( 'should render InvitationBadge when subscription has status INVITED' , ( ) => {
38+ render ( < SidebarItemBadges room = { createFakeSubscription ( { status : 'INVITED' } ) } /> , { wrapper : appRoot } ) ;
39+
40+ expect ( screen . getByRole ( 'status' , { name : 'Message request' } ) ) . toBeInTheDocument ( ) ;
41+ } ) ;
42+
43+ it ( 'should not render InvitationBadge when subscription does not have status INVITED' , ( ) => {
44+ render ( < SidebarItemBadges room = { createFakeSubscription ( ) } /> , { wrapper : appRoot } ) ;
45+
46+ expect ( screen . queryByRole ( 'status' , { name : 'Message request' } ) ) . not . toBeInTheDocument ( ) ;
47+ } ) ;
3648} ) ;
Original file line number Diff line number Diff line change 1+ import { isInviteSubscription } from '@rocket.chat/core-typings' ;
12import type { SubscriptionWithRoom } from '@rocket.chat/ui-contexts' ;
23
4+ import InvitationBadge from './InvitationBadge' ;
35import UnreadBadge from './UnreadBadge' ;
46import { useUnreadDisplay } from '../hooks/useUnreadDisplay' ;
57
@@ -11,7 +13,13 @@ type SidebarItemBadgesProps = {
1113const SidebarItemBadges = ( { room, roomTitle } : SidebarItemBadgesProps ) => {
1214 const { unreadCount, unreadTitle, unreadVariant, showUnread } = useUnreadDisplay ( room ) ;
1315
14- return < > { showUnread && < UnreadBadge title = { unreadTitle } roomTitle = { roomTitle } variant = { unreadVariant } total = { unreadCount . total } /> } </ > ;
16+ return (
17+ < >
18+ { showUnread && < UnreadBadge title = { unreadTitle } roomTitle = { roomTitle } variant = { unreadVariant } total = { unreadCount . total } /> }
19+
20+ { isInviteSubscription ( room ) && < InvitationBadge /> }
21+ </ >
22+ ) ;
1523} ;
1624
1725export default SidebarItemBadges ;
You can’t perform that action at this time.
0 commit comments