Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Removes all non-primitive types from BookmarksToolbar and BookmarkTool… #9713

Merged
merged 1 commit into from
Jul 10, 2017

Conversation

NejcZdovc
Copy link
Contributor

@NejcZdovc NejcZdovc commented Jun 26, 2017

…barButton

Submitter Checklist:

  • 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).
  • Tagged reviewers and labelled the pull request as needed.

Resolves #9712

Auditors: @bsclifton

Test plan:

Note: Reordering in context menu is not working. Will create issue for it.

  • right click on a blank bookmark toolbar
  • context menu should be displayed
  • right click on a bookmark
  • context menu should be displayed
  • right click on a bookmark folder
  • context menu should be displayed
  • left click on a bookmark folder
  • context menu should be displayed with items in the folder
  • create so many bookmark items that you get overflow menu
  • check that overflow menu is correctly displayed
  • check if bookmarks are displayed and updated correctly
  1. DND test
  • try to reorder bookmarks on the bookmark toolbar
  • try to add bookmark into a folder
  • try to bookmark a tab with dragging lock icon on the bookmark toolbar

Reviewer Checklist:

Tests

  • Adequate test coverage exists to prevent regressions
  • Tests should be independent and work correctly when run individually or as a suite ref
  • New files have MPL2 license header

@NejcZdovc NejcZdovc added this to the 0.19.x (Nightly Channel) milestone Jun 26, 2017
@NejcZdovc NejcZdovc self-assigned this Jun 26, 2017
@NejcZdovc NejcZdovc added the perf label Jun 26, 2017
@NejcZdovc NejcZdovc changed the base branch from master to 0.18.x June 26, 2017 18:02
@NejcZdovc NejcZdovc changed the base branch from 0.18.x to master June 26, 2017 18:03
@NejcZdovc NejcZdovc changed the base branch from master to 0.18.x June 26, 2017 18:05
@NejcZdovc NejcZdovc changed the base branch from 0.18.x to master June 26, 2017 18:06
@NejcZdovc NejcZdovc force-pushed the refactor/#9712-bookmarks branch 4 times, most recently from e902032 to 147aba4 Compare June 26, 2017 18:21
@NejcZdovc NejcZdovc mentioned this pull request Jun 26, 2017
51 tasks
.filter((bookmark) => !bookmark.get('parentFolderId'))
.sort(siteUtil.siteSort)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

++ on filter before sort

@@ -119,9 +119,9 @@ const getToolbarBookmarks = (state) => {
}

