Skip to content

Commit

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

Auditors: @bsclifton @bridiver

Test Plan:
  • Loading branch information
NejcZdovc committed Jun 13, 2017
1 parent 7ce06ee commit 0419204
Showing 1 changed file with 20 additions and 17 deletions.
37 changes: 20 additions & 17 deletions app/renderer/components/main/siteInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
* You can obtain one at http://mozilla.org/MPL/2.0/. */

const React = require('react')
const PropTypes = require('prop-types')
const {StyleSheet, css} = require('aphrodite/no-important')

// Components
const ImmutableComponent = require('../immutableComponent')
const ReduxComponent = require('../reduxComponent')
const Dialog = require('../common/dialog')
const Button = require('../common/button')

// Actions
const appActions = require('../../../../js/actions/appActions')
const webviewActions = require('../../../../js/actions/webviewActions')
const windowActions = require('../../../../js/actions/windowActions')

// Utils
const cx = require('../../../../js/lib/classSet')
Expand All @@ -26,29 +26,37 @@ const platformUtil = require('../../../common/lib/platformUtil')
const globalStyles = require('../styles/global')
const commonStyles = require('../styles/commonStyles')

class SiteInfo extends ImmutableComponent {
constructor () {
super()
class SiteInfo extends React.Component {
constructor (props) {
super(props)
this.onAllowRunInsecureContent = this.onAllowRunInsecureContent.bind(this)
this.onDenyRunInsecureContent = this.onDenyRunInsecureContent.bind(this)
this.onViewCertificate = this.onViewCertificate.bind(this)
}

onAllowRunInsecureContent () {
appActions.changeSiteSetting(siteUtil.getOrigin(this.location),
'runInsecureContent', true, this.isPrivate)
appActions.loadURLRequested(this.props.frameProps.get('tabId'), this.location)
this.props.onHide()
this.onHide()
}

onDenyRunInsecureContent () {
appActions.removeSiteSetting(siteUtil.getOrigin(this.location),
'runInsecureContent', this.isPrivate)
appActions.loadURLRequested(this.props.frameProps.get('tabId'), this.location)
this.props.onHide()
this.onHide()
}

onViewCertificate () {
this.props.onHide()
this.onHide()
webviewActions.showCertificate()
}

onHide () {
windowActions.setSiteInfoVisible(false)
}

get isExtendedValidation () {
return this.props.frameProps.getIn(['security', 'isExtendedValidation'])
}
Expand Down Expand Up @@ -183,7 +191,7 @@ class SiteInfo extends ImmutableComponent {
<Button l10nId='dismissAllowRunInsecureContent'
className='primaryButton'
testId='dismissAllowRunInsecureContentButton'
onClick={this.props.onHide}
onClick={this.onHide}
/>
</div>
{viewCertificateButton}
Expand All @@ -196,7 +204,7 @@ class SiteInfo extends ImmutableComponent {
<Button l10nId='dismissDenyRunInsecureContent'
className='whiteButton'
testId='dismissDenyRunInsecureContentButton'
onClick={this.props.onHide}
onClick={this.onHide}
/>
<Button l10nId='denyRunInsecureContent'
className='primaryButton'
Expand Down Expand Up @@ -231,7 +239,7 @@ class SiteInfo extends ImmutableComponent {
</div>
}

return <Dialog testId='siteInfoDialog' onHide={this.props.onHide} className='siteInfo' isClickDismiss>
return <Dialog testId='siteInfoDialog' onHide={this.onHide} className='siteInfo' isClickDismiss>
<div onClick={(e) => e.stopPropagation()}
className={cx({
[css(commonStyles.flyoutDialog)]: true,
Expand All @@ -252,10 +260,7 @@ class SiteInfo extends ImmutableComponent {
}
}

SiteInfo.propTypes = {
frameProps: PropTypes.object,
onHide: PropTypes.func
}
module.exports = ReduxComponent.connect(SiteInfo)

const styles = StyleSheet.create({
flexJustifyEnd: {
Expand Down Expand Up @@ -302,5 +307,3 @@ const styles = StyleSheet.create({
maxWidth: '500px'
}
})

module.exports = SiteInfo

0 comments on commit 0419204

Please sign in to comment.