-
-
Notifications
You must be signed in to change notification settings - Fork 10.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Move internal tags out of labs (#7519)
closes #6165 - internal tags has been in labs for a couple of months, we've fixed some bugs & are ready to ship - removes all code that tests for the labs flag - also refactors the various usage of the visibility filter into a single util - all the tests still pass!!! - this marks #6165 as closed because I think the remaining UI tasks will be handled as part of a larger piece of work
- Loading branch information
1 parent
f57719d
commit 63094d3
Showing
14 changed files
with
162 additions
and
323 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,12 @@ | ||
var labs = require('../../utils/labs'); | ||
var visibilityFilter = require('../../utils/visibility-filter'); | ||
|
||
function getKeywords(data) { | ||
if (data.post && data.post.tags && data.post.tags.length > 0) { | ||
return data.post.tags.reduce(function (tags, tag) { | ||
if (tag.visibility !== 'internal' || !labs.isSet('internalTags')) { | ||
tags.push(tag.name); | ||
} | ||
return tags; | ||
}, []); | ||
return visibilityFilter(data.post.tags, ['public'], false, function processItem(item) { | ||
return item.name; | ||
}); | ||
} | ||
return null; | ||
} | ||
|
||
module.exports = getKeywords; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
var _ = require('lodash'); | ||
/** | ||
* | ||
* @param {Array|Object} items | ||
* @param {Array} visibility | ||
* @param {Boolean} [explicit] | ||
* @param {Function} [fn] | ||
* @returns {Array|Object} filtered items | ||
*/ | ||
module.exports = function visibilityFilter(items, visibility, explicit, fn) { | ||
var memo = _.isArray(items) ? [] : {}; | ||
|
||
if (_.includes(visibility, 'all')) { | ||
return fn ? _.map(items, fn) : items; | ||
} | ||
|
||
// We don't want to change the structure of what is returned | ||
return _.reduce(items, function (items, item, key) { | ||
if (!item.visibility && !explicit || _.includes(visibility, item.visibility)) { | ||
var newItem = fn ? fn(item) : item; | ||
if (_.isArray(items)) { | ||
memo.push(newItem); | ||
} else { | ||
memo[key] = newItem; | ||
} | ||
} | ||
return memo; | ||
}, memo); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.