Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/workbench/browser/parts/notifications/notificationsActions.ts
3296 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import './media/notificationsActions.css';
7
import { INotificationViewItem } from '../../../common/notifications.js';
8
import { localize } from '../../../../nls.js';
9
import { Action } from '../../../../base/common/actions.js';
10
import { CLEAR_NOTIFICATION, EXPAND_NOTIFICATION, COLLAPSE_NOTIFICATION, CLEAR_ALL_NOTIFICATIONS, HIDE_NOTIFICATIONS_CENTER, TOGGLE_DO_NOT_DISTURB_MODE, TOGGLE_DO_NOT_DISTURB_MODE_BY_SOURCE } from './notificationsCommands.js';
11
import { ICommandService } from '../../../../platform/commands/common/commands.js';
12
import { IClipboardService } from '../../../../platform/clipboard/common/clipboardService.js';
13
import { Codicon } from '../../../../base/common/codicons.js';
14
import { registerIcon } from '../../../../platform/theme/common/iconRegistry.js';
15
import { ThemeIcon } from '../../../../base/common/themables.js';
16
17
const clearIcon = registerIcon('notifications-clear', Codicon.close, localize('clearIcon', 'Icon for the clear action in notifications.'));
18
const clearAllIcon = registerIcon('notifications-clear-all', Codicon.clearAll, localize('clearAllIcon', 'Icon for the clear all action in notifications.'));
19
const hideIcon = registerIcon('notifications-hide', Codicon.chevronDown, localize('hideIcon', 'Icon for the hide action in notifications.'));
20
const expandIcon = registerIcon('notifications-expand', Codicon.chevronUp, localize('expandIcon', 'Icon for the expand action in notifications.'));
21
const collapseIcon = registerIcon('notifications-collapse', Codicon.chevronDown, localize('collapseIcon', 'Icon for the collapse action in notifications.'));
22
const configureIcon = registerIcon('notifications-configure', Codicon.gear, localize('configureIcon', 'Icon for the configure action in notifications.'));
23
const doNotDisturbIcon = registerIcon('notifications-do-not-disturb', Codicon.bellSlash, localize('doNotDisturbIcon', 'Icon for the mute all action in notifications.'));
24
25
export class ClearNotificationAction extends Action {
26
27
static readonly ID = CLEAR_NOTIFICATION;
28
static readonly LABEL = localize('clearNotification', "Clear Notification");
29
30
constructor(
31
id: string,
32
label: string,
33
@ICommandService private readonly commandService: ICommandService
34
) {
35
super(id, label, ThemeIcon.asClassName(clearIcon));
36
}
37
38
override async run(notification: INotificationViewItem): Promise<void> {
39
this.commandService.executeCommand(CLEAR_NOTIFICATION, notification);
40
}
41
}
42
43
export class ClearAllNotificationsAction extends Action {
44
45
static readonly ID = CLEAR_ALL_NOTIFICATIONS;
46
static readonly LABEL = localize('clearNotifications', "Clear All Notifications");
47
48
constructor(
49
id: string,
50
label: string,
51
@ICommandService private readonly commandService: ICommandService
52
) {
53
super(id, label, ThemeIcon.asClassName(clearAllIcon));
54
}
55
56
override async run(): Promise<void> {
57
this.commandService.executeCommand(CLEAR_ALL_NOTIFICATIONS);
58
}
59
}
60
61
export class ToggleDoNotDisturbAction extends Action {
62
63
static readonly ID = TOGGLE_DO_NOT_DISTURB_MODE;
64
static readonly LABEL = localize('toggleDoNotDisturbMode', "Toggle Do Not Disturb Mode");
65
66
constructor(
67
id: string,
68
label: string,
69
@ICommandService private readonly commandService: ICommandService
70
) {
71
super(id, label, ThemeIcon.asClassName(doNotDisturbIcon));
72
}
73
74
override async run(): Promise<void> {
75
this.commandService.executeCommand(TOGGLE_DO_NOT_DISTURB_MODE);
76
}
77
}
78
79
export class ToggleDoNotDisturbBySourceAction extends Action {
80
81
static readonly ID = TOGGLE_DO_NOT_DISTURB_MODE_BY_SOURCE;
82
static readonly LABEL = localize('toggleDoNotDisturbModeBySource', "Toggle Do Not Disturb Mode By Source...");
83
84
constructor(
85
id: string,
86
label: string,
87
@ICommandService private readonly commandService: ICommandService
88
) {
89
super(id, label);
90
}
91
92
override async run(): Promise<void> {
93
this.commandService.executeCommand(TOGGLE_DO_NOT_DISTURB_MODE_BY_SOURCE);
94
}
95
}
96
97
export class ConfigureDoNotDisturbAction extends Action {
98
99
static readonly ID = 'workbench.action.configureDoNotDisturbMode';
100
static readonly LABEL = localize('configureDoNotDisturbMode', "Configure Do Not Disturb...");
101
102
constructor(
103
id: string,
104
label: string
105
) {
106
super(id, label, ThemeIcon.asClassName(doNotDisturbIcon));
107
}
108
}
109
110
export class HideNotificationsCenterAction extends Action {
111
112
static readonly ID = HIDE_NOTIFICATIONS_CENTER;
113
static readonly LABEL = localize('hideNotificationsCenter', "Hide Notifications");
114
115
constructor(
116
id: string,
117
label: string,
118
@ICommandService private readonly commandService: ICommandService
119
) {
120
super(id, label, ThemeIcon.asClassName(hideIcon));
121
}
122
123
override async run(): Promise<void> {
124
this.commandService.executeCommand(HIDE_NOTIFICATIONS_CENTER);
125
}
126
}
127
128
export class ExpandNotificationAction extends Action {
129
130
static readonly ID = EXPAND_NOTIFICATION;
131
static readonly LABEL = localize('expandNotification', "Expand Notification");
132
133
constructor(
134
id: string,
135
label: string,
136
@ICommandService private readonly commandService: ICommandService
137
) {
138
super(id, label, ThemeIcon.asClassName(expandIcon));
139
}
140
141
override async run(notification: INotificationViewItem): Promise<void> {
142
this.commandService.executeCommand(EXPAND_NOTIFICATION, notification);
143
}
144
}
145
146
export class CollapseNotificationAction extends Action {
147
148
static readonly ID = COLLAPSE_NOTIFICATION;
149
static readonly LABEL = localize('collapseNotification', "Collapse Notification");
150
151
constructor(
152
id: string,
153
label: string,
154
@ICommandService private readonly commandService: ICommandService
155
) {
156
super(id, label, ThemeIcon.asClassName(collapseIcon));
157
}
158
159
override async run(notification: INotificationViewItem): Promise<void> {
160
this.commandService.executeCommand(COLLAPSE_NOTIFICATION, notification);
161
}
162
}
163
164
export class ConfigureNotificationAction extends Action {
165
166
static readonly ID = 'workbench.action.configureNotification';
167
static readonly LABEL = localize('configureNotification', "More Actions...");
168
169
constructor(
170
id: string,
171
label: string,
172
readonly notification: INotificationViewItem
173
) {
174
super(id, label, ThemeIcon.asClassName(configureIcon));
175
}
176
}
177
178
export class CopyNotificationMessageAction extends Action {
179
180
static readonly ID = 'workbench.action.copyNotificationMessage';
181
static readonly LABEL = localize('copyNotification', "Copy Text");
182
183
constructor(
184
id: string,
185
label: string,
186
@IClipboardService private readonly clipboardService: IClipboardService
187
) {
188
super(id, label);
189
}
190
191
override run(notification: INotificationViewItem): Promise<void> {
192
return this.clipboardService.writeText(notification.message.raw);
193
}
194
}
195
196