diff --git a/includes/header-notification.html b/includes/header-notification.html index 928ba01d94..416f6686b1 100644 --- a/includes/header-notification.html +++ b/includes/header-notification.html @@ -1,11 +1,37 @@ + + +{% if currentLanguage != 'en' and page.relativePath contains '/site-policy/' %} + {% assign translation_notification_type = "true" %} + {% assign translation_notification = site.data.reusables.policies.translation %} + + +{% elsif currentLanguage != 'en' && !languages[currentLanguage].wip %} + {% assign translation_notification_type = "true" %} + {% assign translation_notification = site.data.ui.header.notices.localization_complete %} + + +{% elsif currentLanguage != 'en' && languages[currentLanguage].wip %} + {% assign translation_notification_type = "true" %} + {% assign translation_notification = site.data.ui.header.notices.localization_in_progress %} +{% endif %} + + + + {% if currentVersion == "github-ae@latest" %} -
- {% data ui.header.notices.ghae_silent_launch %} + {% assign release_notification_type = "true" %} + {% assign release_notification = site.data.ui.header.notices.ghae_silent_launch %} +{% endif %} + + +{% if translation_notification_type %} +
+ {{ translation_notification }}
{% endif %} -{% if header_notification %} -
- {{ header_notification }} +{% if release_notification_type %} +
+ {{ release_notification }}
{% endif %} diff --git a/includes/header.html b/includes/header.html index 491c584044..978031b26b 100644 --- a/includes/header.html +++ b/includes/header.html @@ -1,22 +1,4 @@
- - {% if currentLanguage != 'en' and page.relativePath contains '/site-policy/' %} - {% assign header_notification_type = "translation_policy" %} - {% assign header_notification = site.data.reusables.policies.translation %} - - {% elsif site.data.ui.header.notices.flags.localization_complete == true %} - {% assign header_notification_type = "localization_complete" %} - {% assign header_notification = site.data.ui.header.notices.localization_complete %} - - {% elsif site.data.ui.header.notices.flags.localization_in_progress == true %} - {% assign header_notification_type = "localization_in_progress" %} - {% assign header_notification = site.data.ui.header.notices.localization_in_progress %} - - {% elsif currentLanguage == 'en' and site.data.ui.header.notices.flags.product_in_progress == true %} - {% assign header_notification_type = "product_in_progress" %} - {% assign header_notification = site.data.ui.header.notices.product_in_progress %} - {% endif %} - {% include header-notification %}
diff --git a/middleware/index.js b/middleware/index.js index 30f7762ddc..19ebf17ba6 100644 --- a/middleware/index.js +++ b/middleware/index.js @@ -42,7 +42,6 @@ module.exports = function (app) { app.use(require('./early-access-paths')) app.use(require('./early-access-proxy')) app.use(require('./find-page')) - app.use(require('./notices')) app.use(require('./archived-enterprise-versions')) app.use(require('./archived-enterprise-versions-assets')) app.use('/assets', express.static('assets')) diff --git a/middleware/notices.js b/middleware/notices.js deleted file mode 100644 index 5b8e5a1b7d..0000000000 --- a/middleware/notices.js +++ /dev/null @@ -1,38 +0,0 @@ -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() -} diff --git a/tests/rendering/header.js b/tests/rendering/header.js index 0063274091..4965bc037d 100644 --- a/tests/rendering/header.js +++ b/tests/rendering/header.js @@ -42,15 +42,13 @@ describe('header', () => { describe('notices', () => { test('displays a "localization in progress" notice for WIP languages', async () => { const $ = await getDOM('/de') - expect($('.header-notifications.localization_in_progress').length).toBe(1) - expect($('.localization_complete').length).toBe(0) + expect($('.header-notifications.translation_notice').length).toBe(1) expect($('.header-notifications a[href="/en"]').length).toBe(1) }) test('displays "complete" notice for non-WIP non-English languages', async () => { const $ = await getDOM('/ja') - expect($('.header-notifications.localization_complete').length).toBe(1) - expect($('.localization_in_progress').length).toBe(0) + expect($('.header-notifications.translation_notice').length).toBe(1) expect($('.header-notifications a[href="/en"]').length).toBe(1) expect($('.header-notifications a[href*="github.com/contact"]').length).toBe(1) }) @@ -62,7 +60,7 @@ describe('header', () => { test('displays translation disclaimer notice on localized site-policy pages', async () => { const $ = await getDOM('/ja/github/site-policy/github-logo-policy') - expect($('.header-notifications.translation_policy a[href="https://github.com/github/site-policy/issues"]').length).toBe(1) + expect($('.header-notifications.translation_notice a[href="https://github.com/github/site-policy/issues"]').length).toBe(1) }) })