Skip to content

Commit 5705d33

Browse files
authored
Header notification updates (#16425)
* remove middleware that sets notification flags * move all notification handling into includes/header-notification.html * update tests
1 parent 8788ab7 commit 5705d33

File tree

5 files changed

+34
-67
lines changed

5 files changed

+34
-67
lines changed

includes/header-notification.html

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,37 @@
1+
<!-- START TRANSLATIONS NOTICES -->
2+
<!-- Site policy translations notice -->
3+
{% if currentLanguage != 'en' and page.relativePath contains '/site-policy/' %}
4+
{% assign translation_notification_type = "true" %}
5+
{% assign translation_notification = site.data.reusables.policies.translation %}
6+
7+
<!-- Completed translations notice -->
8+
{% elsif currentLanguage != 'en' && !languages[currentLanguage].wip %}
9+
{% assign translation_notification_type = "true" %}
10+
{% assign translation_notification = site.data.ui.header.notices.localization_complete %}
11+
12+
<!-- In-progress translations notice -->
13+
{% elsif currentLanguage != 'en' && languages[currentLanguage].wip %}
14+
{% assign translation_notification_type = "true" %}
15+
{% assign translation_notification = site.data.ui.header.notices.localization_in_progress %}
16+
{% endif %}
17+
<!-- END TRANSLATIONS NOTICES -->
18+
19+
<!-- START RELEASE NOTICES -->
20+
<!-- Custom GitHub AE notice -->
121
{% if currentVersion == "github-ae@latest" %}
2-
<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 %}">
3-
{% data ui.header.notices.ghae_silent_launch %}
22+
{% assign release_notification_type = "true" %}
23+
{% assign release_notification = site.data.ui.header.notices.ghae_silent_launch %}
24+
{% endif %}
25+
<!-- END RELEASE NOTICES -->
26+
27+
{% if translation_notification_type %}
28+
<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 %}">
29+
{{ translation_notification }}
430
</div>
531
{% endif %}
632

7-
{% if header_notification %}
8-
<div class="header-notifications text-center f5 bg-blue-1 text-gray-dark py-4 px-6 {{ header_notification_type }}">
9-
{{ header_notification }}
33+
{% if release_notification_type %}
34+
<div class="header-notifications text-center f5 bg-blue-1 text-gray-dark py-4 px-6 release_notice">
35+
{{ release_notification }}
1036
</div>
1137
{% endif %}

includes/header.html

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,4 @@
11
<div class="border-bottom border-gray-light no-print">
2-
3-
{% if currentLanguage != 'en' and page.relativePath contains '/site-policy/' %}
4-
{% assign header_notification_type = "translation_policy" %}
5-
{% assign header_notification = site.data.reusables.policies.translation %}
6-
7-
{% elsif site.data.ui.header.notices.flags.localization_complete == true %}
8-
{% assign header_notification_type = "localization_complete" %}
9-
{% assign header_notification = site.data.ui.header.notices.localization_complete %}
10-
11-
{% elsif site.data.ui.header.notices.flags.localization_in_progress == true %}
12-
{% assign header_notification_type = "localization_in_progress" %}
13-
{% assign header_notification = site.data.ui.header.notices.localization_in_progress %}
14-
15-
{% elsif currentLanguage == 'en' and site.data.ui.header.notices.flags.product_in_progress == true %}
16-
{% assign header_notification_type = "product_in_progress" %}
17-
{% assign header_notification = site.data.ui.header.notices.product_in_progress %}
18-
{% endif %}
19-
202
{% include header-notification %}
213

224
<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 %}">

middleware/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ module.exports = function (app) {
4242
app.use(require('./early-access-paths'))
4343
app.use(require('./early-access-proxy'))
4444
app.use(require('./find-page'))
45-
app.use(require('./notices'))
4645
app.use(require('./archived-enterprise-versions'))
4746
app.use(require('./archived-enterprise-versions-assets'))
4847
app.use('/assets', express.static('assets'))

middleware/notices.js

Lines changed: 0 additions & 38 deletions
This file was deleted.

tests/rendering/header.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,13 @@ describe('header', () => {
4242
describe('notices', () => {
4343
test('displays a "localization in progress" notice for WIP languages', async () => {
4444
const $ = await getDOM('/de')
45-
expect($('.header-notifications.localization_in_progress').length).toBe(1)
46-
expect($('.localization_complete').length).toBe(0)
45+
expect($('.header-notifications.translation_notice').length).toBe(1)
4746
expect($('.header-notifications a[href="/en"]').length).toBe(1)
4847
})
4948

5049
test('displays "complete" notice for non-WIP non-English languages', async () => {
5150
const $ = await getDOM('/ja')
52-
expect($('.header-notifications.localization_complete').length).toBe(1)
53-
expect($('.localization_in_progress').length).toBe(0)
51+
expect($('.header-notifications.translation_notice').length).toBe(1)
5452
expect($('.header-notifications a[href="/en"]').length).toBe(1)
5553
expect($('.header-notifications a[href*="github.com/contact"]').length).toBe(1)
5654
})
@@ -62,7 +60,7 @@ describe('header', () => {
6260

6361
test('displays translation disclaimer notice on localized site-policy pages', async () => {
6462
const $ = await getDOM('/ja/github/site-policy/github-logo-policy')
65-
expect($('.header-notifications.translation_policy a[href="https://github.com/github/site-policy/issues"]').length).toBe(1)
63+
expect($('.header-notifications.translation_notice a[href="https://github.com/github/site-policy/issues"]').length).toBe(1)
6664
})
6765
})
6866

0 commit comments

Comments
 (0)