Skip to content

Commit 260950f

Browse files
chore: add new icons to abac rooms (RocketChat#37424)
1 parent b27e9fb commit 260950f

12 files changed

Lines changed: 108 additions & 126 deletions

File tree

apps/meteor/client/components/ABAC/ABACHeaderTag.spec.tsx

Lines changed: 0 additions & 62 deletions
This file was deleted.

apps/meteor/client/components/ABAC/ABACHeaderTag.tsx

Lines changed: 0 additions & 28 deletions
This file was deleted.

apps/meteor/client/components/ABAC/__snapshots__/ABACHeaderTag.spec.tsx.snap

Lines changed: 0 additions & 26 deletions
This file was deleted.
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
import { useRoomIcon } from './useRoomIcon';
2+
import { createFakeRoom } from '../../tests/mocks/data';
3+
4+
const mockRooms = {
5+
public: createFakeRoom({
6+
t: 'c',
7+
name: 'public',
8+
teamMain: false,
9+
// @ts-expect-error TODO: Implement ABAC attributes in rooms
10+
abacAttributes: false,
11+
}),
12+
private: createFakeRoom({
13+
t: 'p',
14+
name: 'private',
15+
teamMain: false,
16+
// @ts-expect-error TODO: Implement ABAC attributes in rooms
17+
abacAttributes: false,
18+
}),
19+
team: createFakeRoom({
20+
t: 'c',
21+
name: 'team',
22+
teamMain: true,
23+
// @ts-expect-error TODO: Implement ABAC attributes in rooms
24+
abacAttributes: false,
25+
}),
26+
direct: createFakeRoom({
27+
t: 'd',
28+
name: 'direct',
29+
teamMain: false,
30+
// @ts-expect-error TODO: Implement ABAC attributes in rooms
31+
abacAttributes: false,
32+
}),
33+
directMultiple: createFakeRoom({
34+
t: 'd',
35+
name: 'direct-multiple',
36+
teamMain: false,
37+
// @ts-expect-error TODO: Implement ABAC attributes in rooms
38+
abacAttributes: false,
39+
uids: ['user1', 'user2', 'user3'],
40+
}),
41+
federated: createFakeRoom({
42+
t: 'c',
43+
name: 'federated',
44+
teamMain: false,
45+
// @ts-expect-error TODO: Implement ABAC attributes in rooms
46+
abacAttributes: false,
47+
federated: true,
48+
}),
49+
abacRoom: createFakeRoom({
50+
t: 'c',
51+
name: 'abac-room',
52+
teamMain: false,
53+
// @ts-expect-error TODO: Implement ABAC attributes in rooms
54+
abacAttributes: true,
55+
}),
56+
abacTeamRoom: createFakeRoom({
57+
t: 'c',
58+
name: 'abac-team-room',
59+
teamMain: true,
60+
// @ts-expect-error TODO: Implement ABAC attributes in rooms
61+
abacAttributes: true,
62+
}),
63+
};
64+
65+
const expectedResults = {
66+
public: { name: 'hash' },
67+
private: { name: 'hashtag-lock' },
68+
team: { name: 'team' },
69+
federated: { name: 'globe' },
70+
abacRoom: { name: 'hash-shield' },
71+
abacTeamRoom: { name: 'team-shield' },
72+
direct: { name: 'at' },
73+
directMultiple: { name: 'balloon' },
74+
};
75+
76+
describe('useRoomIcon', () => {
77+
it('should return the correct icon for each room', () => {
78+
Object.entries(mockRooms).forEach(([key, room]) => {
79+
const result = useRoomIcon(room);
80+
expect(result).toEqual(expectedResults[key as keyof typeof expectedResults]);
81+
});
82+
});
83+
});

apps/meteor/client/hooks/useRoomIcon.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@ import { ReactiveUserStatus } from '../components/UserStatus';
88
export const useRoomIcon = (
99
room: Pick<IRoom, 't' | 'prid' | 'teamMain' | 'uids' | 'u'>,
1010
): ComponentProps<typeof Icon> | ReactElement | null => {
11+
// @ts-expect-error TODO: Implement ABAC attributes in rooms
12+
if (room.abacAttributes) {
13+
if (room.teamMain) {
14+
return { name: 'team-shield' };
15+
}
16+
return { name: 'hash-shield' };
17+
}
18+
1119
if (isRoomFederated(room)) {
1220
return { name: 'globe' };
1321
}

apps/meteor/client/lib/rooms/roomTypes/private.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,14 @@ roomCoordinator.add(
8282
},
8383

8484
getIcon(room) {
85+
// @ts-expect-error TODO: Implement ABAC attributes in rooms
86+
if (room.abacAttributes) {
87+
if (room.teamMain) {
88+
return 'team-shield';
89+
}
90+
return 'hash-shield';
91+
}
92+
8593
if (room.prid) {
8694
return 'discussion';
8795
}

apps/meteor/client/views/room/Header/RoomHeader.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import RoomToolbox from './RoomToolbox';
1313
import Encrypted from './icons/Encrypted';
1414
import Favorite from './icons/Favorite';
1515
import Translate from './icons/Translate';
16-
import ABACHeaderTag from '../../../components/ABAC/ABACHeaderTag';
1716
import { Header, HeaderAvatar, HeaderContent, HeaderContentRow, HeaderSubtitle, HeaderToolbar } from '../../../components/Header';
1817
import MarkdownText from '../../../components/MarkdownText';
1918

@@ -51,7 +50,6 @@ const RoomHeader = ({ room, topic = '', slots = {}, roomToolbox }: RoomHeaderPro
5150
<Favorite room={room} />
5251
{room.prid && <ParentRoomWithData room={room} />}
5352
{room.teamId && !room.teamMain && <ParentTeam room={room} />}
54-
<ABACHeaderTag room={room} />
5553
{isRoomFederated(room) && <FederatedRoomOriginServer room={room} />}
5654
<Encrypted room={room} />
5755
<Translate room={room} />

apps/meteor/client/views/room/HeaderV2/RoomHeader.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import RoomTopic from './RoomTopic';
1212
import Encrypted from './icons/Encrypted';
1313
import Favorite from './icons/Favorite';
1414
import Translate from './icons/Translate';
15-
import ABACHeaderTag from '../../../components/ABAC/ABACHeaderTag';
1615
import { Header, HeaderContent, HeaderContentRow, HeaderToolbar } from '../../../components/Header';
1716

1817
export type RoomHeaderProps = {
@@ -44,7 +43,6 @@ const RoomHeader = ({ room, slots = {}, roomToolbox }: RoomHeaderProps) => {
4443
<HeaderContentRow>
4544
<RoomTitle room={room} />
4645
<Favorite room={room} />
47-
<ABACHeaderTag room={room} />
4846
{isRoomFederated(room) && <FederatedRoomOriginServer room={room} />}
4947
<Encrypted room={room} />
5048
<Translate room={room} />

apps/meteor/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@
264264
"@rocket.chat/gazzodown": "workspace:^",
265265
"@rocket.chat/http-router": "workspace:^",
266266
"@rocket.chat/i18n": "workspace:^",
267-
"@rocket.chat/icons": "~0.44.0",
267+
"@rocket.chat/icons": "~0.45.0",
268268
"@rocket.chat/instance-status": "workspace:^",
269269
"@rocket.chat/jwt": "workspace:^",
270270
"@rocket.chat/layout": "^0.33.1",

packages/i18n/src/locales/en.i18n.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,6 @@
7777
"A_new_owner_will_be_assigned_automatically_to_those__count__rooms__rooms__": "A new owner will be assigned automatically to those <bold>{{count}}</bold> rooms:<br/> {{rooms}}.",
7878
"A_secure_and_highly_private_self-managed_solution_for_conference_calls": "A secure and highly private self-managed solution for conference calls.",
7979
"A_workspace_admin_needs_to_install_and_configure_a_conference_call_app": "A workspace admin needs to install and configure a conference call app.",
80-
"ABAC_header_tag_title": "Only compliant users have access to attribute-based access controlled rooms.",
81-
"ABAC_header_tag": "ABAC",
8280
"Accept": "Accept",
8381
"Accept_Call": "Accept Call",
8482
"Accept_incoming_livechat_requests_even_if_there_are_no_online_agents": "Accept incoming omnichannel requests even if there are no online agents",

0 commit comments

Comments
 (0)