Skip to content

Commit 3c28676

Browse files
fix: missing room type translation on useEncryptedRoomDescription (RocketChat#36799)
1 parent 4225961 commit 3c28676

5 files changed

Lines changed: 92 additions & 11 deletions

File tree

.changeset/new-poems-compare.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@rocket.chat/meteor": patch
3+
---
4+
5+
Fixes a missing translation on the create channel/team modal

apps/meteor/client/NavBarV2/NavBarPagesGroup/actions/useEncryptedRoomDescription.spec.tsx

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,80 @@ describe.each([
5454
});
5555
});
5656
});
57+
58+
describe('useEncryptedRoomDescription, Portuguese (pt-BR)', () => {
59+
it('returns "Encrypted_not_available" when channel is not private and E2E is enabled,', () => {
60+
const { result } = renderHook(() => useEncryptedRoomDescription('channel'), {
61+
wrapper: mockAppRoot()
62+
.withSetting('E2E_Enable', true)
63+
.withDefaultLanguage('pt-BR')
64+
.withTranslations('pt-BR', 'core', {
65+
Encrypted_not_available: 'Indisponível para {{roomType}} público',
66+
channel: 'canal',
67+
team: 'equipe',
68+
})
69+
.build(),
70+
});
71+
const describe = result.current;
72+
73+
expect(describe({ isPrivate: false, encrypted: false })).toBe('Indisponível para canal público');
74+
});
75+
76+
it('returns "Encrypted_not_available" when team is not private and E2E is enabled,', () => {
77+
const { result } = renderHook(() => useEncryptedRoomDescription('team'), {
78+
wrapper: mockAppRoot()
79+
.withSetting('E2E_Enable', true)
80+
.withDefaultLanguage('pt-BR')
81+
.withTranslations('pt-BR', 'core', {
82+
Encrypted_not_available: 'Indisponível para {{roomType}} público',
83+
channel: 'canal',
84+
team: 'equipe',
85+
})
86+
.build(),
87+
});
88+
const describe = result.current;
89+
90+
expect(describe({ isPrivate: false, encrypted: false })).toBe('Indisponível para equipe público');
91+
});
92+
93+
it('returns "Encrypted_messages" when channel is private and encrypted are true and E2E is enabled', () => {
94+
const { result } = renderHook(() => useEncryptedRoomDescription('channel'), {
95+
wrapper: mockAppRoot()
96+
.withSetting('E2E_Enable', true)
97+
.withDefaultLanguage('pt-BR')
98+
.withTranslations('pt-BR', 'core', {
99+
// TODO: Improve the portuguese translation with a way to captalize the room type for it to be in the start of the sentence
100+
Encrypted_messages:
101+
'Criptografado de ponta a ponta {{roomType}}. A pesquisa não funcionará com {{roomType}} criptografado e as notificações podem não mostrar o conteúdo das mensagens.',
102+
team: 'equipe',
103+
channel: 'canal',
104+
})
105+
.build(),
106+
});
107+
const describe = result.current;
108+
109+
expect(describe({ isPrivate: true, encrypted: true })).toBe(
110+
'Criptografado de ponta a ponta canal. A pesquisa não funcionará com canal criptografado e as notificações podem não mostrar o conteúdo das mensagens.',
111+
);
112+
});
113+
114+
it('returns "Encrypted_messages" when team is private and encrypted are true and E2E is enabled', () => {
115+
const { result } = renderHook(() => useEncryptedRoomDescription('team'), {
116+
wrapper: mockAppRoot()
117+
.withSetting('E2E_Enable', true)
118+
.withTranslations('pt-BR', 'core', {
119+
Encrypted_messages:
120+
'Criptografado de ponta a ponta {{roomType}}. A pesquisa não funcionará com {{roomType}} criptografado e as notificações podem não mostrar o conteúdo das mensagens.',
121+
channel: 'canal',
122+
team: 'equipe',
123+
})
124+
.withDefaultLanguage('pt-BR')
125+
.build(),
126+
});
127+
const describe = result.current;
128+
129+
expect(describe({ isPrivate: true, encrypted: true })).toBe(
130+
'Criptografado de ponta a ponta equipe. A pesquisa não funcionará com equipe criptografado e as notificações podem não mostrar o conteúdo das mensagens.',
131+
);
132+
});
133+
});

