diff options
| -rw-r--r-- | gui/src/main/notification-controller.ts | 31 | ||||
| -rw-r--r-- | gui/src/shared/notifications/account-expired.ts | 7 | ||||
| -rw-r--r-- | gui/src/shared/notifications/close-to-account-expiry.ts | 7 | ||||
| -rw-r--r-- | gui/src/shared/notifications/notification.ts | 7 | ||||
| -rw-r--r-- | gui/src/shared/notifications/unsupported-version.ts | 6 |
5 files changed, 42 insertions, 16 deletions
diff --git a/gui/src/main/notification-controller.ts b/gui/src/main/notification-controller.ts index c011ce7665..c5c30b42ef 100644 --- a/gui/src/main/notification-controller.ts +++ b/gui/src/main/notification-controller.ts @@ -9,6 +9,7 @@ import { ConnectingNotificationProvider, DisconnectedNotificationProvider, ErrorNotificationProvider, + NotificationAction, ReconnectingNotificationProvider, SystemNotification, SystemNotificationProvider, @@ -117,24 +118,30 @@ export default class NotificationController { timeoutType: systemNotification.critical ? 'never' : 'default', }); - if (systemNotification.action) { - notification.on('click', () => { - consumePromise( - this.notificationControllerDelegate.openLink( - systemNotification.action!.url, - systemNotification.action!.withAuth, - ), - ); - }); + // Action buttons are only available on macOS. + if (process.platform === 'darwin') { + if (systemNotification.action) { + notification.actions = [{ type: 'button', text: systemNotification.action.text }]; + notification.on('action', () => this.performAction(systemNotification.action)); + } + notification.on('click', () => this.notificationControllerDelegate.openApp()); } else { - notification.on('click', () => { - this.notificationControllerDelegate.openApp(); - }); + if (systemNotification.action) { + notification.on('click', () => this.performAction(systemNotification.action)); + } else { + notification.on('click', () => this.notificationControllerDelegate.openApp()); + } } return notification; } + private performAction(action?: NotificationAction) { + if (action && action.type === 'open-url') { + consumePromise(this.notificationControllerDelegate.openLink(action.url, action.withAuth)); + } + } + private showTunnelStateNotification(systemNotification: SystemNotification) { const message = systemNotification.message; const lastAnnouncement = this.lastTunnelStateAnnouncement; diff --git a/gui/src/shared/notifications/account-expired.ts b/gui/src/shared/notifications/account-expired.ts index ea600aa577..c89845bc4b 100644 --- a/gui/src/shared/notifications/account-expired.ts +++ b/gui/src/shared/notifications/account-expired.ts @@ -28,7 +28,12 @@ export class AccountExpiredNotificationProvider implements SystemNotificationPro ), critical: true, presentOnce: { value: true, name: this.constructor.name }, - action: { type: 'open-url', url: links.purchase, withAuth: true }, + action: { + type: 'open-url', + url: links.purchase, + withAuth: true, + text: messages.pgettext('notifications', 'Buy more'), + }, }; } } diff --git a/gui/src/shared/notifications/close-to-account-expiry.ts b/gui/src/shared/notifications/close-to-account-expiry.ts index b30aff2542..ad1969929f 100644 --- a/gui/src/shared/notifications/close-to-account-expiry.ts +++ b/gui/src/shared/notifications/close-to-account-expiry.ts @@ -41,7 +41,12 @@ export class CloseToAccountExpiryNotificationProvider return { message, critical: true, - action: { type: 'open-url', url: links.purchase, withAuth: true }, + action: { + type: 'open-url', + url: links.purchase, + withAuth: true, + text: messages.pgettext('notifications', 'Buy more'), + }, }; } diff --git a/gui/src/shared/notifications/notification.ts b/gui/src/shared/notifications/notification.ts index 98b50d4d24..adbf3ae746 100644 --- a/gui/src/shared/notifications/notification.ts +++ b/gui/src/shared/notifications/notification.ts @@ -1,4 +1,9 @@ -export type NotificationAction = { type: 'open-url'; url: string; withAuth?: boolean }; +export type NotificationAction = { + type: 'open-url'; + url: string; + text?: string; + withAuth?: boolean; +}; export type InAppNotificationIndicatorType = 'success' | 'warning' | 'error'; diff --git a/gui/src/shared/notifications/unsupported-version.ts b/gui/src/shared/notifications/unsupported-version.ts index fd2e0b5c72..097a142815 100644 --- a/gui/src/shared/notifications/unsupported-version.ts +++ b/gui/src/shared/notifications/unsupported-version.ts @@ -27,7 +27,11 @@ export class UnsupportedVersionNotificationProvider return { message, critical: true, - action: { type: 'open-url', url: links.download }, + action: { + type: 'open-url', + url: links.download, + text: messages.pgettext('notifications', 'Upgrade'), + }, presentOnce: { value: true, name: this.constructor.name }, suppressInDevelopment: true, }; |
