From ee3ba9a36651d92ba0de02db12c7dd5aebf9e290 Mon Sep 17 00:00:00 2001 From: NejcZdovc Date: Thu, 15 Jun 2017 16:51:17 +0200 Subject: [PATCH] Converts ReleaseNotes into redux component Resolves #9448 Auditors: @bsclifton @bridiver Test Plan: --- app/renderer/components/main/main.js | 9 +---- app/renderer/components/main/releaseNotes.js | 40 ++++++++++++++++---- 2 files changed, 33 insertions(+), 16 deletions(-) diff --git a/app/renderer/components/main/main.js b/app/renderer/components/main/main.js index fe99991f648..155e9e168b8 100644 --- a/app/renderer/components/main/main.js +++ b/app/renderer/components/main/main.js @@ -83,7 +83,6 @@ class Main extends ImmutableComponent { this.onHideAutofillAddressPanel = this.onHideAutofillAddressPanel.bind(this) this.onHideAutofillCreditCardPanel = this.onHideAutofillCreditCardPanel.bind(this) this.onHideNoScript = this.onHideNoScript.bind(this) - this.onHideReleaseNotes = this.onHideReleaseNotes.bind(this) this.onHideCheckDefaultBrowserDialog = this.onHideCheckDefaultBrowserDialog.bind(this) this.onTabContextMenu = this.onTabContextMenu.bind(this) this.onFind = this.onFind.bind(this) @@ -564,10 +563,6 @@ class Main extends ImmutableComponent { windowActions.setNoScriptVisible(false) } - onHideReleaseNotes () { - windowActions.setReleaseNotesVisible(false) - } - onHideCheckDefaultBrowserDialog () { windowActions.setModalDialogDetail('checkDefaultBrowserDialog') } @@ -792,9 +787,7 @@ class Main extends ImmutableComponent { } { releaseNotesIsVisible - ? + ? : null } { diff --git a/app/renderer/components/main/releaseNotes.js b/app/renderer/components/main/releaseNotes.js index b0a0bc5c29f..8257d42a10c 100644 --- a/app/renderer/components/main/releaseNotes.js +++ b/app/renderer/components/main/releaseNotes.js @@ -4,33 +4,59 @@ const React = require('react') const {StyleSheet, css} = require('aphrodite') +const Immutable = require('immutable') // Components -const ImmutableComponent = require('../immutableComponent') +const ReduxComponent = require('../reduxComponent') const Dialog = require('../common/dialog') +// Actions +const windowActions = require('../../../../js/actions/windowActions') + // Styles const commonStyles = require('../styles/commonStyles') -class ReleaseNotes extends ImmutableComponent { +class ReleaseNotes extends React.Component { + constructor (props) { + super(props) + this.onClick = this.onClick.bind(this) + } + onClick (e) { e.stopPropagation() } + + onHide () { + windowActions.setReleaseNotesVisible(false) + } + + mergeProps (state, ownProps) { + const metadata = state.getIn(['updates', 'metadata'], Immutable.Map()) + + const props = {} + props.name = metadata.get('name') + props.notes = metadata.get('notes') + + return props + } + render () { const className = css( commonStyles.flyoutDialog, styles.releaseNotes ) - return -
-

{this.props.metadata.get('name')}

-
{this.props.metadata.get('notes')}
+ return +
+

{this.props.name}

+
{this.props.notes}
} } +module.exports = ReduxComponent.connect(ReleaseNotes) + const styles = StyleSheet.create({ releaseNotes: { width: 'auto', @@ -42,5 +68,3 @@ const styles = StyleSheet.create({ marginBottom: '10px' } }) - -module.exports = ReleaseNotes