-
Notifications
You must be signed in to change notification settings - Fork 11.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove ability of key button to disable e2e encryption
- Loading branch information
Showing
5 changed files
with
26 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
27
apps/meteor/client/views/room/HeaderV2/icons/Encrypted.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters