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

Commit

Permalink
More bookmarks menu item no longer appears
Browse files Browse the repository at this point in the history
Fix #7097

Auditors: @bsclifton
  • Loading branch information
bbondy committed Feb 6, 2017
1 parent 726b9d2 commit 35944f6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/common/lib/menuUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,14 @@ const isItemValid = (currentItem, previousItem) => {
return false
}
}
return currentItem && (typeof currentItem.label === 'string' || typeof currentItem.type === 'string')
return currentItem && (typeof currentItem.l10nLabelId === 'string' || typeof currentItem.label === 'string' || currentItem.type === 'separator')
}

/**
* Remove invalid entries from a menu template:
* - null or falsey entries
* - extra menu separators
* - entries which don't have a label or type
* - entries which don't have a label (or l10nLabelId) if their type is not 'separator'
*/
module.exports.sanitizeTemplateItems = (template) => {
const reduced = template.reduce((result, currentValue, currentIndex, array) => {
Expand Down
6 changes: 6 additions & 0 deletions test/unit/app/common/lib/menuUtilTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,12 @@ describe('menuUtil tests', function () {
const expectedResult = [{label: 'lol1'}, separator, {label: 'lol2'}]
assert.deepEqual(result, expectedResult)
})
it('allows l10nLabelId instead of label', function () {
const template = [{l10nLabelId: 'lol1'}]
const result = menuUtil.sanitizeTemplateItems(template)
const expectedResult = [{l10nLabelId: 'lol1'}]
assert.deepEqual(result, expectedResult)
})
it('removes items which are missing label or type', function () {
const template = [{}, {test: 'test'}, {label: 'lol'}]
const result = menuUtil.sanitizeTemplateItems(template)
Expand Down

1 comment on commit 35944f6

@bsclifton
Copy link
Member

Choose a reason for hiding this comment

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

++

Please sign in to comment.