Skip to content

Commit f6fb09e

Browse files
authored
Fix requireInteraction by setting priority to 0 instead of 2. Also added a context menu option to test notification popups. (#22)
1 parent 02176fc commit f6fb09e

2 files changed

Lines changed: 28 additions & 2 deletions

File tree

pd-notifier/background/pd-notifier.js

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ function PagerDutyNotifier()
9494
// This will handle the event triggered from clicking one of the notification's buttons.
9595
self.handlerButtonClicked = function handlerButtonClicked(notificationId, buttonIndex)
9696
{
97+
if (notificationId == 'test') { return; } // Ignore for test notifications.
98+
9799
switch (buttonIndex)
98100
{
99101
case 0: // Acknowledge
@@ -117,6 +119,7 @@ function PagerDutyNotifier()
117119
// This will handle the event triggered when clicking on the main notification area.
118120
self.handlerNotificationClicked = function handlerNotificationClicked(notificationId)
119121
{
122+
if (notificationId == 'test') { return; } // Ignore for test notifications.
120123
window.open('https://' + self.account + '.pagerduty.com/incidents/' + notificationId);
121124
}
122125

@@ -252,7 +255,7 @@ function PagerDutyNotifier()
252255
title: incident.summary,
253256
message: "Service: " + incident.service.summary,
254257
contextMessage: incident.urgency.charAt(0).toUpperCase() + incident.urgency.slice(1) + " Urgency",
255-
priority: 2,
258+
priority: 0,
256259
isClickable: true,
257260
buttons: buttons,
258261
requireInteraction: self.requireInteraction
@@ -335,6 +338,29 @@ chrome.contextMenus.onClicked.addListener(function(info, tab)
335338
}
336339
});
337340

341+
// Add option to trigger a test notification popup.
342+
chrome.contextMenus.create({
343+
title: "Show test notification",
344+
id: "pd_test_notification",
345+
contexts: ["browser_action"],
346+
visible: true
347+
});
348+
349+
chrome.contextMenus.onClicked.addListener(function(info, tab)
350+
{
351+
if (info.menuItemId === "pd_test_notification")
352+
{
353+
_pdNotifier.triggerNotification({
354+
'id': 'test',
355+
'summary': 'Test Notification',
356+
'service': {
357+
'summary': 'Test Service'
358+
},
359+
'urgency': 'high'
360+
})
361+
}
362+
});
363+
338364
// Listen for Chrome Alarms and retrigger the notifier when one is caught.
339365
chrome.alarms.onAlarm.addListener(function(alarm)
340366
{

pd-notifier/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"name": "PagerDuty Notifier",
44
"short_name": "PD Notifier",
55
"description": "Desktop notifications for your PagerDuty incidents.",
6-
"version": "0.22",
6+
"version": "0.23",
77
"author": "Rich Adams (https://richadams.me)",
88
"icons": {
99
"16": "images/icon-16.png",

0 commit comments

Comments
 (0)