Skip to content

Commit

Permalink
Remove ability of key button to disable e2e encryption
Browse files Browse the repository at this point in the history
  • Loading branch information
KevLehman committed Oct 14, 2024
1 parent 1343dff commit f472f1f
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 51 deletions.
27 changes: 3 additions & 24 deletions apps/meteor/client/views/room/Header/icons/Encrypted.tsx
Original file line number Diff line number Diff line change
@@ -1,36 +1,15 @@
import type { IRoom } from '@rocket.chat/core-typings';
import { useMutableCallback } from '@rocket.chat/fuselage-hooks';
import colors from '@rocket.chat/fuselage-tokens/colors';
import { useSetting, usePermission, useTranslation, useEndpoint } from '@rocket.chat/ui-contexts';
import { useSetting, useTranslation } from '@rocket.chat/ui-contexts';
import React, { memo } from 'react';

import { HeaderState } from '../../../../components/Header';
import { dispatchToastMessage } from '../../../../lib/toast';

const Encrypted = ({ room }: { room: IRoom }) => {
const t = useTranslation();
const e2eEnabled = useSetting('E2E_Enable');
const toggleE2E = useEndpoint('POST', '/v1/rooms.saveRoomSettings');
const canToggleE2E = usePermission('toggle-room-e2e-encryption');
const encryptedLabel = canToggleE2E ? t('Encrypted_key_title') : t('Encrypted');
const handleE2EClick = useMutableCallback(async () => {
if (!canToggleE2E) {
return;
}

const { success } = await toggleE2E({ rid: room._id, encrypted: !room.encrypted });
if (!success) {
return;
}

dispatchToastMessage({
type: 'success',
message: t('E2E_Encryption_disabled_for_room', { roomName: room.name }),
});
});
return e2eEnabled && room?.encrypted ? (
<HeaderState title={encryptedLabel} icon='key' onClick={handleE2EClick} color={colors.g500} tiny />
) : null;
const encryptedLabel = t('Encrypted');
return e2eEnabled && room?.encrypted ? <HeaderState title={encryptedLabel} icon='key' color={colors.g500} tiny /> : null;
};

export default memo(Encrypted);
27 changes: 3 additions & 24 deletions apps/meteor/client/views/room/HeaderV2/icons/Encrypted.tsx
Original file line number Diff line number Diff line change
@@ -1,36 +1,15 @@
import type { IRoom } from '@rocket.chat/core-typings';
import { useMutableCallback } from '@rocket.chat/fuselage-hooks';
import colors from '@rocket.chat/fuselage-tokens/colors';
import { useSetting, usePermission, useTranslation, useEndpoint } from '@rocket.chat/ui-contexts';
import { useSetting, useTranslation } from '@rocket.chat/ui-contexts';
import React, { memo } from 'react';

import { HeaderState } from '../../../../components/Header';
import { dispatchToastMessage } from '../../../../lib/toast';

const Encrypted = ({ room }: { room: IRoom }) => {
const t = useTranslation();
const e2eEnabled = useSetting('E2E_Enable');
const toggleE2E = useEndpoint('POST', '/v1/rooms.saveRoomSettings');
const canToggleE2E = usePermission('toggle-room-e2e-encryption');
const encryptedLabel = canToggleE2E ? t('Encrypted_key_title') : t('Encrypted');
const handleE2EClick = useMutableCallback(async () => {
if (!canToggleE2E) {
return;
}

const { success } = await toggleE2E({ rid: room._id, encrypted: !room.encrypted });
if (!success) {
return;
}

dispatchToastMessage({
type: 'success',
message: t('E2E_Encryption_disabled_for_room', { roomName: room.name }),
});
});
return e2eEnabled && room?.encrypted ? (
<HeaderState title={encryptedLabel} icon='key' onClick={handleE2EClick} color={colors.g500} tiny />
) : null;
const encryptedLabel = t('Encrypted');
return e2eEnabled && room?.encrypted ? <HeaderState title={encryptedLabel} icon='key' color={colors.g500} tiny /> : null;
};

export default memo(Encrypted);
1 change: 0 additions & 1 deletion packages/i18n/src/locales/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -1974,7 +1974,6 @@
"Encrypted": "Encrypted",
"Encrypted_channel_Description": "Messages are end-to-end encrypted, search will not work and notifications may not show message content",
"Encrypted_content_cannot_be_searched": "Encrypted content cannot be searched.",
"Encrypted_key_title": "Click here to disable end-to-end encryption for this channel (requires e2ee-permission)",
"Encrypted_message": "Encrypted message",
"Encrypted_RoomType": "Encrypted {{roomType}}",
"Encrypted_message_preview_unavailable": "Encrypted message, preview unavailable",
Expand Down
3 changes: 1 addition & 2 deletions packages/i18n/src/locales/se.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -1974,7 +1974,6 @@
"Encrypted": "Encrypted",
"Encrypted_channel_Description": "Messages are end-to-end encrypted, search will not work and notifications may not show message content",
"Encrypted_content_cannot_be_searched": "Encrypted content cannot be searched.",
"Encrypted_key_title": "Click here to disable end-to-end encryption for this channel (requires e2ee-permission)",
"Encrypted_message": "Encrypted message",
"Encrypted_RoomType": "Encrypted {{roomType}}",
"Encrypted_message_preview_unavailable": "Encrypted message, preview unavailable",
Expand Down Expand Up @@ -6604,4 +6603,4 @@
"Sidepanel_navigation_description": "Display channels and/or discussions associated with teams by default. This allows team owners to customize communication methods to best meet their team’s needs. This is currently in feature preview and will be a premium capability once fully released.",
"Show_channels_description": "Show team channels in second sidebar",
"Show_discussions_description": "Show team discussions in second sidebar"
}
}
19 changes: 19 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9750,6 +9750,7 @@ __metadata:
eslint-plugin-you-dont-need-lodash-underscore: "npm:~6.12.0"
eventemitter3: "npm:^4.0.7"
exif-be-gone: "npm:^1.3.2"
expiry-map: "npm:^2.0.0"
express: "npm:^4.17.3"
express-rate-limit: "npm:^5.5.1"
fast-glob: "npm:^3.2.12"
Expand Down Expand Up @@ -23829,6 +23830,15 @@ __metadata:
languageName: node
linkType: hard

"expiry-map@npm:^2.0.0":
version: 2.0.0
resolution: "expiry-map@npm:2.0.0"
dependencies:
map-age-cleaner: "npm:^0.2.0"
checksum: 10/9be8662e1a5c1084fb6d0ddc5402658dd06101c330454062b2f5efbf1477259d272e54ec16663d7d12a93d08ed510535781c36acb214696c5bc3a690a02a7a9d
languageName: node
linkType: hard

"exponential-backoff@npm:^3.1.1":
version: 3.1.1
resolution: "exponential-backoff@npm:3.1.1"
Expand Down Expand Up @@ -30793,6 +30803,15 @@ __metadata:
languageName: node
linkType: hard

"map-age-cleaner@npm:^0.2.0":
version: 0.2.0
resolution: "map-age-cleaner@npm:0.2.0"
dependencies:
p-defer: "npm:^1.0.0"
checksum: 10/13a6810b76b0067efa7f4b0f3dc58b58b4a4b5faa4cae5a0e8d5d59eda04d7074724eee426c9b5890a1d7e14d1e2902a090587acc8e2430198e79ab1556a2dad
languageName: node
linkType: hard

"map-cache@npm:^0.2.2":
version: 0.2.2
resolution: "map-cache@npm:0.2.2"
Expand Down

0 comments on commit f472f1f

Please sign in to comment.