summaryrefslogtreecommitdiffhomepage
path: root/gui/src
diff options
context:
space:
mode:
authorOskar Nyberg <oskar@mullvad.net>2022-11-30 11:59:53 +0100
committerOskar Nyberg <oskar@mullvad.net>2023-02-09 10:39:26 +0100
commit9bc388cd020d0e4fc675e02b20522f31c2464885 (patch)
treed61f78e0b279aa6207415feb40d6529478098eb7 /gui/src
parent4dc8fe0cc75ca0b65c10bf05002d5ab8b0fe0e0b (diff)
downloadmullvadvpn-9bc388cd020d0e4fc675e02b20522f31c2464885.tar.xz
mullvadvpn-9bc388cd020d0e4fc675e02b20522f31c2464885.zip
Add severity to SystemNotification
Diffstat (limited to 'gui/src')
-rw-r--r--gui/src/main/notification-controller.ts18
-rw-r--r--gui/src/shared/notifications/account-expired.ts8
-rw-r--r--gui/src/shared/notifications/block-when-disconnected.ts20
-rw-r--r--gui/src/shared/notifications/close-to-account-expiry.ts3
-rw-r--r--gui/src/shared/notifications/connected.ts10
-rw-r--r--gui/src/shared/notifications/connecting.ts6
-rw-r--r--gui/src/shared/notifications/disconnected.ts10
-rw-r--r--gui/src/shared/notifications/error.ts9
-rw-r--r--gui/src/shared/notifications/inconsistent-version.ts3
-rw-r--r--gui/src/shared/notifications/notification.ts9
-rw-r--r--gui/src/shared/notifications/reconnecting.ts6
-rw-r--r--gui/src/shared/notifications/unsupported-version.ts3
-rw-r--r--gui/src/shared/notifications/update-available.ts3
13 files changed, 80 insertions, 28 deletions
diff --git a/gui/src/main/notification-controller.ts b/gui/src/main/notification-controller.ts
index 3ea65fa5a0..33149bcae8 100644
--- a/gui/src/main/notification-controller.ts
+++ b/gui/src/main/notification-controller.ts
@@ -13,6 +13,7 @@ import {
ReconnectingNotificationProvider,
SystemNotification,
SystemNotificationProvider,
+ SystemNotificationSeverityType,
} from '../shared/notifications/notification';
export interface NotificationSender {
@@ -111,10 +112,6 @@ export default class NotificationController {
this.addPendingNotification(notification);
notification.show();
- if (!systemNotification.critical) {
- setTimeout(() => notification.close(), 4000);
- }
-
return notification;
} else {
return;
@@ -127,7 +124,8 @@ export default class NotificationController {
body: systemNotification.message,
silent: true,
icon: this.notificationIcon,
- timeoutType: systemNotification.critical ? 'never' : 'default',
+ timeoutType:
+ systemNotification.severity == SystemNotificationSeverityType.high ? 'never' : 'default',
});
// Action buttons are only available on macOS.
@@ -137,7 +135,12 @@ export default class NotificationController {
notification.on('action', () => this.performAction(systemNotification.action));
}
notification.on('click', () => this.notificationControllerDelegate.openApp());
- } else if (!(process.platform === 'win32' && systemNotification.critical)) {
+ } else if (
+ !(
+ process.platform === 'win32' &&
+ systemNotification.severity === SystemNotificationSeverityType.high
+ )
+ ) {
if (systemNotification.action) {
notification.on('click', () => this.performAction(systemNotification.action));
} else {
@@ -208,7 +211,8 @@ export default class NotificationController {
const suppressDueToDevelopment =
notification.suppressInDevelopment && process.env.NODE_ENV === 'development';
const suppressDueToVisibleWindow = isWindowVisible;
- const suppressDueToPreference = !areSystemNotificationsEnabled && !notification.critical;
+ const suppressDueToPreference =
+ !areSystemNotificationsEnabled && notification.severity > SystemNotificationSeverityType.info;
return (
!suppressDueToDevelopment &&
diff --git a/gui/src/shared/notifications/account-expired.ts b/gui/src/shared/notifications/account-expired.ts
index cbfc782eeb..42e40aa491 100644
--- a/gui/src/shared/notifications/account-expired.ts
+++ b/gui/src/shared/notifications/account-expired.ts
@@ -2,7 +2,11 @@ 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,
+ SystemNotificationProvider,
+ SystemNotificationSeverityType,
+} from './notification';
interface AccountExpiredNotificaitonContext {
accountExpiry: string;
@@ -23,7 +27,7 @@ export class AccountExpiredNotificationProvider implements SystemNotificationPro
public getSystemNotification(): SystemNotification {
return {
message: messages.pgettext('notifications', 'Account is out of time'),
- critical: true,
+ 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..0eada4036c 100644
--- a/gui/src/shared/notifications/block-when-disconnected.ts
+++ b/gui/src/shared/notifications/block-when-disconnected.ts
@@ -3,7 +3,13 @@ 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,
+ SystemNotificationProvider,
+ SystemNotificationSeverityType,
+} from './notification';
interface BlockWhenDisconnectedNotificationContext {
tunnelState: TunnelState;
@@ -11,7 +17,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 +29,15 @@ export class BlockWhenDisconnectedNotificationProvider implements InAppNotificat
);
}
+ public getSystemNotification(): SystemNotification {
+ const message = messages.pgettext('notifications', 'Lockdown mode active, connection blocked');
+
+ return {
+ message,
+ severity: SystemNotificationSeverityType.info,
+ };
+ }
+
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..2a9fc1a384 100644
--- a/gui/src/shared/notifications/close-to-account-expiry.ts
+++ b/gui/src/shared/notifications/close-to-account-expiry.ts
@@ -9,6 +9,7 @@ import {
InAppNotificationProvider,
SystemNotification,
SystemNotificationProvider,
+ SystemNotificationSeverityType,
} from './notification';
interface CloseToAccountExpiryNotificationContext {
@@ -38,7 +39,7 @@ export class CloseToAccountExpiryNotificationProvider
return {
message,
- critical: true,
+ 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..bcce249a15 100644
--- a/gui/src/shared/notifications/connected.ts
+++ b/gui/src/shared/notifications/connected.ts
@@ -2,14 +2,18 @@ import { sprintf } from 'sprintf-js';
import { messages } from '../../shared/gettext';
import { TunnelState } from '../daemon-rpc-types';
-import { SystemNotificationProvider } from './notification';
+import {
+ SystemNotification,
+ 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 +31,7 @@ export class ConnectedNotificationProvider implements SystemNotificationProvider
return {
message,
- critical: false,
+ severity: SystemNotificationSeverityType.low,
};
} else {
return undefined;
diff --git a/gui/src/shared/notifications/connecting.ts b/gui/src/shared/notifications/connecting.ts
index b35d9ed3b6..bf8d3b1248 100644
--- a/gui/src/shared/notifications/connecting.ts
+++ b/gui/src/shared/notifications/connecting.ts
@@ -5,7 +5,9 @@ import { TunnelState } from '../daemon-rpc-types';
import {
InAppNotification,
InAppNotificationProvider,
+ SystemNotification,
SystemNotificationProvider,
+ SystemNotificationSeverityType,
} from './notification';
interface ConnectingNotificationContext {
@@ -21,7 +23,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 +41,7 @@ export class ConnectingNotificationProvider
return {
message,
- critical: false,
+ severity: SystemNotificationSeverityType.low,
};
} else {
return undefined;
diff --git a/gui/src/shared/notifications/disconnected.ts b/gui/src/shared/notifications/disconnected.ts
index 05c53148ec..66a1e9d66e 100644
--- a/gui/src/shared/notifications/disconnected.ts
+++ b/gui/src/shared/notifications/disconnected.ts
@@ -1,6 +1,10 @@
import { messages } from '../../shared/gettext';
import { TunnelState } from '../daemon-rpc-types';
-import { SystemNotificationProvider } from './notification';
+import {
+ SystemNotification,
+ SystemNotificationProvider,
+ SystemNotificationSeverityType,
+} from './notification';
interface DisconnectedNotificationContext {
tunnelState: TunnelState;
@@ -13,10 +17,10 @@ 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,
};
}
}
diff --git a/gui/src/shared/notifications/error.ts b/gui/src/shared/notifications/error.ts
index fa1848a0fb..f066bc1040 100644
--- a/gui/src/shared/notifications/error.ts
+++ b/gui/src/shared/notifications/error.ts
@@ -12,7 +12,9 @@ import { messages } from '../gettext';
import {
InAppNotification,
InAppNotificationProvider,
+ SystemNotification,
SystemNotificationProvider,
+ SystemNotificationSeverityType,
} from './notification';
interface ErrorNotificationContext {
@@ -26,7 +28,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 +43,10 @@ export class ErrorNotificationProvider
return {
message,
- critical: !!this.context.tunnelState.details.blockingError,
+ severity:
+ this.context.tunnelState.details.blockingError === undefined
+ ? SystemNotificationSeverityType.low
+ : SystemNotificationSeverityType.high,
};
} else {
return undefined;
diff --git a/gui/src/shared/notifications/inconsistent-version.ts b/gui/src/shared/notifications/inconsistent-version.ts
index e6118c883e..3334f9e99c 100644
--- a/gui/src/shared/notifications/inconsistent-version.ts
+++ b/gui/src/shared/notifications/inconsistent-version.ts
@@ -4,6 +4,7 @@ import {
InAppNotificationProvider,
SystemNotification,
SystemNotificationProvider,
+ SystemNotificationSeverityType,
} from './notification';
interface InconsistentVersionNotificationContext {
@@ -19,7 +20,7 @@ export class InconsistentVersionNotificationProvider
public getSystemNotification(): SystemNotification {
return {
message: messages.pgettext('notifications', 'App is out of sync. Please quit and restart.'),
- critical: true,
+ 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..af95baa558 100644
--- a/gui/src/shared/notifications/notification.ts
+++ b/gui/src/shared/notifications/notification.ts
@@ -7,13 +7,20 @@ export type NotificationAction = {
export type InAppNotificationIndicatorType = 'success' | 'warning' | 'error';
+export enum SystemNotificationSeverityType {
+ info = 0,
+ low,
+ medium,
+ high,
+}
+
interface NotificationProvider {
mayDisplay(): boolean;
}
export interface SystemNotification {
message: string;
- critical: boolean;
+ severity: SystemNotificationSeverityType;
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..caea454eff 100644
--- a/gui/src/shared/notifications/reconnecting.ts
+++ b/gui/src/shared/notifications/reconnecting.ts
@@ -3,7 +3,9 @@ import { TunnelState } from '../daemon-rpc-types';
import {
InAppNotification,
InAppNotificationProvider,
+ SystemNotification,
SystemNotificationProvider,
+ SystemNotificationSeverityType,
} from './notification';
export class ReconnectingNotificationProvider
@@ -14,10 +16,10 @@ 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,
};
}
diff --git a/gui/src/shared/notifications/unsupported-version.ts b/gui/src/shared/notifications/unsupported-version.ts
index 3db1db9fc7..3a012e1aad 100644
--- a/gui/src/shared/notifications/unsupported-version.ts
+++ b/gui/src/shared/notifications/unsupported-version.ts
@@ -5,6 +5,7 @@ import {
InAppNotificationProvider,
SystemNotification,
SystemNotificationProvider,
+ SystemNotificationSeverityType,
} from './notification';
interface UnsupportedVersionNotificationContext {
@@ -25,7 +26,7 @@ export class UnsupportedVersionNotificationProvider
public getSystemNotification(): SystemNotification {
return {
message: this.getMessage(),
- critical: true,
+ 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..2205274cc6 100644
--- a/gui/src/shared/notifications/update-available.ts
+++ b/gui/src/shared/notifications/update-available.ts
@@ -7,6 +7,7 @@ import {
InAppNotificationProvider,
SystemNotification,
SystemNotificationProvider,
+ SystemNotificationSeverityType,
} from './notification';
interface UpdateAvailableNotificationContext {
@@ -39,7 +40,7 @@ export class UpdateAvailableNotificationProvider
public getSystemNotification(): SystemNotification {
return {
message: this.systemMessage(),
- critical: false,
+ severity: SystemNotificationSeverityType.medium,
action: {
type: 'open-url',
url: this.context.suggestedIsBeta ? links.betaDownload : links.download,