Skip to content
This repository has been archived by the owner. It is now read-only.

Moves navigation logic from main.js to new component #8205

Merged
merged 1 commit into from Apr 12, 2017

Conversation

@NejcZdovc
Copy link
Member

NejcZdovc commented Apr 10, 2017

  • Submitted a ticket for my issue if one did not already exist.
  • Used Github auto-closing keywords in the commit message.
  • Added/updated tests for this change (for new code or code which already has tests).
  • Ran git rebase -i to squash commits (if needed).

Resovles #8189

Auditor

@bridiver

Test plan:

  • check if navigation buttons are working correctly (back and forward)
  • check if long press is working on navigation buttons
  • check if lion icon is behaving correctly (try disabling shield, check if block numbers from bravery is the same as is on a lion icon)
  • check if refresh and home buttons are working correctly
@NejcZdovc NejcZdovc self-assigned this Apr 10, 2017
@NejcZdovc NejcZdovc requested a review from bridiver Apr 10, 2017
@NejcZdovc NejcZdovc force-pushed the NejcZdovc:hotfix/#8149-navigator branch 2 times, most recently from 67c3f1e to dccc4a0 Apr 11, 2017
@NejcZdovc
Copy link
Member Author

NejcZdovc commented Apr 11, 2017

@bridiver as per your comment https://github.com/brave/browser-laptop/pull/8149/files#r110748326 I changed util into state and change braveShieldsDisabled to braveShieldsEnabled. Can you review it again please?

@NejcZdovc
Copy link
Member Author

NejcZdovc commented Apr 11, 2017

@bridiver in d759270 I also changed entry param, so that we only operate with activeFrame, we don't need state for this function

@NejcZdovc NejcZdovc requested a review from bsclifton Apr 12, 2017
@NejcZdovc
Copy link
Member Author

NejcZdovc commented Apr 12, 2017

@bsclifton @bridiver can we please merge this one?

Copy link
Collaborator

bridiver left a comment

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.

Copy link
@bridiver

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.

Copy link
@bridiver

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.

Copy link
@bridiver

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.

Copy link
@bridiver

bridiver Apr 12, 2017

Collaborator

can't we use props.activeTab here?

browserAction={browserAction}
extensionId={id}
tabId={activeTabId}
popupWindowSrc={this.props.windowState.getIn(['popupWindowDetail', 'src'])} />

This comment has been minimized.

Copy link
@bridiver

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.

Copy link
@bridiver

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.

Copy link
@bridiver

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.

Copy link
@bridiver

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?

@bridiver
Copy link
Collaborator

bridiver commented Apr 12, 2017

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.

@NejcZdovc NejcZdovc force-pushed the NejcZdovc:hotfix/#8149-navigator branch 2 times, most recently from 494df0a to 276bef9 Apr 12, 2017
@NejcZdovc
Copy link
Member Author

NejcZdovc commented Apr 12, 2017

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.

Resovles #8189

Auditor: @bridiver
@NejcZdovc NejcZdovc force-pushed the NejcZdovc:hotfix/#8149-navigator branch from 276bef9 to 1cdaaf3 Apr 12, 2017
}

const parsedUrl = urlParse(lastCommittedURL)
return !(parsedUrl.protocol !== 'https:' && parsedUrl.protocol !== 'http:')

This comment has been minimized.

Copy link
@bridiver

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

@bridiver bridiver merged commit b1a6c61 into brave:master Apr 12, 2017
0 of 2 checks passed
0 of 2 checks passed
continuous-integration/appveyor/pr Waiting for AppVeyor build to complete
Details
continuous-integration/travis-ci/pr The Travis CI build is in progress
Details
@bridiver
Copy link
Collaborator

bridiver commented Apr 12, 2017

++

@bridiver bridiver added this to the 0.14.3 milestone Apr 12, 2017
@bbondy

This comment has been minimized.

Copy link
Member

bbondy commented on app/renderer/components/navigation/navigator.js in 1cdaaf3 May 8, 2017

windowActions.newFrame doesn't exist, seems like the code removed was the proper appActions.createTabRequested({ url }), probably a rebase problem. I'll fix.

This comment has been minimized.

Copy link
Member

bbondy replied May 8, 2017

fixed here #8750

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants
You can’t perform that action at this time.