diff --git a/apps/meteor/client/hooks/roomActions/useE2EERoomAction.ts b/apps/meteor/client/hooks/roomActions/useE2EERoomAction.ts index e1c3126985ae..4bfb2ed23370 100644 --- a/apps/meteor/client/hooks/roomActions/useE2EERoomAction.ts +++ b/apps/meteor/client/hooks/roomActions/useE2EERoomAction.ts @@ -5,13 +5,15 @@ import { useCallback, useMemo } from 'react'; import { useTranslation } from 'react-i18next'; import { e2e } from '../../../app/e2e/client/rocketchat.e2e'; -import { useRoom } from '../../views/room/contexts/RoomContext'; +import { dispatchToastMessage } from '../../lib/toast'; +import { useRoom, useRoomSubscription } from '../../views/room/contexts/RoomContext'; import type { RoomToolboxActionConfig } from '../../views/room/contexts/RoomToolboxContext'; import { useReactiveValue } from '../useReactiveValue'; export const useE2EERoomAction = () => { const enabled = useSetting('E2E_Enable', false); const room = useRoom(); + const subscription = useRoomSubscription(); const readyToEncrypt = useReactiveValue(useCallback(() => e2e.isReady(), [])) || room.encrypted; const permittedToToggleEncryption = usePermission('toggle-room-e2e-encryption', room._id); const permittedToEditRoom = usePermission('edit-room', room._id); @@ -21,8 +23,20 @@ export const useE2EERoomAction = () => { const toggleE2E = useEndpoint('POST', '/v1/rooms.saveRoomSettings'); - const action = useMutableCallback(() => { - void toggleE2E({ rid: room._id, encrypted: !room.encrypted }); + const action = useMutableCallback(async () => { + const { success } = await toggleE2E({ rid: room._id, encrypted: !room.encrypted }); + if (!success) { + return; + } + + dispatchToastMessage({ + type: 'success', + message: t(room.encrypted ? 'E2E_Encryption_disabled_for_room' : 'E2E_Encryption_enabled_for_room', { roomName: room.name }), + }); + + if (subscription?.autoTranslate) { + dispatchToastMessage({ type: 'success', message: t('AutoTranslate_Disabled_for_room', { roomName: room.name }) }); + } }); const enabledOnRoom = !!room.encrypted; diff --git a/apps/meteor/client/views/room/contextualBar/AutoTranslate/AutoTranslateWithData.tsx b/apps/meteor/client/views/room/contextualBar/AutoTranslate/AutoTranslateWithData.tsx index 6bfc4ff03a80..8d589ddb6edc 100644 --- a/apps/meteor/client/views/room/contextualBar/AutoTranslate/AutoTranslateWithData.tsx +++ b/apps/meteor/client/views/room/contextualBar/AutoTranslate/AutoTranslateWithData.tsx @@ -2,9 +2,11 @@ import { useMutableCallback } from '@rocket.chat/fuselage-hooks'; import { useLanguage } from '@rocket.chat/ui-contexts'; import type { ReactElement } from 'react'; import React, { useMemo, useEffect, useState, memo } from 'react'; +import { useTranslation } from 'react-i18next'; import { useEndpointAction } from '../../../../hooks/useEndpointAction'; import { useEndpointData } from '../../../../hooks/useEndpointData'; +import { dispatchToastMessage } from '../../../../lib/toast'; import { useRoom, useRoomSubscription } from '../../contexts/RoomContext'; import { useRoomToolbox } from '../../contexts/RoomToolboxContext'; import AutoTranslate from './AutoTranslate'; @@ -16,10 +18,12 @@ const AutoTranslateWithData = (): ReactElement => { const userLanguage = useLanguage(); const [currentLanguage, setCurrentLanguage] = useState(subscription?.autoTranslateLanguage ?? ''); const saveSettings = useEndpointAction('POST', '/v1/autotranslate.saveSettings'); + const { t } = useTranslation(); const { value: translateData } = useEndpointData('/v1/autotranslate.getSupportedLanguages', { params: useMemo(() => ({ targetLanguage: userLanguage }), [userLanguage]), }); + const languagesDict = translateData ? Object.fromEntries(translateData.languages.map((lang) => [lang.language, lang.name])) : {}; const handleChangeLanguage = useMutableCallback((value) => { setCurrentLanguage(value); @@ -29,6 +33,10 @@ const AutoTranslateWithData = (): ReactElement => { field: 'autoTranslateLanguage', value, }); + dispatchToastMessage({ + type: 'success', + message: t('AutoTranslate_to_language_enabled_for_room', { language: languagesDict[value], roomName: room.name }), + }); }); const handleSwitch = useMutableCallback((event) => { @@ -37,6 +45,13 @@ const AutoTranslateWithData = (): ReactElement => { field: 'autoTranslate', value: event.target.checked, }); + dispatchToastMessage({ + type: 'success', + message: t(event.target.checked ? 'AutoTranslate_to_language_enabled_for_room' : 'AutoTranslate_Disabled_for_room', { + language: languagesDict[currentLanguage], + roomName: room.name, + }), + }); }); useEffect(() => { diff --git a/apps/meteor/packages/rocketchat-i18n/i18n/en.i18n.json b/apps/meteor/packages/rocketchat-i18n/i18n/en.i18n.json index c0cf327dbb39..889cd623f13d 100644 --- a/apps/meteor/packages/rocketchat-i18n/i18n/en.i18n.json +++ b/apps/meteor/packages/rocketchat-i18n/i18n/en.i18n.json @@ -713,12 +713,14 @@ "AutoTranslate_APIKey": "API Key", "AutoTranslate_Change_Language_Description": "Changing the auto-translate language does not translate previous messages.", "AutoTranslate_DeepL": "DeepL", + "AutoTranslate_Disabled_for_room": "Auto-translate disabled for #{{roomName}}", "AutoTranslate_Enabled": "Enable Auto-Translate", "AutoTranslate_Enabled_Description": "Enabling auto-translation will allow people with the `auto-translate` permission to have all messages automatically translated into their selected language. Fees may apply.", "AutoTranslate_Google": "Google", "AutoTranslate_Microsoft": "Microsoft", "AutoTranslate_Microsoft_API_Key": "Ocp-Apim-Subscription-Key", "AutoTranslate_ServiceProvider": "Service Provider", + "AutoTranslate_to_language_enabled_for_room": "Auto-translate to {{language}} enabled for #{{roomName}}", "Available": "Available", "Available_agents": "Available agents", "Available_departments": "Available Departments", @@ -1727,6 +1729,8 @@ "Markdown_Marked_Tables": "Enable Marked Tables", "duplicated-account": "Duplicated account", "E2E Encryption": "E2E Encryption", + "E2E_Encryption_enabled_for_room": "End-to-end encryption enabled for #{{roomName}}", + "E2E_Encryption_disabled_for_room": "End-to-end encryption disabled for #{{roomName}}", "Markdown_Parser": "Markdown Parser", "Markdown_SupportSchemesForLink": "Markdown Support Schemes for Link", "E2E Encryption_Description": "Keep conversations private, ensuring only the sender and intended recipients are able to read them.", diff --git a/apps/meteor/packages/rocketchat-i18n/i18n/pt-BR.i18n.json b/apps/meteor/packages/rocketchat-i18n/i18n/pt-BR.i18n.json index 423d43cdece3..fc27020a9f02 100644 --- a/apps/meteor/packages/rocketchat-i18n/i18n/pt-BR.i18n.json +++ b/apps/meteor/packages/rocketchat-i18n/i18n/pt-BR.i18n.json @@ -633,12 +633,14 @@ "AutoTranslate_APIKey": "Key da API", "AutoTranslate_Change_Language_Description": "Alterar o idioma de tradução automática não traduz mensagens anteriores.", "AutoTranslate_DeepL": "DeepL", + "AutoTranslate_Disabled_for_room": "Tradução automática desabilitada para #{{roomName}}", "AutoTranslate_Enabled": "Habilitar tradução automática", "AutoTranslate_Enabled_Description": "Habilitar a tradução automática implicará em permitir que as pessoas com a permissão `auto-translate` tenham todas as suas mensagens automaticamente traduzidas para seu idioma. Taxas podem ser cobradas.", "AutoTranslate_Google": "Google", "AutoTranslate_Microsoft": "Microsoft", "AutoTranslate_Microsoft_API_Key": "Ocp-Apim-Subscription-Key", "AutoTranslate_ServiceProvider": "Provedor de serviço", + "AutoTranslate_to_language_enabled_for_room": "Tradução automática para {{language}} habilitada para #{{roomName}}", "Available": "Disponível", "Available_agents": "Agentes disponíveis", "Available_departments": "Departamentos disponíveis", @@ -1517,6 +1519,7 @@ "Markdown_Marked_Tables": "Ativar tabelas marcadas", "duplicated-account": "Conta duplicada", "E2E Encryption": "Criptografia E2E", + "E2E_Encryption_enabled_for_room": "Criptografia E2E habilitada para #{{roomName}}", "Markdown_Parser": "Parser de marcação", "Markdown_SupportSchemesForLink": "Esquemas de links compatíveis com marcação", "Markdown_SupportSchemesForLink_Description": "Lista de esquemas permitidos separados por vírgulas",