MCPcopy Create free account
hub / github.com/DTStack/molecule / NotificationController

Class NotificationController

src/controller/notification.tsx:33–107  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31
32@singleton()
33export class NotificationController
34 extends Controller
35 implements INotificationController
36{
37 private readonly notificationService: INotificationService;
38 private readonly statusBarService: IStatusBarService;
39 private readonly builtinService: IBuiltinService;
40
41 constructor() {
42 super();
43 this.notificationService = container.resolve(NotificationService);
44 this.statusBarService = container.resolve(StatusBarService);
45 this.builtinService = container.resolve(BuiltinService);
46 }
47
48 public onCloseNotification = (item: INotificationItem<any>): void => {
49 this.notificationService.remove(item.id);
50 };
51
52 public toggleNotifications() {
53 this.notificationService.toggleNotification();
54 }
55
56 public onClick = (e: React.MouseEvent, item: IStatusBarItem) => {
57 this.toggleNotifications();
58 };
59
60 public onActionBarClick = (
61 event: React.MouseEvent<Element, MouseEvent>,
62 item: IActionBarItemProps<any>
63 ) => {
64 const action = item.id;
65 const { NOTIFICATION_CLEAR_ALL_ID, NOTIFICATION_HIDE_ID } =
66 this.builtinService.getConstants();
67
68 if (action === NOTIFICATION_CLEAR_ALL_ID) {
69 this.notificationService.clear();
70 } else if (action === NOTIFICATION_HIDE_ID) {
71 this.toggleNotifications();
72 }
73 };
74
75 public initView() {
76 const {
77 builtInNotification,
78 NOTIFICATION_CLEAR_ALL,
79 NOTIFICATION_HIDE,
80 } = this.builtinService.getModules();
81
82 if (builtInNotification) {
83 const NotificationView = connect(
84 this.notificationService,
85 NotificationStatusBarView
86 );
87 /* istanbul ignore next */
88 const defaultNotification = {
89 ...builtInNotification,
90 actionBar: [NOTIFICATION_CLEAR_ALL, NOTIFICATION_HIDE].filter(

Callers

nothing calls this directly

Calls 4

toggleNotificationsMethod · 0.95
removeMethod · 0.65
getConstantsMethod · 0.65
clearMethod · 0.65

Tested by

no test coverage detected