Skip to content

Commit

Permalink
Converts ReleaseNotes into redux component
Browse files Browse the repository at this point in the history
Resolves brave#9448

Auditors: @bsclifton @bridiver

Test Plan:
  • Loading branch information
NejcZdovc committed Jun 15, 2017
1 parent 6478bcd commit ee3ba9a
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 16 deletions.
9 changes: 1 addition & 8 deletions app/renderer/components/main/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -564,10 +563,6 @@ class Main extends ImmutableComponent {
windowActions.setNoScriptVisible(false)
}

onHideReleaseNotes () {
windowActions.setReleaseNotesVisible(false)
}

onHideCheckDefaultBrowserDialog () {
windowActions.setModalDialogDetail('checkDefaultBrowserDialog')
}
Expand Down Expand Up @@ -792,9 +787,7 @@ class Main extends ImmutableComponent {
}
{
releaseNotesIsVisible
? <ReleaseNotes
metadata={this.props.appState.getIn(['updates', 'metadata'])}
onHide={this.onHideReleaseNotes} />
? <ReleaseNotes />
: null
}
{
Expand Down
40 changes: 32 additions & 8 deletions app/renderer/components/main/releaseNotes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 <Dialog onHide={this.props.onHide} isClickDismiss>
<div className={className} onClick={this.onClick.bind(this)}>
<h1 className={css(styles.header)}>{this.props.metadata.get('name')}</h1>
<div>{this.props.metadata.get('notes')}</div>
return <Dialog onHide={this.onHide} isClickDismiss>
<div className={className} onClick={this.onClick}>
<h1 className={css(styles.header)}>{this.props.name}</h1>
<div>{this.props.notes}</div>
</div>
</Dialog>
}
}

module.exports = ReduxComponent.connect(ReleaseNotes)

const styles = StyleSheet.create({
releaseNotes: {
width: 'auto',
Expand All @@ -42,5 +68,3 @@ const styles = StyleSheet.create({
marginBottom: '10px'
}
})

module.exports = ReleaseNotes

0 comments on commit ee3ba9a

Please sign in to comment.