apps/meteor/client/NavBarV2/NavBarPagesGroup/actions/useEncryptedRoomDescription.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useSetting } from '@rocket.chat/ui-contexts';
22
import { useTranslation } from 'react-i18next';
33

4-
export const useEncryptedRoomDescription = (roomType: 'channel' | 'team') => {
4+
export const useEncryptedRoomDescription = (roomType: 'channel' | 'team' | 'discussion') => {
55
const { t } = useTranslation();
66
const e2eEnabled = useSetting('E2E_Enable');
77

@@ -10,10 +10,10 @@ export const useEncryptedRoomDescription = (roomType: 'channel' | 'team') => {
1010
return t('Not_available_for_this_workspace');
1111
}
1212
if (!isPrivate) {
13-
return t('Encrypted_not_available', { roomType });
13+
return t('Encrypted_not_available', { roomType: t(roomType) });
1414
}
1515
if (encrypted) {
16-
return t('Encrypted_messages', { roomType });
16+
return t('Encrypted_messages', { roomType: t(roomType) });
1717
}
1818
return t('Encrypted_messages_false');
1919
};

apps/meteor/client/components/CreateDiscussion/CreateDiscussion.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import { goToRoomById } from '../../lib/utils/goToRoomById';
3030
import RoomAutoComplete from '../RoomAutoComplete';
3131
import UserAutoCompleteMultiple from '../UserAutoCompleteMultiple';
3232
import DefaultParentRoomField from './DefaultParentRoomField';
33+
import { useEncryptedRoomDescription } from '../../NavBarV2/NavBarPagesGroup/actions/useEncryptedRoomDescription';
3334

3435
type CreateDiscussionFormValues = {
3536
name: string;
@@ -91,6 +92,8 @@ const CreateDiscussion = ({ onClose, defaultParentRoom, parentMessageId, nameSug
9192
});
9293
};
9394

95+
const getEncryptedHint = useEncryptedRoomDescription('discussion');
96+
9497
const parentRoomId = useId();
9598
const encryptedId = useId();
9699
const discussionNameId = useId();
@@ -242,11 +245,7 @@ const CreateDiscussion = ({ onClose, defaultParentRoom, parentMessageId, nameSug
242245
render={({ field: { value, ...field } }) => <ToggleSwitch id={encryptedId} {...field} checked={value} />}
243246
/>
244247
</FieldRow>
245-
{encrypted ? (
246-
<FieldHint id={`${encryptedId}-hint`}>{t('Encrypted_messages', { roomType: 'discussion' })}</FieldHint>
247-
) : (
248-
<FieldHint id={`${encryptedId}-hint`}>{t('Encrypted_messages_false')}</FieldHint>
249-
)}
248+
<FieldHint id={`${encryptedId}-hint`}>{getEncryptedHint({ isPrivate: true, encrypted })}</FieldHint>
250249
</Field>
251250
</FieldGroup>
252251
</ModalContent>

apps/meteor/client/sidebar/header/hooks/useEncryptedRoomDescription.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useSetting } from '@rocket.chat/ui-contexts';
22
import { useTranslation } from 'react-i18next';
33

4-
export const useEncryptedRoomDescription = (roomType: 'channel' | 'team') => {
4+
export const useEncryptedRoomDescription = (roomType: 'channel' | 'team' | 'discussion') => {
55
const { t } = useTranslation();
66
const e2eEnabled = useSetting('E2E_Enable');
77

@@ -10,10 +10,10 @@ export const useEncryptedRoomDescription = (roomType: 'channel' | 'team') => {
1010
return t('Not_available_for_this_workspace');
1111
}
1212
if (!isPrivate) {
13-
return t('Encrypted_not_available', { roomType });
13+
return t('Encrypted_not_available', { roomType: t(roomType) });
1414
}
1515
if (encrypted) {
16-
return t('Encrypted_messages', { roomType });
16+
return t('Encrypted_messages', { roomType: t(roomType) });
1717
}
1818
return t('Encrypted_messages_false');
1919
};

0 commit comments

Comments
 (0)