import { NotificationSeverity, IPromptChoice, IPromptOptions, INotificationInput, INotificationActions } from '../generated-model'; import { Event, Emitter } from '@vscode-alt/monaco-editor/esm/vs/base/common/event'; import Severity from '@vscode-alt/monaco-editor/esm/vs/base/common/severity'; export type INotificationMessageStr = string | Error; export interface INotificationHandle { /** * Will be fired once the notification is closed. */ readonly onDidClose: Event; /** * Allows to indicate progress on the notification even after the * notification is already visible. */ readonly progress: INotificationProgress; /** * Allows to update the severity of the notification. */ updateSeverity(severity: NotificationSeverity): void; /** * Allows to update the message of the notification even after the * notification is already visible. */ updateMessage(message: INotificationMessageStr): void; /** * Allows to update the actions of the notification even after the * notification is already visible. */ updateActions(actions?: INotificationActions): void; /** * Hide the notification and remove it from the notification center. */ close(): void; } export interface INotificationProgress { /** * Causes the progress bar to spin infinitley. */ infinite(): void; /** * Indicate the total amount of work. */ total(value: number): void; /** * Indicate that a specific chunk of work is done. */ worked(value: number): void; /** * Indicate that the long running operation is done. */ done(): void; } /** * A service to bring up notifications and non-modal prompts. * * Note: use the `IDialogService` for a modal way to ask the user for input. */ export interface INotificationService { /** * Show the provided notification to the user. The returned `INotifcationHandle` * can be used to control the notification afterwards. * * **Note:** If your intent is to show a message with actions to the user, consider * the `INotificationService.prompt()` method instead which are optimized for * this usecase and much easier to use! * * @returns a handle on the notification to e.g. hide it or update message, buttons, etc. */ notify(notification: Pick> & { message: INotificationMessageStr} | INotificationInput): INotificationHandle; /** * A convinent way to reporting infos. Use the `INotificationService.notify` * method if you need more control over the notification. */ info(message: INotificationMessageStr | INotificationMessageStr[]): void; /** * A convinient way of reporting infos. Use the `INotificationService.notify` * method if you need more control over the notification. */ info(message: INotificationMessageStr | INotificationMessageStr[]): void; /** * A convinient way of reporting warnings. Use the `INotificationService.notify` * method if you need more control over the notification. */ warn(message: INotificationMessageStr | INotificationMessageStr[]): void; /** * A convinient way of reporting errors. Use the `INotificationService.notify` * method if you need more control over the notification. */ error(message: INotificationMessageStr | INotificationMessageStr[]): void; /** * Shows a prompt in the notification area with the provided choices. The prompt * is non-modal. If you want to show a modal dialog method, use `IDialogService`. * * @param onCancel will be called if the user closed the notification without picking * any of the provided choices. * * @returns a handle on the notification to e.g. hide it or update message, buttons, etc. */ prompt(serverity: NotificationSeverity, message: string, choice: IPromptChoice[], options?: IPromptOptions): INotificationHandle; } export interface INotificationsService { addNotification(notification: INotificationInput); closeNotification(index: number); }