1
0
mirror of synced 2025-12-21 02:46:50 -05:00
Files
docs/middleware/notices.js
Sarah Schneider aa5a62d49d Remove versions feature flag code (#15793)
* remove FEATURE_NEW_VERSIONS from feature-flags.json

* remove process.env.FEATURE_NEW_VERSIONS from include files

* remove process.env.FEATURE_NEW_VERSIONS from lib files

* remove process.env.FEATURE_NEW_VERSIONS from middleware files

* remove process.env.FEATURE_NEW_VERSIONS from script files

* remove process.env.FEATURE_NEW_VERSIONS from test files

* update test fixtures to use new versions as canonical fixtures
2020-09-29 13:36:07 -04:00

39 lines
1.1 KiB
JavaScript

const { set } = require('lodash')
const patterns = require('../lib/patterns')
const languages = require('../lib/languages')
module.exports = (req, res, next) => {
// Skip asset paths
if (patterns.assetPaths.test(req.path)) return next()
const language = languages[req.language]
// Set flag that enables `localization_complete` message for no-longer-WIP languages
set(
req.context,
'site.data.ui.header.notices.flags.localization_complete',
language.code !== 'en' && !language.wip
)
// Set flag that enables `localization_in_progress` message for WIP languages
set(
req.context,
'site.data.ui.header.notices.flags.localization_in_progress',
language.wip
)
const currentProduct = req.context.allProducts[req.context.currentProduct]
// if this is the homepage and no product is chosen yet, return early
if (!currentProduct) return next()
// Set flag that enables `product_in_progress` message for WIP products
set(
req.context,
'site.data.ui.header.notices.flags.product_in_progress',
currentProduct.wip
)
return next()
}