Path: blob/main/src/vs/workbench/browser/parts/notifications/notificationsActions.ts
3296 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import './media/notificationsActions.css';6import { INotificationViewItem } from '../../../common/notifications.js';7import { localize } from '../../../../nls.js';8import { Action } from '../../../../base/common/actions.js';9import { 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';10import { ICommandService } from '../../../../platform/commands/common/commands.js';11import { IClipboardService } from '../../../../platform/clipboard/common/clipboardService.js';12import { Codicon } from '../../../../base/common/codicons.js';13import { registerIcon } from '../../../../platform/theme/common/iconRegistry.js';14import { ThemeIcon } from '../../../../base/common/themables.js';1516const clearIcon = registerIcon('notifications-clear', Codicon.close, localize('clearIcon', 'Icon for the clear action in notifications.'));17const clearAllIcon = registerIcon('notifications-clear-all', Codicon.clearAll, localize('clearAllIcon', 'Icon for the clear all action in notifications.'));18const hideIcon = registerIcon('notifications-hide', Codicon.chevronDown, localize('hideIcon', 'Icon for the hide action in notifications.'));19const expandIcon = registerIcon('notifications-expand', Codicon.chevronUp, localize('expandIcon', 'Icon for the expand action in notifications.'));20const collapseIcon = registerIcon('notifications-collapse', Codicon.chevronDown, localize('collapseIcon', 'Icon for the collapse action in notifications.'));21const configureIcon = registerIcon('notifications-configure', Codicon.gear, localize('configureIcon', 'Icon for the configure action in notifications.'));22const doNotDisturbIcon = registerIcon('notifications-do-not-disturb', Codicon.bellSlash, localize('doNotDisturbIcon', 'Icon for the mute all action in notifications.'));2324export class ClearNotificationAction extends Action {2526static readonly ID = CLEAR_NOTIFICATION;27static readonly LABEL = localize('clearNotification', "Clear Notification");2829constructor(30id: string,31label: string,32@ICommandService private readonly commandService: ICommandService33) {34super(id, label, ThemeIcon.asClassName(clearIcon));35}3637override async run(notification: INotificationViewItem): Promise<void> {38this.commandService.executeCommand(CLEAR_NOTIFICATION, notification);39}40}4142export class ClearAllNotificationsAction extends Action {4344static readonly ID = CLEAR_ALL_NOTIFICATIONS;45static readonly LABEL = localize('clearNotifications', "Clear All Notifications");4647constructor(48id: string,49label: string,50@ICommandService private readonly commandService: ICommandService51) {52super(id, label, ThemeIcon.asClassName(clearAllIcon));53}5455override async run(): Promise<void> {56this.commandService.executeCommand(CLEAR_ALL_NOTIFICATIONS);57}58}5960export class ToggleDoNotDisturbAction extends Action {6162static readonly ID = TOGGLE_DO_NOT_DISTURB_MODE;63static readonly LABEL = localize('toggleDoNotDisturbMode', "Toggle Do Not Disturb Mode");6465constructor(66id: string,67label: string,68@ICommandService private readonly commandService: ICommandService69) {70super(id, label, ThemeIcon.asClassName(doNotDisturbIcon));71}7273override async run(): Promise<void> {74this.commandService.executeCommand(TOGGLE_DO_NOT_DISTURB_MODE);75}76}7778export class ToggleDoNotDisturbBySourceAction extends Action {7980static readonly ID = TOGGLE_DO_NOT_DISTURB_MODE_BY_SOURCE;81static readonly LABEL = localize('toggleDoNotDisturbModeBySource', "Toggle Do Not Disturb Mode By Source...");8283constructor(84id: string,85label: string,86@ICommandService private readonly commandService: ICommandService87) {88super(id, label);89}9091override async run(): Promise<void> {92this.commandService.executeCommand(TOGGLE_DO_NOT_DISTURB_MODE_BY_SOURCE);93}94}9596export class ConfigureDoNotDisturbAction extends Action {9798static readonly ID = 'workbench.action.configureDoNotDisturbMode';99static readonly LABEL = localize('configureDoNotDisturbMode', "Configure Do Not Disturb...");100101constructor(102id: string,103label: string104) {105super(id, label, ThemeIcon.asClassName(doNotDisturbIcon));106}107}108109export class HideNotificationsCenterAction extends Action {110111static readonly ID = HIDE_NOTIFICATIONS_CENTER;112static readonly LABEL = localize('hideNotificationsCenter', "Hide Notifications");113114constructor(115id: string,116label: string,117@ICommandService private readonly commandService: ICommandService118) {119super(id, label, ThemeIcon.asClassName(hideIcon));120}121122override async run(): Promise<void> {123this.commandService.executeCommand(HIDE_NOTIFICATIONS_CENTER);124}125}126127export class ExpandNotificationAction extends Action {128129static readonly ID = EXPAND_NOTIFICATION;130static readonly LABEL = localize('expandNotification', "Expand Notification");131132constructor(133id: string,134label: string,135@ICommandService private readonly commandService: ICommandService136) {137super(id, label, ThemeIcon.asClassName(expandIcon));138}139140override async run(notification: INotificationViewItem): Promise<void> {141this.commandService.executeCommand(EXPAND_NOTIFICATION, notification);142}143}144145export class CollapseNotificationAction extends Action {146147static readonly ID = COLLAPSE_NOTIFICATION;148static readonly LABEL = localize('collapseNotification', "Collapse Notification");149150constructor(151id: string,152label: string,153@ICommandService private readonly commandService: ICommandService154) {155super(id, label, ThemeIcon.asClassName(collapseIcon));156}157158override async run(notification: INotificationViewItem): Promise<void> {159this.commandService.executeCommand(COLLAPSE_NOTIFICATION, notification);160}161}162163export class ConfigureNotificationAction extends Action {164165static readonly ID = 'workbench.action.configureNotification';166static readonly LABEL = localize('configureNotification', "More Actions...");167168constructor(169id: string,170label: string,171readonly notification: INotificationViewItem172) {173super(id, label, ThemeIcon.asClassName(configureIcon));174}175}176177export class CopyNotificationMessageAction extends Action {178179static readonly ID = 'workbench.action.copyNotificationMessage';180static readonly LABEL = localize('copyNotification', "Copy Text");181182constructor(183id: string,184label: string,185@IClipboardService private readonly clipboardService: IClipboardService186) {187super(id, label);188}189190override run(notification: INotificationViewItem): Promise<void> {191return this.clipboardService.writeText(notification.message.raw);192}193}194195196