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

Hide bookmark bar when removing last item #14048

Merged
merged 2 commits into from
May 8, 2018

Conversation

petemill
Copy link
Member

@petemill petemill commented May 8, 2018

Fix #14047
The bookmark bar has always remained 'visible' when removing the last item. It just happened to be reduced to a few pixels tall. This was a defect as it affected the vertical rhythm of the UI. With #13758, the toolbar always remains the set height. With this change, the toolbar is hidden automatically when the last item is removed, just like it already automatically shows when the first item is added.

Also fixes getSetting so check for whether an object is Immutable.Map correctly, so that it can be used in tests.

Test Plan:

Automated

  • npm run unittest -- --grep 'bookmarksReducer'

Manual

  • Add several bookmark items, including folders
  • Remove some items
    • observe the toolbar is still shown
  • Move some items
    • observe the toolbar is still shown
  • Delete all items
    • observe the toolbar is not shown anymore
  • Recreate items, and use 'move' to put all items in a folder that is not on the bookmark bar
    • observe the toolbar is not shown anymore

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.
  • Request a security/privacy review as needed. (Ask a Brave employee to help if you cannot access this document.)

Test Plan:

Reviewer Checklist:

  • Request a security/privacy review as needed if one was not already requested.

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

Fix #14047
The bookmark bar has always remained 'visible' when removing the last item. It just happened to be reduced to a few pixels tall. This was a defect as it affected the vertical rhythm of the UI. With #13758, the toolbar always remains the set height. With this change, the toolbar is hidden automatically when the last item is removed, just like it already automatically shows when the first item is added.

Test Plan:
Automated
- `npm run unittest -- --grep 'bookmarksReducer'`

Manual
- Add several bookmark items, including folders
- Remove some items
  - observe the toolbar is still shown
- Move some items
  - observe the toolbar is still shown
- Delete all items
  - observe the toolbar is not shown anymore
- Recreate items, and use 'move' to put all items in a folder that is not on the bookmark bar
  - observe the toolbar is not shown anymore
@petemill petemill added this to the 0.22.x Release 3 (Beta channel) milestone May 8, 2018
@petemill petemill self-assigned this May 8, 2018
@petemill petemill requested review from bsclifton and NejcZdovc May 8, 2018 03:28
@@ -548,6 +560,19 @@ describe('bookmarksReducer unit test', function () {
.deleteIn(['cache', 'bookmarkLocation', 'https://clifton.io/'])
assert.equal(spy.calledOnce, true)
assert.deepEqual(newState.toJS(), expectedState.toJS())
console.log('settings', newState.get('settings').toJS(), newState.getIn(['settings', settingsConstants.SHOW_BOOKMARKS_TOOLBAR]))
Copy link
Member

Choose a reason for hiding this comment

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

Whoops, left a console.log in there 😄

@@ -89,6 +94,12 @@ const bookmarksReducer = (state, action, immutableAction) => {

const destinationDetail = bookmarksState.findBookmark(state, action.get('destinationKey'))
state = syncUtil.updateObjectCache(state, destinationDetail, STATE_SITES.BOOKMARKS)

// close bookmark bar when going to 0
const bookmarkBarItemCount = bookmarksState.getBookmarksWithFolders(state, 0).size
Copy link
Member

Choose a reason for hiding this comment

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

A little nit-picky... but could we move this code to app/common/lib/bookmarkUtils? Since it's the same as the code above in bookmarkFoldersReducer.js, each of these could be replaced with a single call (maybe the method would be called like closeBookmarksToolbarIfEmpty or something like that)

Should make the logic easier to unit test too 😄 👍

assert.ok(onChangeSettingSpy.neverCalledWith(settingsConstants.SHOW_BOOKMARKS_TOOLBAR, false), 'bookmarks toolbar enabled setting is unaffected by removing 1 bookmark')
})

it('hides bookmarks toolbar when all toolbar bookmarks are removed', function () {
Copy link
Member

Choose a reason for hiding this comment

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

Do we need a test for bookmarksReducer too?

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.

Comments left 😄

@petemill petemill removed the request for review from NejcZdovc May 8, 2018 06:20
@bsclifton bsclifton force-pushed the fix/14047-hide-bookmarks-bar-no-items branch from bae0fcf to 9b3379f Compare May 8, 2018 07:09
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.

Updated the code and tests- works great 😄 👍

Copy link
Member Author

@petemill petemill left a comment

Choose a reason for hiding this comment

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

Thanks @bsclifton for the more thorough test updates

@petemill petemill merged commit 2a55706 into master May 8, 2018
@petemill petemill deleted the fix/14047-hide-bookmarks-bar-no-items branch May 8, 2018 17:25
petemill added a commit that referenced this pull request May 8, 2018
…items

Hide bookmark bar when removing last item
petemill added a commit that referenced this pull request May 8, 2018
…items

Hide bookmark bar when removing last item
@petemill
Copy link
Member Author

petemill commented May 8, 2018

master 2a55706
0.23.x 56b080f
0.22.x-release3 4f59d42

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.

Bookmark bar stays visible after all bookmarks are deleted
2 participants