forked from jitsi/jitsi-meet
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add dialog to set the E2EE key * Use the Redux action / middleware to update the key even when set through the hash parameter * Cleanup URL after processing the key so it's not recorded in browser history
- Loading branch information
Showing
15 changed files
with
365 additions
and
9 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/** | ||
* The type of the action which signals the E2EE key has changed. | ||
* | ||
* { | ||
* type: SET_E2EE_KEY | ||
* } | ||
*/ | ||
export const SET_E2EE_KEY = 'SET_E2EE_KEY'; |
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,16 @@ | ||
// @flow | ||
|
||
import { SET_E2EE_KEY } from './actionTypes'; | ||
|
||
/** | ||
* Dispatches an action to set the E2EE key. | ||
* | ||
* @param {string|undefined} key - The new key to be used for E2EE. | ||
* @returns {Object} | ||
*/ | ||
export function setE2EEKey(key: ?string) { | ||
return { | ||
type: SET_E2EE_KEY, | ||
key | ||
}; | ||
} |
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,76 @@ | ||
// @flow | ||
|
||
import React from 'react'; | ||
|
||
import { createE2EEEvent, sendAnalytics } from '../../analytics'; | ||
import { openDialog } from '../../base/dialog'; | ||
import { translate } from '../../base/i18n'; | ||
import { IconRoomUnlock } from '../../base/icons'; | ||
import { connect } from '../../base/redux'; | ||
import { AbstractButton, BetaTag } from '../../base/toolbox'; | ||
import type { AbstractButtonProps } from '../../base/toolbox'; | ||
|
||
import E2EEDialog from './E2EEDialog'; | ||
|
||
|
||
type Props = AbstractButtonProps & { | ||
|
||
/** | ||
* The redux {@code dispatch} function. | ||
*/ | ||
dispatch: Function | ||
|
||
}; | ||
|
||
/** | ||
* Button that open a dialog to set the E2EE key. | ||
*/ | ||
class E2EEButton extends AbstractButton<Props, *> { | ||
accessibilityLabel = 'toolbar.accessibilityLabel.e2ee'; | ||
icon = IconRoomUnlock; | ||
label = 'toolbar.e2ee'; | ||
tooltip = 'toolbar.e2ee'; | ||
|
||
/** | ||
* Helper function to be implemented by subclasses, which returns | ||
* a React Element to display (a beta tag) at the end of the button. | ||
* | ||
* @override | ||
* @protected | ||
* @returns {ReactElement} | ||
*/ | ||
_getElementAfter() { | ||
return <BetaTag />; | ||
} | ||
|
||
/** | ||
* Handles clicking / pressing the button, and opens the E2EE dialog. | ||
* | ||
* @protected | ||
* @returns {void} | ||
*/ | ||
_handleClick() { | ||
sendAnalytics(createE2EEEvent('dialog.open')); | ||
this.props.dispatch(openDialog(E2EEDialog)); | ||
} | ||
} | ||
|
||
/** | ||
* Maps (parts of) the redux state to the associated props for this component. | ||
* | ||
* @param {Object} state - The Redux state. | ||
* @param {Props} ownProps - The own props of the Component. | ||
* @private | ||
* @returns {Props} | ||
*/ | ||
export function mapStateToProps(state: Object, ownProps: Props) { | ||
const { e2eeSupported } = state['features/base/conference']; | ||
const { visible = Boolean(e2eeSupported) } = ownProps; | ||
|
||
return { | ||
visible | ||
}; | ||
} | ||
|
||
|
||
export default translate(connect(mapStateToProps)(E2EEButton)); |
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,142 @@ | ||
/* @flow */ | ||
|
||
import React, { Component } from 'react'; | ||
import type { Dispatch } from 'redux'; | ||
import { FieldTextStateless as TextField } from '@atlaskit/field-text'; | ||
|
||
import { createE2EEEvent, sendAnalytics } from '../../analytics'; | ||
import { Dialog } from '../../base/dialog'; | ||
import { translate, translateToHTML } from '../../base/i18n'; | ||
import { connect } from '../../base/redux'; | ||
|
||
import { setE2EEKey } from '../actions'; | ||
|
||
|
||
type Props = { | ||
|
||
/** | ||
* The current E2EE key. | ||
*/ | ||
_key: string, | ||
|
||
/** | ||
* The redux {@code dispatch} function. | ||
*/ | ||
dispatch: Dispatch<any>, | ||
|
||
/** | ||
* Invoked to obtain translated strings. | ||
*/ | ||
t: Function | ||
}; | ||
|
||
type State = { | ||
|
||
/** | ||
* The current E2EE key. | ||
*/ | ||
key: string | ||
}; | ||
|
||
/** | ||
* Implements a React {@code Component} for displaying a dialog with a field | ||
* for setting the E2EE key. | ||
* | ||
* @extends Component | ||
*/ | ||
class E2EEDialog extends Component<Props, State> { | ||
/** | ||
* Initializes a new {@code E2EEDialog } instance. | ||
* | ||
* @param {Object} props - The read-only properties with which the new | ||
* instance is to be initialized. | ||
*/ | ||
constructor(props: Props) { | ||
super(props); | ||
|
||
this.state = { | ||
key: this.props._key | ||
}; | ||
|
||
// Bind event handlers so they are only bound once for every instance. | ||
this._onKeyChange = this._onKeyChange.bind(this); | ||
this._onSubmit = this._onSubmit.bind(this); | ||
} | ||
|
||
/** | ||
* Implements React's {@link Component#render()}. | ||
* | ||
* @inheritdoc | ||
* @returns {ReactElement} | ||
*/ | ||
render() { | ||
const { t } = this.props; | ||
|
||
return ( | ||
<Dialog | ||
isModal = { false } | ||
onSubmit = { this._onSubmit } | ||
titleKey = 'dialog.e2eeTitle' | ||
width = 'small'> | ||
<div className = 'e2ee-destription'> | ||
{ translateToHTML(t, 'dialog.e2eeDescription') } | ||
</div> | ||
<TextField | ||
autoFocus = { true } | ||
compact = { true } | ||
label = { t('dialog.e2eeLabel') } | ||
name = 'e2eeKey' | ||
onChange = { this._onKeyChange } | ||
shouldFitContainer = { true } | ||
type = 'password' | ||
value = { this.state.key } /> | ||
</Dialog>); | ||
} | ||
|
||
_onKeyChange: (Object) => void; | ||
|
||
/** | ||
* Updates the entered key. | ||
* | ||
* @param {Object} event - The DOM event triggered from the entered value having changed. | ||
* @private | ||
* @returns {void} | ||
*/ | ||
_onKeyChange(event) { | ||
this.setState({ key: event.target.value.trim() }); | ||
} | ||
|
||
_onSubmit: () => boolean; | ||
|
||
/** | ||
* Dispatches an action to update the E2EE key. | ||
* | ||
* @private | ||
* @returns {boolean} | ||
*/ | ||
_onSubmit() { | ||
const { key } = this.state; | ||
|
||
sendAnalytics(createE2EEEvent(`key.${key ? 'set' : 'unset'}`)); | ||
this.props.dispatch(setE2EEKey(key)); | ||
|
||
return true; | ||
} | ||
} | ||
|
||
/** | ||
* Maps (parts of) the Redux state to the associated props for this component. | ||
* | ||
* @param {Object} state - The Redux state. | ||
* @private | ||
* @returns {Props} | ||
*/ | ||
function mapStateToProps(state) { | ||
const { e2eeKey } = state['features/e2ee']; | ||
|
||
return { | ||
_key: e2eeKey || '' | ||
}; | ||
} | ||
|
||
export default translate(connect(mapStateToProps)(E2EEDialog)); |
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,2 @@ | ||
export { default as E2EEButton } from './E2EEButton'; | ||
export { default as E2EEDialog } from './E2EEDialog'; |
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 @@ | ||
export * from './actions'; | ||
export * from './actionTypes'; | ||
export * from './components'; | ||
|
||
import './middleware'; | ||
import './reducer'; |
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,5 @@ | ||
// @flow | ||
|
||
import { getLogger } from '../base/logging/functions'; | ||
|
||
export default getLogger('features/e2ee'); |
Oops, something went wrong.