diff --git a/apps/meteor/client/lib/getRoomTypeTranslation.ts b/apps/meteor/client/lib/getRoomTypeTranslation.ts index 6a878257b416..e0c8556bac36 100644 --- a/apps/meteor/client/lib/getRoomTypeTranslation.ts +++ b/apps/meteor/client/lib/getRoomTypeTranslation.ts @@ -1,18 +1,39 @@ -import type { IRoom } from '@rocket.chat/core-typings'; +import { + isPublicRoom, + type IRoom, + isDirectMessageRoom, + isPrivateTeamRoom, + isPublicTeamRoom, + isPrivateDiscussion, + isPrivateRoom, +} from '@rocket.chat/core-typings'; import { t } from '../../app/utils/lib/i18n'; -export const getRoomTypeTranslation = (type: IRoom['t']) => { - switch (type) { - case 'c': - return t('Channel'); - case 'p': - return t('Private_Group'); - case 'd': - return t('Direct_Message'); - case 'l': - return t('Livechat'); - default: - return t('Room'); +export const getRoomTypeTranslation = (room: IRoom) => { + if (isPublicRoom(room)) { + return t('Channel'); } + + if (isPrivateDiscussion(room)) { + return t('Private_Discussion'); + } + + if (isPrivateRoom(room)) { + return t('Private_Group'); + } + + if (isDirectMessageRoom(room)) { + return t('Direct_Message'); + } + + if (isPrivateTeamRoom(room)) { + return t('Teams_Private_Team'); + } + + if (isPublicTeamRoom(room)) { + return t('Teams_Public_Team'); + } + + return t('Room'); }; diff --git a/apps/meteor/client/views/audit/components/tabs/RoomsTab.tsx b/apps/meteor/client/views/audit/components/tabs/RoomsTab.tsx index 6f416db4b329..3a3c0ab2c3d5 100644 --- a/apps/meteor/client/views/audit/components/tabs/RoomsTab.tsx +++ b/apps/meteor/client/views/audit/components/tabs/RoomsTab.tsx @@ -6,7 +6,6 @@ import type { UseFormReturn } from 'react-hook-form'; import { useController } from 'react-hook-form'; import RoomAutoComplete from '../../../../components/RoomAutoComplete'; -import { getRoomTypeTranslation } from '../../../../lib/getRoomTypeTranslation'; import type { AuditFields } from '../../hooks/useAuditForm'; type RoomsTabProps = { @@ -30,14 +29,8 @@ const RoomsTab = ({ form: { control }, setSelectedRoom }: RoomsTabProps) => { error={!!ridFieldState.error} placeholder={t('Channel_Name_Placeholder')} onChange={ridField.onChange} - renderRoomIcon={({ encrypted, type }) => - encrypted ? ( - - ) : null + renderRoomIcon={({ encrypted }) => + encrypted ? : null } /> diff --git a/apps/meteor/client/views/room/contextualBar/MessageSearchTab/components/MessageSearchForm.tsx b/apps/meteor/client/views/room/contextualBar/MessageSearchTab/components/MessageSearchForm.tsx index 053e90b8037c..9067c4c55ebf 100644 --- a/apps/meteor/client/views/room/contextualBar/MessageSearchTab/components/MessageSearchForm.tsx +++ b/apps/meteor/client/views/room/contextualBar/MessageSearchTab/components/MessageSearchForm.tsx @@ -82,7 +82,7 @@ const MessageSearchForm = ({ provider, onSearch }: MessageSearchFormProps) => { {room.encrypted && ( - {t('Encrypted_RoomType', { roomType: getRoomTypeTranslation(room.t).toLowerCase() })} + {t('Encrypted_RoomType', { roomType: getRoomTypeTranslation(room).toLowerCase() })} {t('Encrypted_content_cannot_be_searched')} )} diff --git a/packages/core-typings/src/IRoom.ts b/packages/core-typings/src/IRoom.ts index 38fe23bd3453..32bf438cd70d 100644 --- a/packages/core-typings/src/IRoom.ts +++ b/packages/core-typings/src/IRoom.ts @@ -129,6 +129,7 @@ export const isPrivateDiscussion = (room: Partial): room is IRoom => isDi export const isPublicDiscussion = (room: Partial): room is IRoom => isDiscussion(room) && room.t === 'c'; export const isPublicRoom = (room: Partial): room is IRoom => room.t === 'c'; +export const isPrivateRoom = (room: Partial): room is IRoom => room.t === 'p'; export interface IDirectMessageRoom extends Omit { t: 'd'; diff --git a/packages/i18n/src/locales/en.i18n.json b/packages/i18n/src/locales/en.i18n.json index f99d62b37ceb..c4b0c957a175 100644 --- a/packages/i18n/src/locales/en.i18n.json +++ b/packages/i18n/src/locales/en.i18n.json @@ -4241,6 +4241,7 @@ "Private_Channel": "Private Channel", "Private_Channels": "Private channels", "Private_Chats": "Private Chats", + "Private_Discussion": "Private discussion", "Private_Group": "Private Group", "Private_Groups": "Private groups", "Private_Groups_list": "List of Private Groups", @@ -6425,7 +6426,7 @@ "unread_messages_other": "{{count}} unread messages", "Encrypted_messages": "End-to-end encrypted {{roomType}}. Search will not work with encrypted {{roomType}} and notifications may not show the messages content.", "Encrypted_messages_false": "Messages are not encrypted", - "Encrypted_content_will_not_appear_search": "{{roomType}} encrypted, encrypted content will not appear in search", + "Encrypted_content_will_not_appear_search": "Room encrypted, encrypted content will not appear in search", "Encrypted_content_cannot_be_searched_and_audited": "Encrypted content cannot be searched and audited", "Encrypted_content_cannot_be_searched_and_audited_subtitle": "There are one or more encrypted rooms selected for audit.", "Not_available_for_broadcast": "Not available for broadcast {{roomType}}",