diff options
| author | Oskar Nyberg <oskar@mullvad.net> | 2023-02-09 10:53:22 +0100 |
|---|---|---|
| committer | Oskar Nyberg <oskar@mullvad.net> | 2023-02-09 10:53:22 +0100 |
| commit | 9f9996b47029bceb9582ffdd5199a1db10287e8f (patch) | |
| tree | a867bca5026dc75a4378437c7ebd017ebb9fbf7e /gui/src/shared | |
| parent | a452a38ed484da45d483150ca35a38705b007dfc (diff) | |
| parent | 8e4170b381f275f6aae787bffc624294b34be1b6 (diff) | |
| download | mullvadvpn-9f9996b47029bceb9582ffdd5199a1db10287e8f.tar.xz mullvadvpn-9f9996b47029bceb9582ffdd5199a1db10287e8f.zip | |
Merge branch 'improve-notifications'
Diffstat (limited to 'gui/src/shared')
| -rw-r--r-- | gui/src/shared/notifications/account-expired.ts | 10 | ||||
| -rw-r--r-- | gui/src/shared/notifications/block-when-disconnected.ts | 22 | ||||
| -rw-r--r-- | gui/src/shared/notifications/close-to-account-expiry.ts | 5 | ||||
| -rw-r--r-- | gui/src/shared/notifications/connected.ts | 12 | ||||
| -rw-r--r-- | gui/src/shared/notifications/connecting.ts | 9 | ||||
| -rw-r--r-- | gui/src/shared/notifications/disconnected.ts | 12 | ||||
| -rw-r--r-- | gui/src/shared/notifications/error.ts | 11 | ||||
| -rw-r--r-- | gui/src/shared/notifications/inconsistent-version.ts | 5 | ||||
| -rw-r--r-- | gui/src/shared/notifications/notification.ts | 18 | ||||
| -rw-r--r-- | gui/src/shared/notifications/reconnecting.ts | 9 | ||||
| -rw-r--r-- | gui/src/shared/notifications/unsupported-version.ts | 5 | ||||
| -rw-r--r-- | gui/src/shared/notifications/update-available.ts | 5 |
12 files changed, 102 insertions, 21 deletions
diff --git a/gui/src/shared/notifications/account-expired.ts b/gui/src/shared/notifications/account-expired.ts index cbfc782eeb..a7af4f2c8b 100644 --- a/gui/src/shared/notifications/account-expired.ts +++ b/gui/src/shared/notifications/account-expired.ts @@ -2,7 +2,12 @@ import { links } from '../../config.json'; import { hasExpired } from '../account-expiry'; import { TunnelState } from '../daemon-rpc-types'; import { messages } from '../gettext'; -import { SystemNotification, SystemNotificationProvider } from './notification'; +import { + SystemNotification, + SystemNotificationCategory, + SystemNotificationProvider, + SystemNotificationSeverityType, +} from './notification'; interface AccountExpiredNotificaitonContext { accountExpiry: string; @@ -23,7 +28,8 @@ export class AccountExpiredNotificationProvider implements SystemNotificationPro public getSystemNotification(): SystemNotification { return { message: messages.pgettext('notifications', 'Account is out of time'), - critical: true, + category: SystemNotificationCategory.expiry, + severity: SystemNotificationSeverityType.high, presentOnce: { value: true, name: this.constructor.name }, action: { type: 'open-url', diff --git a/gui/src/shared/notifications/block-when-disconnected.ts b/gui/src/shared/notifications/block-when-disconnected.ts index 91b464a299..c0b2f4e0f1 100644 --- a/gui/src/shared/notifications/block-when-disconnected.ts +++ b/gui/src/shared/notifications/block-when-disconnected.ts @@ -3,7 +3,14 @@ import { sprintf } from 'sprintf-js'; import { strings } from '../../config.json'; import { messages } from '../../shared/gettext'; import { TunnelState } from '../daemon-rpc-types'; -import { InAppNotification, InAppNotificationProvider } from './notification'; +import { + InAppNotification, + InAppNotificationProvider, + SystemNotification, + SystemNotificationCategory, + SystemNotificationProvider, + SystemNotificationSeverityType, +} from './notification'; interface BlockWhenDisconnectedNotificationContext { tunnelState: TunnelState; @@ -11,7 +18,8 @@ interface BlockWhenDisconnectedNotificationContext { hasExcludedApps: boolean; } -export class BlockWhenDisconnectedNotificationProvider implements InAppNotificationProvider { +export class BlockWhenDisconnectedNotificationProvider + implements InAppNotificationProvider, SystemNotificationProvider { public constructor(private context: BlockWhenDisconnectedNotificationContext) {} public mayDisplay() { @@ -22,6 +30,16 @@ export class BlockWhenDisconnectedNotificationProvider implements InAppNotificat ); } + public getSystemNotification(): SystemNotification { + const message = messages.pgettext('notifications', 'Lockdown mode active, connection blocked'); + + return { + message, + severity: SystemNotificationSeverityType.info, + category: SystemNotificationCategory.tunnelState, + }; + } + public getInAppNotification(): InAppNotification { const lockdownModeSettingName = messages.pgettext('vpn-settings-view', 'Lockdown mode'); let subtitle = sprintf( diff --git a/gui/src/shared/notifications/close-to-account-expiry.ts b/gui/src/shared/notifications/close-to-account-expiry.ts index 82daf05562..a3f5e749ad 100644 --- a/gui/src/shared/notifications/close-to-account-expiry.ts +++ b/gui/src/shared/notifications/close-to-account-expiry.ts @@ -8,7 +8,9 @@ import { InAppNotification, InAppNotificationProvider, SystemNotification, + SystemNotificationCategory, SystemNotificationProvider, + SystemNotificationSeverityType, } from './notification'; interface CloseToAccountExpiryNotificationContext { @@ -38,7 +40,8 @@ export class CloseToAccountExpiryNotificationProvider return { message, - critical: true, + category: SystemNotificationCategory.expiry, + severity: SystemNotificationSeverityType.medium, action: { type: 'open-url', url: links.purchase, diff --git a/gui/src/shared/notifications/connected.ts b/gui/src/shared/notifications/connected.ts index 5fc667b78c..c66339fe9e 100644 --- a/gui/src/shared/notifications/connected.ts +++ b/gui/src/shared/notifications/connected.ts @@ -2,14 +2,19 @@ import { sprintf } from 'sprintf-js'; import { messages } from '../../shared/gettext'; import { TunnelState } from '../daemon-rpc-types'; -import { SystemNotificationProvider } from './notification'; +import { + SystemNotification, + SystemNotificationCategory, + SystemNotificationProvider, + SystemNotificationSeverityType, +} from './notification'; export class ConnectedNotificationProvider implements SystemNotificationProvider { public constructor(private context: TunnelState) {} public mayDisplay = () => this.context.state === 'connected'; - public getSystemNotification() { + public getSystemNotification(): SystemNotification | undefined { if (this.context.state === 'connected') { let message = messages.pgettext('notifications', 'Connected'); const location = this.context.details.location?.hostname; @@ -27,7 +32,8 @@ export class ConnectedNotificationProvider implements SystemNotificationProvider return { message, - critical: false, + severity: SystemNotificationSeverityType.info, + category: SystemNotificationCategory.tunnelState, }; } else { return undefined; diff --git a/gui/src/shared/notifications/connecting.ts b/gui/src/shared/notifications/connecting.ts index b35d9ed3b6..214e015e10 100644 --- a/gui/src/shared/notifications/connecting.ts +++ b/gui/src/shared/notifications/connecting.ts @@ -5,7 +5,10 @@ import { TunnelState } from '../daemon-rpc-types'; import { InAppNotification, InAppNotificationProvider, + SystemNotification, + SystemNotificationCategory, SystemNotificationProvider, + SystemNotificationSeverityType, } from './notification'; interface ConnectingNotificationContext { @@ -21,7 +24,7 @@ export class ConnectingNotificationProvider return this.context.tunnelState.state === 'connecting' && !this.context.reconnecting; } - public getSystemNotification() { + public getSystemNotification(): SystemNotification | undefined { if (this.context.tunnelState.state === 'connecting') { let message = messages.pgettext('notifications', 'Connecting'); const location = this.context.tunnelState.details?.location?.hostname; @@ -39,7 +42,9 @@ export class ConnectingNotificationProvider return { message, - critical: false, + severity: SystemNotificationSeverityType.info, + category: SystemNotificationCategory.tunnelState, + throttle: true, }; } else { return undefined; diff --git a/gui/src/shared/notifications/disconnected.ts b/gui/src/shared/notifications/disconnected.ts index 05c53148ec..874cb11b3e 100644 --- a/gui/src/shared/notifications/disconnected.ts +++ b/gui/src/shared/notifications/disconnected.ts @@ -1,6 +1,11 @@ import { messages } from '../../shared/gettext'; import { TunnelState } from '../daemon-rpc-types'; -import { SystemNotificationProvider } from './notification'; +import { + SystemNotification, + SystemNotificationCategory, + SystemNotificationProvider, + SystemNotificationSeverityType, +} from './notification'; interface DisconnectedNotificationContext { tunnelState: TunnelState; @@ -13,10 +18,11 @@ export class DisconnectedNotificationProvider implements SystemNotificationProvi public mayDisplay = () => this.context.tunnelState.state === 'disconnected' && !this.context.blockWhenDisconnected; - public getSystemNotification() { + public getSystemNotification(): SystemNotification | undefined { return { message: messages.pgettext('notifications', 'Disconnected and unsecure'), - critical: false, + severity: SystemNotificationSeverityType.info, + category: SystemNotificationCategory.tunnelState, }; } } diff --git a/gui/src/shared/notifications/error.ts b/gui/src/shared/notifications/error.ts index fa1848a0fb..67267a494e 100644 --- a/gui/src/shared/notifications/error.ts +++ b/gui/src/shared/notifications/error.ts @@ -12,7 +12,10 @@ import { messages } from '../gettext'; import { InAppNotification, InAppNotificationProvider, + SystemNotification, + SystemNotificationCategory, SystemNotificationProvider, + SystemNotificationSeverityType, } from './notification'; interface ErrorNotificationContext { @@ -26,7 +29,7 @@ export class ErrorNotificationProvider public mayDisplay = () => this.context.tunnelState.state === 'error'; - public getSystemNotification() { + public getSystemNotification(): SystemNotification | undefined { if (this.context.tunnelState.state === 'error') { let message = getMessage(this.context.tunnelState.details); if (!this.context.tunnelState.details.blockingError && this.context.hasExcludedApps) { @@ -41,7 +44,11 @@ export class ErrorNotificationProvider return { message, - critical: !!this.context.tunnelState.details.blockingError, + severity: + this.context.tunnelState.details.blockingError === undefined + ? SystemNotificationSeverityType.low + : SystemNotificationSeverityType.high, + category: SystemNotificationCategory.tunnelState, }; } else { return undefined; diff --git a/gui/src/shared/notifications/inconsistent-version.ts b/gui/src/shared/notifications/inconsistent-version.ts index e6118c883e..f4a5616c43 100644 --- a/gui/src/shared/notifications/inconsistent-version.ts +++ b/gui/src/shared/notifications/inconsistent-version.ts @@ -3,7 +3,9 @@ import { InAppNotification, InAppNotificationProvider, SystemNotification, + SystemNotificationCategory, SystemNotificationProvider, + SystemNotificationSeverityType, } from './notification'; interface InconsistentVersionNotificationContext { @@ -19,7 +21,8 @@ export class InconsistentVersionNotificationProvider public getSystemNotification(): SystemNotification { return { message: messages.pgettext('notifications', 'App is out of sync. Please quit and restart.'), - critical: true, + category: SystemNotificationCategory.inconsistentVersion, + severity: SystemNotificationSeverityType.high, presentOnce: { value: true, name: this.constructor.name }, suppressInDevelopment: true, }; diff --git a/gui/src/shared/notifications/notification.ts b/gui/src/shared/notifications/notification.ts index 2152da0e79..10b5b21fc8 100644 --- a/gui/src/shared/notifications/notification.ts +++ b/gui/src/shared/notifications/notification.ts @@ -7,13 +7,29 @@ export type NotificationAction = { export type InAppNotificationIndicatorType = 'success' | 'warning' | 'error'; +export enum SystemNotificationSeverityType { + info = 0, + low, + medium, + high, +} + +export enum SystemNotificationCategory { + tunnelState, + expiry, + newVersion, + inconsistentVersion, +} + interface NotificationProvider { mayDisplay(): boolean; } export interface SystemNotification { message: string; - critical: boolean; + severity: SystemNotificationSeverityType; + category: SystemNotificationCategory; + throttle?: boolean; presentOnce?: { value: boolean; name: string }; suppressInDevelopment?: boolean; action?: NotificationAction; diff --git a/gui/src/shared/notifications/reconnecting.ts b/gui/src/shared/notifications/reconnecting.ts index 9c20cad8c9..43491322f0 100644 --- a/gui/src/shared/notifications/reconnecting.ts +++ b/gui/src/shared/notifications/reconnecting.ts @@ -3,7 +3,10 @@ import { TunnelState } from '../daemon-rpc-types'; import { InAppNotification, InAppNotificationProvider, + SystemNotification, + SystemNotificationCategory, SystemNotificationProvider, + SystemNotificationSeverityType, } from './notification'; export class ReconnectingNotificationProvider @@ -14,10 +17,12 @@ export class ReconnectingNotificationProvider return this.context.state === 'disconnecting' && this.context.details === 'reconnect'; } - public getSystemNotification() { + public getSystemNotification(): SystemNotification | undefined { return { message: messages.pgettext('notifications', 'Reconnecting'), - critical: false, + severity: SystemNotificationSeverityType.info, + category: SystemNotificationCategory.tunnelState, + throttle: true, }; } diff --git a/gui/src/shared/notifications/unsupported-version.ts b/gui/src/shared/notifications/unsupported-version.ts index 3db1db9fc7..8c2f87460b 100644 --- a/gui/src/shared/notifications/unsupported-version.ts +++ b/gui/src/shared/notifications/unsupported-version.ts @@ -4,7 +4,9 @@ import { InAppNotification, InAppNotificationProvider, SystemNotification, + SystemNotificationCategory, SystemNotificationProvider, + SystemNotificationSeverityType, } from './notification'; interface UnsupportedVersionNotificationContext { @@ -25,7 +27,8 @@ export class UnsupportedVersionNotificationProvider public getSystemNotification(): SystemNotification { return { message: this.getMessage(), - critical: true, + category: SystemNotificationCategory.newVersion, + severity: SystemNotificationSeverityType.high, action: { type: 'open-url', url: this.context.suggestedIsBeta ? links.betaDownload : links.download, diff --git a/gui/src/shared/notifications/update-available.ts b/gui/src/shared/notifications/update-available.ts index 61a2452138..0394ef15a5 100644 --- a/gui/src/shared/notifications/update-available.ts +++ b/gui/src/shared/notifications/update-available.ts @@ -6,7 +6,9 @@ import { InAppNotification, InAppNotificationProvider, SystemNotification, + SystemNotificationCategory, SystemNotificationProvider, + SystemNotificationSeverityType, } from './notification'; interface UpdateAvailableNotificationContext { @@ -39,7 +41,8 @@ export class UpdateAvailableNotificationProvider public getSystemNotification(): SystemNotification { return { message: this.systemMessage(), - critical: false, + category: SystemNotificationCategory.newVersion, + severity: SystemNotificationSeverityType.medium, action: { type: 'open-url', url: this.context.suggestedIsBeta ? links.betaDownload : links.download, |
