Port VS Code telemetry opt-in dialog (#1130)

This commit is contained in:
Karl Burtram
2018-04-11 15:47:34 -07:00
committed by GitHub
parent ed10f984b6
commit cd0210c88a
22 changed files with 240 additions and 107 deletions

View File

@@ -89,12 +89,12 @@ export interface INotificationProgress {
done(): void;
}
export interface INotificationHandle extends IDisposable {
export interface INotificationHandle {
/**
* Will be fired once the notification is disposed.
* Will be fired once the notification is closed.
*/
readonly onDidDispose: Event<void>;
readonly onDidClose: Event<void>;
/**
* Allows to indicate progress on the notification even after the
@@ -118,6 +118,36 @@ export interface INotificationHandle extends IDisposable {
* notification is already visible.
*/
updateActions(actions?: INotificationActions): void;
/**
* Hide the notification and remove it from the notification center.
*/
close(): void;
}
export interface IPromptChoice {
/**
* Label to show for the choice to the user.
*/
label: string;
/**
* Primary choices show up as buttons in the notification below the message.
* Secondary choices show up under the gear icon in the header of the notification.
*/
isSecondary?: boolean;
/**
* Wether to keep the notification open after the choice was selected
* by the user. By default, will close the notification upon click.
*/
keepOpen?: boolean;
/**
* Triggered when the user selects the choice.
*/
run: () => void;
}
export interface INotificationService {
@@ -151,23 +181,34 @@ export interface INotificationService {
* method if you need more control over the notification.
*/
error(message: NotificationMessage | NotificationMessage[]): 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 instead, 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(severity: Severity, message: string, choices: IPromptChoice[], onCancel?: () => void): INotificationHandle;
}
export class NoOpNotification implements INotificationHandle {
readonly progress = new NoOpProgress();
private _onDidDispose: Emitter<void> = new Emitter();
private readonly _onDidClose: Emitter<void> = new Emitter();
public get onDidDispose(): Event<void> {
return this._onDidDispose.event;
public get onDidClose(): Event<void> {
return this._onDidClose.event;
}
updateSeverity(severity: Severity): void { }
updateMessage(message: NotificationMessage): void { }
updateActions(actions?: INotificationActions): void { }
dispose(): void {
this._onDidDispose.dispose();
close(): void {
this._onDidClose.dispose();
}
}