return {
visibleBookmarks: noParentItems.take(i),
visibleBookmarks: noParentItems.take(i).map((item, index) => index).toList(),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure I understand this change

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of sending the whole object we are sending only keys. So we have list of keys and this way we are not triggering re-renders. We send this key to the child components which gets the whole object from the state.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, makes sense

const {SWITCH_TO_NEW_TABS} = require('../constants/settings')
const getSetting = require('../settings').getSetting

const bookmarkActions = {
openBookmarksInFolder: function (allBookmarkItems, folderDetail) {
openBookmarksInFolder: function (folderDetail) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this one should also be converted to an action. Not sure why this is called bookmarkActions, probably just some legacy reason because it's not an action the way we define them now

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can probably dump this whole file, make a real action and move the logic to the reducer

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that we need to convert this, but not sure if this PR is the right one to do it in. One thing that we also need to discuss is how can we call other actions inside the reducers. One case that I had was calling an actions that was then handled in multiple reducers. So we need to define this

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should not be calling actions from reducers, that breaks the uni-directional flow that is the whole point of flux/redux. The only time we are doing that now is for some special cases in the windowStore and maybe a few legacy calls. If you have a specific example to look at we can talk about options

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as far as converting it goes, this is just like the others. It is accessing appStoreRenderer and that is problematic. Why is this any different than the others that you already converted?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure that that's enough. So if you check out createTabRequested you will see that we have two places where we call APP_CREATE_TAB_REQUESTED.

First: https://github.com/brave/browser-laptop/blob/master/app/browser/reducers/tabsReducer.js?utf8=%E2%9C%93#L138

Second: https://github.com/brave/browser-laptop/blob/master/app/browser/reducers/sitesReducer.js?utf8=%E2%9C%93#L158

Now if instead of calling this app actions I just do tabs.create some logic will be lost, which would be called otherwise. This is the main reason why I keep using actions, because they are used in different places and I could regress some logic if I just pick one. What I don't want to do is duplicating a code.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the handler in sitesReducer should be changed to APP_TAB_CREATED. APP_CREATE_TAB_REQUESTED is a temporary workaround until we move things to the browser process so nothing else should handle it

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in any case if tabs.create doesn't encapsulate all the logic for creating a tab then we need to fix that because the api is not useful if it can only be called through APP_CREATE_TAB_REQUESTED

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for instance activateIfOpen shouldn't be an action property because it always applies to specific urls

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on our conversation yesterday I would suggest that we merged this PR. This file bookmarkActions.js was not really the focus in this PR, so I would suggest that we create a follow up where we would refactor only this file.

e.stopPropagation()
}

windowActions.onShowBookmarkFolderMenu(this.props.bookmarkKey, left, top)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add a TODO to merge setBookmarksToolbarSelectedFolderId into onShowBookmarkFolderMenu. We should never call more than one action at a time

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

icon: showFavicon ? site.get('favicon') : undefined,
faIcon,
contextMenu: function (e) {
onSiteDetailMenu(state, item[0], e)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is supposed to be windowActions. onSiteDetailMenu ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a test that covers this? Looks like it should be failing if there is

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@bsclifton bsclifton changed the title Removes all non-primitve types from BookmarksToolbar and BookmarkTool… Removes all non-primitive types from BookmarksToolbar and BookmarkTool… Jun 26, 2017
@NejcZdovc NejcZdovc force-pushed the refactor/#9712-bookmarks branch 2 times, most recently from 47f9dca to 642db43 Compare June 28, 2017 06:34
@NejcZdovc NejcZdovc removed the request for review from bridiver July 5, 2017 16:26
@NejcZdovc NejcZdovc requested review from bridiver and bsclifton and removed request for bsclifton and darkdh July 5, 2017 16:26
@NejcZdovc
Copy link
Contributor Author

re-run TEST_DIR=bookmark-components npm run testsuite 4 times locally and it's passing every single time

@NejcZdovc NejcZdovc force-pushed the refactor/#9712-bookmarks branch 3 times, most recently from 9439534 to 3fa0af0 Compare July 9, 2017 20:15
@NejcZdovc NejcZdovc requested review from bridiver and bsclifton and removed request for bridiver and bsclifton July 10, 2017 06:34
@ayumi
Copy link
Contributor

ayumi commented Jul 10, 2017

what's the status of this? currently UI lag is immense in master, encumbering other performance work. i'm really looking forward to this patch!

Copy link
Collaborator

@bridiver bridiver left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

++ with follow-up from action discussion

@bbondy bbondy merged commit 03ae74b into brave:master Jul 10, 2017
bbondy added a commit that referenced this pull request Jul 10, 2017
Removes all non-primitive types from BookmarksToolbar and BookmarkTool…
Copy link
Member

@bsclifton bsclifton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

++

@@ -89,6 +101,414 @@ const onTabPageMenu = function (state, action) {
tabPageMenu.popup(getCurrentWindow())
}

const openInNewTabMenuItem = (url, isPrivate, partitionNumber, openerTabId) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Each of these menu types should be in a file (I'd suggest commonMenu- see https://github.com/brave/browser-laptop/blob/2bd7726b6d6ea83f41fbebdfab6b4141f8a5a78b/app/common/commonMenu.js). This would make it easy to unit test each method. A quick example of something easy to test: you can check each method that's exported to make sure each has a label field that called locale.translation().

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be great in a follow up 😄 Everything else looks good

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

Successfully merging this pull request may close these issues.

5 participants