Skip to content

Commit

Permalink
Moves hrePreview from Frame
Browse files Browse the repository at this point in the history
Resolves brave#10194

Auditors: @bsclifton

Test Plan:
  • Loading branch information
NejcZdovc authored and dfperry5 committed Aug 18, 2017
1 parent a2c2ed5 commit fef6f54
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 12 deletions.
14 changes: 2 additions & 12 deletions app/renderer/components/frame/frame.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const getSetting = require('../../../../js/settings').getSetting
// Components
const ReduxComponent = require('../reduxComponent')
const FullScreenWarning = require('./fullScreenWarning')
const HrefPreview = require('./hrefPreview')
const MessageBox = require('../common/messageBox')

// Store
Expand Down Expand Up @@ -885,8 +886,6 @@ class Frame extends React.Component {
props.isActive = frameStateUtil.isFrameKeyActive(currentWindow, frame.get('key'))
props.showFullScreenWarning = frame.get('showFullScreenWarning')
props.location = location
props.hrefPreview = frame.get('hrefPreview')
props.showOnRight = frame.get('showOnRight')
props.tabId = tabId
props.showMessageBox = tabMessageBoxState.hasMessageBoxDetail(state, tabId)

Expand Down Expand Up @@ -945,16 +944,7 @@ class Frame extends React.Component {
webviewContainer: true,
isPreview: this.props.isPreview
})} />
{
this.props.hrefPreview
? <div className={cx({
hrefPreview: true,
right: this.props.showOnRight
})}>
{this.props.hrefPreview}
</div>
: null
}
<HrefPreview frameKey={this.props.frameKey} />
{
this.props.showMessageBox
? <MessageBox
Expand Down
45 changes: 45 additions & 0 deletions app/renderer/components/frame/hrefPreview.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */

const React = require('react')
const Immutable = require('immutable')

// Components
const ReduxComponent = require('../reduxComponent')

// Utils
const frameStateUtil = require('../../../../js/state/frameStateUtil')
const cx = require('../../../../js/lib/classSet')

class HrefPreview extends React.Component {
mergeProps (state, ownProps) {
const currentWindow = state.get('currentWindow')
const frame = frameStateUtil.getFrameByKey(currentWindow, ownProps.frameKey) || Immutable.Map()

const props = {}
// used in renderer
props.frameKey = ownProps.frameKey
props.hrefPreview = frame.get('hrefPreview')
props.showOnRight = frame.get('showOnRight')

return props
}

render () {
if (!this.props.hrefPreview) {
return null
}

return <div
className={cx({
hrefPreview: true,
right: this.props.showOnRight
})}
>
{this.props.hrefPreview}
</div>
}
}

module.exports = ReduxComponent.connect(HrefPreview)

0 comments on commit fef6f54

Please sign in to comment.