Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/new-poems-compare.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

Fixes a missing translation on the create channel/team modal
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,80 @@ describe.each([
});
});
});

describe('useEncryptedRoomDescription, Portuguese (pt-BR)', () => {
it('returns "Encrypted_not_available" when channel is not private and E2E is enabled,', () => {
const { result } = renderHook(() => useEncryptedRoomDescription('channel'), {
wrapper: mockAppRoot()
.withSetting('E2E_Enable', true)
.withDefaultLanguage('pt-BR')
.withTranslations('pt-BR', 'core', {
Encrypted_not_available: 'Indisponível para {{roomType}} público',
channel: 'canal',
team: 'equipe',
})
.build(),
});
const describe = result.current;

expect(describe({ isPrivate: false, encrypted: false })).toBe('Indisponível para canal público');
});

it('returns "Encrypted_not_available" when team is not private and E2E is enabled,', () => {
const { result } = renderHook(() => useEncryptedRoomDescription('team'), {
wrapper: mockAppRoot()
.withSetting('E2E_Enable', true)
.withDefaultLanguage('pt-BR')
.withTranslations('pt-BR', 'core', {
Encrypted_not_available: 'Indisponível para {{roomType}} público',
channel: 'canal',
team: 'equipe',
})
.build(),
});
const describe = result.current;

expect(describe({ isPrivate: false, encrypted: false })).toBe('Indisponível para equipe público');
});

it('returns "Encrypted_messages" when channel is private and encrypted are true and E2E is enabled', () => {
const { result } = renderHook(() => useEncryptedRoomDescription('channel'), {
wrapper: mockAppRoot()
.withSetting('E2E_Enable', true)
.withDefaultLanguage('pt-BR')
.withTranslations('pt-BR', 'core', {
// TODO: Improve the portuguese translation with a way to captalize the room type for it to be in the start of the sentence
Encrypted_messages:
'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.',
team: 'equipe',
channel: 'canal',
})
.build(),
});
const describe = result.current;

expect(describe({ isPrivate: true, encrypted: true })).toBe(
'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.',
);
});

it('returns "Encrypted_messages" when team is private and encrypted are true and E2E is enabled', () => {
const { result } = renderHook(() => useEncryptedRoomDescription('team'), {
wrapper: mockAppRoot()
.withSetting('E2E_Enable', true)
.withTranslations('pt-BR', 'core', {
Encrypted_messages:
'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.',
channel: 'canal',
team: 'equipe',
})
.withDefaultLanguage('pt-BR')
.build(),
});
const describe = result.current;

expect(describe({ isPrivate: true, encrypted: true })).toBe(
'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.',
);
});
});
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useSetting } from '@rocket.chat/ui-contexts';
import { useTranslation } from 'react-i18next';

export const useEncryptedRoomDescription = (roomType: 'channel' | 'team') => {
export const useEncryptedRoomDescription = (roomType: 'channel' | 'team' | 'discussion') => {
const { t } = useTranslation();
const e2eEnabled = useSetting('E2E_Enable');

Expand All @@ -10,10 +10,10 @@ export const useEncryptedRoomDescription = (roomType: 'channel' | 'team') => {
return t('Not_available_for_this_workspace');
}
if (!isPrivate) {
return t('Encrypted_not_available', { roomType });
return t('Encrypted_not_available', { roomType: t(roomType) });
}
if (encrypted) {
return t('Encrypted_messages', { roomType });
return t('Encrypted_messages', { roomType: t(roomType) });
}
return t('Encrypted_messages_false');
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { goToRoomById } from '../../lib/utils/goToRoomById';
import RoomAutoComplete from '../RoomAutoComplete';
import UserAutoCompleteMultiple from '../UserAutoCompleteMultiple';
import DefaultParentRoomField from './DefaultParentRoomField';
import { useEncryptedRoomDescription } from '../../NavBarV2/NavBarPagesGroup/actions/useEncryptedRoomDescription';

type CreateDiscussionFormValues = {
name: string;
Expand Down Expand Up @@ -91,6 +92,8 @@ const CreateDiscussion = ({ onClose, defaultParentRoom, parentMessageId, nameSug
});
};

const getEncryptedHint = useEncryptedRoomDescription('discussion');

const parentRoomId = useId();
const encryptedId = useId();
const discussionNameId = useId();
Expand Down Expand Up @@ -242,11 +245,7 @@ const CreateDiscussion = ({ onClose, defaultParentRoom, parentMessageId, nameSug
render={({ field: { value, ...field } }) => <ToggleSwitch id={encryptedId} {...field} checked={value} />}
/>
</FieldRow>
{encrypted ? (
<FieldHint id={`${encryptedId}-hint`}>{t('Encrypted_messages', { roomType: 'discussion' })}</FieldHint>
) : (
<FieldHint id={`${encryptedId}-hint`}>{t('Encrypted_messages_false')}</FieldHint>
)}
<FieldHint id={`${encryptedId}-hint`}>{getEncryptedHint({ isPrivate: true, encrypted })}</FieldHint>
</Field>
</FieldGroup>
</ModalContent>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useSetting } from '@rocket.chat/ui-contexts';
import { useTranslation } from 'react-i18next';

export const useEncryptedRoomDescription = (roomType: 'channel' | 'team') => {
export const useEncryptedRoomDescription = (roomType: 'channel' | 'team' | 'discussion') => {
const { t } = useTranslation();
const e2eEnabled = useSetting('E2E_Enable');

Expand All @@ -10,10 +10,10 @@ export const useEncryptedRoomDescription = (roomType: 'channel' | 'team') => {
return t('Not_available_for_this_workspace');
}
if (!isPrivate) {
return t('Encrypted_not_available', { roomType });
return t('Encrypted_not_available', { roomType: t(roomType) });
}
if (encrypted) {
return t('Encrypted_messages', { roomType });
return t('Encrypted_messages', { roomType: t(roomType) });
}
return t('Encrypted_messages_false');
};
Expand Down
Loading