Skip to content

Commit 696febf

Browse files
committed
Switch from a toggle to a button
1 parent 78f7bab commit 696febf

4 files changed

Lines changed: 13 additions & 24 deletions

File tree

language/en/webpushnotifications_module_ucp.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@
5353
'NOTIFY_WEBPUSH_POPUP_MESSAGE' => 'We would like to send you browser notifications for replies, private messages, and relevant forum activity. Optional — you can manage these settings at any time.',
5454
'NOTIFY_WEBPUSH_POPUP_ALLOW' => 'Allow',
5555
'NOTIFY_WEBPUSH_POPUP_DENY' => 'Deny',
56-
'NOTIFY_WEBPUSH_POPUP_DISABLE' => 'Disable “Allow Browser Notifications” prompts',
57-
'NOTIFY_WEBPUSH_POPUP_DISABLE_EXPLAIN' => 'Toggle this on to stop us from asking you to enable web push notifications on any of your devices. Note that we won’t be able to alert you if your web push notifications ever become disabled.',
56+
'NOTIFY_WEBPUSH_POPUP_DISABLE' => 'Notification reminder pop-ups',
57+
'NOTIFY_WEBPUSH_POPUP_DISABLE_EXPLAIN' => 'We show a reminder asking you to allow browser notifications when they are not currently enabled or when we cannot detect them. Turn this off to permanently stop these reminder pop-ups on all your devices. If you turn this off, you will not be warned if your browser notifications stop working in the future.',
58+
'NOTIFY_WEBPUSH_POPUP_ENABLER' => 'Enable reminders',
59+
'NOTIFY_WEBPUSH_POPUP_DISABLER' => 'Disable reminders',
5860
]);

styles/all/template/webpush.js

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -389,19 +389,10 @@ function PhpbbWebpush() {
389389
.then(data => {
390390
loadingIndicator.fadeOut(phpbb.alertTime);
391391
if (data.success) {
392-
// Update toggle icon based on new state
392+
// Update button text based on new state
393393
const button = document.getElementById('toggle_popup_prompt');
394394
if (button) {
395-
const icon = button.querySelector('i');
396-
if (icon) {
397-
if (data.disabled) {
398-
icon.classList.remove('fa-toggle-off');
399-
icon.classList.add('fa-toggle-on');
400-
} else {
401-
icon.classList.remove('fa-toggle-on');
402-
icon.classList.add('fa-toggle-off');
403-
}
404-
}
395+
button.value = data.disabled ? button.getAttribute('data-l-enable') : button.getAttribute('data-l-disable');
405396
}
406397
if ('form_tokens' in data) {
407398
updateFormTokens(data.form_tokens);

styles/prosilver/template/event/ucp_notifications_content_before.html

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@
1313
<dl>
1414
<dt><label for="toggle_popup_prompt">{{ lang('NOTIFY_WEBPUSH_POPUP_DISABLE') ~ lang('COLON') }}</label><br><span>{{ lang('NOTIFY_WEBPUSH_POPUP_DISABLE_EXPLAIN') }}</span></dt>
1515
<dd>
16-
<button id="toggle_popup_prompt" type="button" name="toggle_popup_prompt" aria-label="{{ lang('NOTIFY_WEBPUSH_POPUP_DISABLE') }}">
17-
<i class="icon icon-lg fa-fw fa-toggle-{% if S_WEBPUSH_POPUP_DISABLED %}on{% else %}off{% endif %}" aria-hidden="true"></i>
18-
</button>
16+
<input id="toggle_popup_prompt" type="button" name="toggle_popup_prompt" value="{% if S_WEBPUSH_POPUP_DISABLED %}{{ lang('NOTIFY_WEBPUSH_POPUP_ENABLER') }}{% else %}{{ lang('NOTIFY_WEBPUSH_POPUP_DISABLER') }}{% endif %}" class="button1 button button-form" data-l-disable="{{ lang('NOTIFY_WEBPUSH_POPUP_DISABLER')|e('html_attr') }}" data-l-enable="{{ lang('NOTIFY_WEBPUSH_POPUP_ENABLER')|e('html_attr') }}">
1917
</dd>
2018
</dl>
2119
{% endif %}

tests/functional/functional_test.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,9 @@ public function test_popup_preference_toggle()
178178
$this->assertCount(1, $crawler->filter('#toggle_popup_prompt'));
179179
$this->assertContainsLang('NOTIFY_WEBPUSH_POPUP_DISABLE', $crawler->filter('label[for="toggle_popup_prompt"]')->text());
180180

181-
// Assert toggle is initially off (prompts enabled)
182-
$toggle_icon = $crawler->filter('#toggle_popup_prompt i');
183-
$this->assertCount(1, $toggle_icon);
184-
$this->assertTrue($toggle_icon->attr('class') !== null && strpos($toggle_icon->attr('class'), 'fa-toggle-off') !== false);
181+
// Assert button text shows "Disable" initially (prompts enabled)
182+
$button_value = $crawler->filter('#toggle_popup_prompt')->attr('value');
183+
$this->assertContainsLang('NOTIFY_WEBPUSH_POPUP_DISABLER', $button_value);
185184

186185
// After user disables popup (in reality this would be via AJAX, but we test the state)
187186
// Set user preference to disabled via DB
@@ -194,10 +193,9 @@ public function test_popup_preference_toggle()
194193
// Reload page
195194
$crawler = self::request('GET', 'ucp.php?i=ucp_notifications&mode=notification_options');
196195

197-
// Assert toggle is now on (prompts disabled)
198-
$toggle_icon = $crawler->filter('#toggle_popup_prompt i');
199-
$this->assertCount(1, $toggle_icon);
200-
$this->assertTrue($toggle_icon->attr('class') !== null && strpos($toggle_icon->attr('class'), 'fa-toggle-on') !== false);
196+
// Assert button text shows "Enable" now (prompts disabled)
197+
$button_value = $crawler->filter('#toggle_popup_prompt')->attr('value');
198+
$this->assertContainsLang('NOTIFY_WEBPUSH_POPUP_ENABLER', $button_value);
201199

202200
// Assert popup is not shown on index when user has disabled it
203201
$crawler = self::request('GET', 'index.php');

0 commit comments

Comments
 (0)