summaryrefslogtreecommitdiffhomepage
path: root/gui/src/shared/notifications/disconnected.ts
blob: 874cb11b3e1ce21219a032dbab383d5ad4ff1cf7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import { messages } from '../../shared/gettext';
import { TunnelState } from '../daemon-rpc-types';
import {
  SystemNotification,
  SystemNotificationCategory,
  SystemNotificationProvider,
  SystemNotificationSeverityType,
} from './notification';

interface DisconnectedNotificationContext {
  tunnelState: TunnelState;
  blockWhenDisconnected: boolean;
}

export class DisconnectedNotificationProvider implements SystemNotificationProvider {
  public constructor(private context: DisconnectedNotificationContext) {}

  public mayDisplay = () =>
    this.context.tunnelState.state === 'disconnected' && !this.context.blockWhenDisconnected;

  public getSystemNotification(): SystemNotification | undefined {
    return {
      message: messages.pgettext('notifications', 'Disconnected and unsecure'),
      severity: SystemNotificationSeverityType.info,
      category: SystemNotificationCategory.tunnelState,
    };
  }
}