4
4
5
5
const React = require ( 'react' )
6
6
const Immutable = require ( 'immutable' )
7
- const ImmutableComponent = require ( './../../../../js/components/immutableComponent ' )
7
+ const ReduxComponent = require ( '../reduxComponent ' )
8
8
9
9
const cx = require ( '../../../../js/lib/classSet' )
10
10
const UrlBar = require ( './urlBar' )
@@ -14,7 +14,7 @@ const siteTags = require('../../../../js/constants/siteTags')
14
14
const messages = require ( '../../../../js/constants/messages' )
15
15
const settings = require ( '../../../../js/constants/settings' )
16
16
const ipc = require ( 'electron' ) . ipcRenderer
17
- const { isSourceAboutUrl, getBaseUrl } = require ( '../../../../js/lib/appUrlUtil' )
17
+ const { isSourceAboutUrl} = require ( '../../../../js/lib/appUrlUtil' )
18
18
const AddEditBookmarkHanger = require ( '../addEditBookmarkHanger' )
19
19
const siteUtil = require ( '../../../../js/state/siteUtil' )
20
20
const eventUtil = require ( '../../../../js/lib/eventUtil' )
@@ -24,10 +24,15 @@ const windowStore = require('../../../../js/stores/windowStore')
24
24
const contextMenus = require ( '../../../../js/contextMenus' )
25
25
const LongPressButton = require ( './../../../../js/components/longPressButton' )
26
26
const PublisherToggle = require ( '../publisherToggle' )
27
+ const { getCurrentWindowId} = require ( '../../currentWindow' )
27
28
28
- class NavigationBar extends ImmutableComponent {
29
- constructor ( ) {
30
- super ( )
29
+ // State
30
+ const tabState = require ( '../../../common/state/tabState' )
31
+ const frameStateUtil = require ( '../../../../js/state/frameStateUtil' )
32
+
33
+ class NavigationBar extends React . Component {
34
+ constructor ( props ) {
35
+ super ( props )
31
36
this . onToggleBookmark = this . onToggleBookmark . bind ( this )
32
37
this . onStop = this . onStop . bind ( this )
33
38
this . onReload = this . onReload . bind ( this )
@@ -121,34 +126,38 @@ class NavigationBar extends ImmutableComponent {
121
126
)
122
127
}
123
128
124
- get locationId ( ) {
125
- return getBaseUrl ( this . props . location )
126
- }
127
-
128
- get publisherId ( ) {
129
- return this . props . locationInfo && this . props . locationInfo . getIn ( [ this . locationId , 'publisher' ] )
130
- }
131
-
132
- get visiblePublisher ( ) {
133
- const hostPattern = UrlUtil . getHostPattern ( this . publisherId )
134
- const hostSettings = this . props . siteSettings . get ( hostPattern )
135
- const ledgerPaymentsShown = hostSettings && hostSettings . get ( 'ledgerPaymentsShown' )
136
- return typeof ledgerPaymentsShown === 'boolean'
137
- ? ledgerPaymentsShown
138
- : true
139
- }
140
-
141
- get isPublisherButtonEnabled ( ) {
142
- return getSetting ( settings . PAYMENTS_ENABLED ) &&
143
- UrlUtil . isHttpOrHttps ( this . props . location ) &&
144
- this . visiblePublisher
145
- }
146
-
147
129
componentDidMount ( ) {
148
130
ipc . on ( messages . SHORTCUT_ACTIVE_FRAME_BOOKMARK , ( ) => this . onToggleBookmark ( ) )
149
131
ipc . on ( messages . SHORTCUT_ACTIVE_FRAME_REMOVE_BOOKMARK , ( ) => this . onToggleBookmark ( ) )
150
132
}
151
133
134
+ mergeProps ( state , dispatchProps , ownProps ) {
135
+ const windowState = state . get ( 'currentWindow' )
136
+ const activeFrame = frameStateUtil . getActiveFrame ( windowState ) || Immutable . Map ( )
137
+ const activeTabId = tabState . getActiveTabId ( state , getCurrentWindowId ( ) )
138
+ const props = { }
139
+
140
+ props . navbar = activeFrame . get ( 'navbar' )
141
+ props . sites = state . get ( 'sites' )
142
+ props . activeFrameKey = activeFrame . get ( 'key' )
143
+ props . location = activeFrame . get ( 'location' ) || ''
144
+ props . title = activeFrame . get ( 'title' ) || ''
145
+ props . partitionNumber = activeFrame . get ( 'partitionNumber' ) || 0
146
+ props . isSecure = activeFrame . getIn ( [ 'security' , 'isSecure' ] )
147
+ props . loading = activeFrame . get ( 'loading' )
148
+ props . bookmarkDetail = windowState . get ( 'bookmarkDetail' )
149
+ props . mouseInTitlebar = windowState . getIn ( [ 'ui' , 'mouseInTitlebar' ] )
150
+ props . enableNoScript = ownProps . enableNoScript
151
+ props . settings = state . get ( 'settings' )
152
+ props . menubarVisible = ownProps . menubarVisible
153
+ props . siteSettings = state . get ( 'siteSettings' )
154
+ props . synopsis = state . getIn ( [ 'publisherInfo' , 'synopsis' ] ) || new Immutable . Map ( )
155
+ props . activeTabShowingMessageBox = tabState . isShowingMessageBox ( state , activeTabId )
156
+ props . locationInfo = state . get ( 'locationInfo' )
157
+
158
+ return props
159
+ }
160
+
152
161
render ( ) {
153
162
if ( this . props . activeFrameKey === undefined ||
154
163
this . props . siteSettings === undefined ) {
@@ -214,26 +223,11 @@ class NavigationBar extends ImmutableComponent {
214
223
: null
215
224
}
216
225
</ div >
217
- < UrlBar ref = 'urlBar'
218
- activeFrameKey = { this . props . activeFrameKey }
219
- canGoForward = { this . props . canGoForward }
220
- searchDetail = { this . props . searchDetail }
221
- loading = { this . loading }
222
- location = { this . props . location }
223
- title = { this . props . title }
224
- history = { this . props . history }
225
- isSecure = { this . props . isSecure }
226
- hasLocationValueSuffix = { this . props . hasLocationValueSuffix }
227
- startLoadTime = { this . props . startLoadTime }
228
- endLoadTime = { this . props . endLoadTime }
226
+ < UrlBar
229
227
titleMode = { this . titleMode }
230
- urlbar = { this . props . navbar . get ( 'urlbar' ) }
231
228
onStop = { this . onStop }
232
229
menubarVisible = { this . props . menubarVisible }
233
- noBorderRadius = { this . isPublisherButtonEnabled }
234
- activeTabShowingMessageBox = { this . props . activeTabShowingMessageBox }
235
230
enableNoScript = { this . props . enableNoScript }
236
- scriptsBlocked = { this . props . scriptsBlocked }
237
231
/>
238
232
{
239
233
isSourceAboutUrl ( this . props . location )
@@ -253,4 +247,4 @@ class NavigationBar extends ImmutableComponent {
253
247
}
254
248
}
255
249
256
- module . exports = NavigationBar
250
+ module . exports = ReduxComponent . connect ( NavigationBar )
0 commit comments