Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upMoves navigation logic from main.js to new component #8205
Conversation
67c3f1e
to
dccc4a0
|
@bridiver as per your comment https://github.com/brave/browser-laptop/pull/8149/files#r110748326 I changed util into state and change |
|
@bsclifton @bridiver can we please merge this one? |
|
great work! Just need to address the perf problem with the props and a few minor naming issues |
| const urlParse = require('../urlParse') | ||
|
|
||
| function braveShieldsEnabled (frame) { | ||
| const activeRequestedLocation = frameStateUtil.activeRequestedLocation(frame) |
This comment has been minimized.
This comment has been minimized.
bridiver
Apr 12, 2017
Collaborator
does it still make sense to name this activeRequestedLocation now that we're passing in a frame? I think we should try to bring the naming conventions in line with muon/chromium to make things a little easier to follow which would mean this method would be getLastCommittedURL. The error pages are transient entries (or will be anyway) so they will never be a committed url.
This comment has been minimized.
This comment has been minimized.
bridiver
Apr 12, 2017
Collaborator
as a side node, committed does not mean that the url has completely loaded, it just means that a load was started and could have been blocked or redirected. Before load-start a url would be considered provisional
| describe('when user has history going forwards and backwards', function () { | ||
| let wrapper | ||
|
|
||
| before(function () { | ||
| wrapper = shallow( | ||
| <Main windowState={windowState} appState={appState} /> | ||
| <Navigator | ||
| windowState={windowState} |
This comment has been minimized.
This comment has been minimized.
bridiver
Apr 12, 2017
Collaborator
passing in the entire window and app state as props will cause the Navigator component to re-render every time anything changes in either one of these stores. We need to make these props much more fine grained so they only update when they actually need to
|
|
||
| onNav (e, navCheckProp, navType, navAction) { | ||
| const activeFrame = frameStateUtil.getActiveFrame(this.props.windowState) | ||
| const activeTabId = tabUtil.activeTabId(this.props.windowState) |
This comment has been minimized.
This comment has been minimized.
| browserAction={browserAction} | ||
| extensionId={id} | ||
| tabId={activeTabId} | ||
| popupWindowSrc={this.props.windowState.getIn(['popupWindowDetail', 'src'])} /> |
This comment has been minimized.
This comment has been minimized.
bridiver
Apr 12, 2017
Collaborator
Can we pass in popupWindowSrc as a prop? See my general note below about passing in props for anything that uses this.props.windowState or this.props.appState. When we transition to ReduxComponent we will just move the props from the parent to mergeProps
|
|
||
| get extensionButtons () { | ||
| const activeTabId = tabUtil.activeTabId(this.props.windowState) | ||
| const enabledExtensions = extensionState.getEnabledExtensions(this.props.appState) |
This comment has been minimized.
This comment has been minimized.
bridiver
Apr 12, 2017
Collaborator
comments about this.props.windowState also apply to anything using this.props.appState
| </div> | ||
| <NavigationBar | ||
| navbar={activeFrame && activeFrame.get('navbar')} | ||
| sites={this.props.appState.get('sites')} |
This comment has been minimized.
This comment has been minimized.
bridiver
Apr 12, 2017
Collaborator
this is where prop lifting gets really annoying. All of these props need to be passed in to the Navigator component so they can be passed along to NavigationBar. It's very convenient to use this.props.appState instead, but unfortunately it is not good for performance
| @@ -747,3 +749,7 @@ module.exports.setObjectId = (item) => { | |||
| const crypto = require('crypto') | |||
| return item.set('objectId', new Immutable.List(crypto.randomBytes(16))) | |||
| } | |||
|
|
|||
| module.exports.enableNoScript = (settings, state) => { | |||
This comment has been minimized.
This comment has been minimized.
bridiver
Apr 12, 2017
Collaborator
siteUtil.js is actually for appState.sites and site settings are in appState.siteSettings. The names are similar, but they are two very distinct things. Maybe a new siteSettingsState in app/common/state?
Also this method sounds like it will enable noScript, but it's actually checking the state of noScript so maybe noScriptEnabled or isNoScriptEnabled? Can we swap also swap the state and settings parameters to be consistent with other state helpers and maybe move this to siteSettingsState?
|
after discussion with @NejcZdovc all of this stuff was going to be re-rendered anyway as part of Main.js so this doesn't really create any new performance problems. |
494df0a
to
276bef9
|
yes, this PR only moves existing logic from main.js to the new component. I didn't introduce any new logic or optimization. All problems that you mentioned were already there. With this PR I wanted to prepare a good base for the redux implementation into the navigator section. |
276bef9
to
1cdaaf3
| } | ||
|
|
||
| const parsedUrl = urlParse(lastCommittedURL) | ||
| return !(parsedUrl.protocol !== 'https:' && parsedUrl.protocol !== 'http:') |
This comment has been minimized.
This comment has been minimized.
bridiver
Apr 12, 2017
Collaborator
merging now, but just a nit that this would be easier to read in the positive form parsedUrl === 'https' or better yet use urlutil.isHttpOrHttps
|
++ |
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
|
fixed here #8750 |
NejcZdovc commentedApr 10, 2017
•
edited
git rebase -ito squash commits (if needed).Resovles #8189
Auditor
@bridiver
Test plan: