Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Header notification updates (#16425)
* remove middleware that sets notification flags

* move all notification handling into includes/header-notification.html

* update tests
  • Loading branch information
sarahs authored Nov 12, 2020
commit 5705d334caa89695cf04caa5fb12a8b31b1a3e5e
36 changes: 31 additions & 5 deletions includes/header-notification.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,37 @@
<!-- START TRANSLATIONS NOTICES -->
<!-- Site policy translations notice -->
{% if currentLanguage != 'en' and page.relativePath contains '/site-policy/' %}
{% assign translation_notification_type = "true" %}
{% assign translation_notification = site.data.reusables.policies.translation %}

<!-- Completed translations notice -->
{% elsif currentLanguage != 'en' && !languages[currentLanguage].wip %}
{% assign translation_notification_type = "true" %}
{% assign translation_notification = site.data.ui.header.notices.localization_complete %}

<!-- In-progress translations notice -->
{% elsif currentLanguage != 'en' && languages[currentLanguage].wip %}
{% assign translation_notification_type = "true" %}
{% assign translation_notification = site.data.ui.header.notices.localization_in_progress %}
{% endif %}
<!-- END TRANSLATIONS NOTICES -->

<!-- START RELEASE NOTICES -->
<!-- Custom GitHub AE notice -->
{% if currentVersion == "github-ae@latest" %}
<div class="header-notifications text-center f5 bg-blue-1 text-gray-dark py-4 px-6 limited_release {% if header_notification %}border-bottom{% endif %}">
{% data ui.header.notices.ghae_silent_launch %}
{% assign release_notification_type = "true" %}
{% assign release_notification = site.data.ui.header.notices.ghae_silent_launch %}
{% endif %}
<!-- END RELEASE NOTICES -->

{% if translation_notification_type %}
<div class="header-notifications text-center f5 bg-blue-1 text-gray-dark py-4 px-6 translation_notice{% if release_notification_type %} border-bottom border-black-fade{% endif %}">
{{ translation_notification }}
</div>
{% endif %}

{% if header_notification %}
<div class="header-notifications text-center f5 bg-blue-1 text-gray-dark py-4 px-6 {{ header_notification_type }}">
{{ header_notification }}
{% if release_notification_type %}
<div class="header-notifications text-center f5 bg-blue-1 text-gray-dark py-4 px-6 release_notice">
{{ release_notification }}
</div>
{% endif %}
18 changes: 0 additions & 18 deletions includes/header.html
Original file line number Diff line number Diff line change
@@ -1,22 +1,4 @@
<div class="border-bottom border-gray-light no-print">

{% 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 %}

<header class="container-xl px-3 px-md-6 pt-3 pb-2 position-relative d-flex flex-justify-between width-full {% if error == '404' %} d-md-none {% endif %}">
Expand Down
1 change: 0 additions & 1 deletion middleware/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'))
Expand Down
38 changes: 0 additions & 38 deletions middleware/notices.js

This file was deleted.

8 changes: 3 additions & 5 deletions tests/rendering/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
Expand All @@ -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)
})
})

Expand Down