mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Port VS Code telemetry opt-in dialog (#1130)
This commit is contained in:
@@ -19,7 +19,7 @@ import { ResolvedKeybindingItem } from 'vs/platform/keybinding/common/resolvedKe
|
||||
import { OS } from 'vs/base/common/platform';
|
||||
import { IKeyboardEvent } from 'vs/platform/keybinding/common/keybinding';
|
||||
import { NullTelemetryService } from 'vs/platform/telemetry/common/telemetryUtils';
|
||||
import { INotificationService, NoOpNotification, INotification } from 'vs/platform/notification/common/notification';
|
||||
import { INotificationService, NoOpNotification, INotification, IPromptChoice } from 'vs/platform/notification/common/notification';
|
||||
|
||||
function createContext(ctx: any) {
|
||||
return {
|
||||
@@ -138,6 +138,9 @@ suite('AbstractKeybindingService', () => {
|
||||
error: (message: any) => {
|
||||
showMessageCalls.push({ sev: Severity.Error, message });
|
||||
return new NoOpNotification();
|
||||
},
|
||||
prompt(severity: Severity, message: string, choices: IPromptChoice[], onCancel?: () => void): any {
|
||||
throw new Error('not implemented');
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -62,6 +62,7 @@ export interface IProductConfiguration {
|
||||
reportIssueUrl: string;
|
||||
licenseUrl: string;
|
||||
privacyStatementUrl: string;
|
||||
telemetryOptOutUrl: string;
|
||||
npsSurveyUrl: string;
|
||||
surveys: ISurveyData[];
|
||||
checksums: { [path: string]: string; };
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user