-
Notifications
You must be signed in to change notification settings - Fork 11.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: E2EE room setup header (#32446)
Co-authored-by: gabriellsh <[email protected]> Co-authored-by: Hugo Costa <[email protected]>
- Loading branch information
1 parent
465c8ed
commit 2ef71e8
Showing
8 changed files
with
121 additions
and
13 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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
'@rocket.chat/i18n': minor | ||
'@rocket.chat/meteor': minor | ||
--- | ||
|
||
Added E2EE room setup header, with just limited functionality and room actions. |
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
29 changes: 29 additions & 0 deletions
29
apps/meteor/client/views/room/Header/RoomHeaderE2EESetup.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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { isDirectMessageRoom } from '@rocket.chat/core-typings'; | ||
import React, { lazy } from 'react'; | ||
|
||
import { E2EEState } from '../../../../app/e2e/client/E2EEState'; | ||
import { E2ERoomState } from '../../../../app/e2e/client/E2ERoomState'; | ||
import { useE2EERoomState } from '../hooks/useE2EERoomState'; | ||
import { useE2EEState } from '../hooks/useE2EEState'; | ||
import DirectRoomHeader from './DirectRoomHeader'; | ||
import RoomHeader from './RoomHeader'; | ||
import type { RoomHeaderProps } from './RoomHeader'; | ||
|
||
const RoomToolboxE2EESetup = lazy(() => import('./RoomToolbox/RoomToolboxE2EESetup')); | ||
|
||
const RoomHeaderE2EESetup = ({ room, topic = '', slots = {} }: RoomHeaderProps) => { | ||
const e2eeState = useE2EEState(); | ||
const e2eRoomState = useE2EERoomState(room._id); | ||
|
||
if (e2eeState === E2EEState.SAVE_PASSWORD || e2eeState === E2EEState.ENTER_PASSWORD || e2eRoomState === E2ERoomState.WAITING_KEYS) { | ||
return <RoomHeader room={room} topic={topic} slots={slots} roomToolbox={<RoomToolboxE2EESetup />} />; | ||
} | ||
|
||
if (isDirectMessageRoom(room) && (room.uids?.length ?? 0) < 3) { | ||
return <DirectRoomHeader slots={slots} room={room} />; | ||
} | ||
|
||
return <RoomHeader room={room} topic={topic} slots={slots} />; | ||
}; | ||
|
||
export default RoomHeaderE2EESetup; |
41 changes: 41 additions & 0 deletions
41
apps/meteor/client/views/room/Header/RoomToolbox/RoomToolboxE2EESetup.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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { useStableArray } from '@rocket.chat/fuselage-hooks'; | ||
import { HeaderToolbarAction } from '@rocket.chat/ui-client'; | ||
import { useTranslation } from '@rocket.chat/ui-contexts'; | ||
import React from 'react'; | ||
|
||
import { roomActionHooksForE2EESetup } from '../../../../ui'; | ||
import type { RoomToolboxActionConfig } from '../../contexts/RoomToolboxContext'; | ||
import { useRoomToolbox } from '../../contexts/RoomToolboxContext'; | ||
|
||
const RoomToolboxE2EESetup = () => { | ||
const t = useTranslation(); | ||
const toolbox = useRoomToolbox(); | ||
|
||
const { tab } = toolbox; | ||
|
||
const actions = useStableArray( | ||
roomActionHooksForE2EESetup | ||
.map((roomActionHook) => roomActionHook()) | ||
.filter((roomAction): roomAction is RoomToolboxActionConfig => !!roomAction), | ||
); | ||
|
||
return ( | ||
<> | ||
{actions.map(({ id, icon, title, action, disabled, tooltip }, index) => ( | ||
<HeaderToolbarAction | ||
key={id} | ||
index={index} | ||
id={id} | ||
icon={icon} | ||
title={t(title)} | ||
pressed={id === tab?.id} | ||
action={action ?? (() => toolbox.openTab(id))} | ||
disabled={disabled} | ||
tooltip={tooltip} | ||
/> | ||
))} | ||
</> | ||
); | ||
}; | ||
|
||
export default RoomToolboxE2EESetup; |
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