Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/extensions/copilot/src/platform/notification/common/notificationService.ts
13401 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 { createServiceIdentifier } from '../../../util/common/services';
7
import { CancellationToken } from '../../../util/vs/base/common/cancellation';
8
9
export interface MessageOptions {
10
modal?: boolean;
11
detail?: string;
12
}
13
14
export interface ProgressOptions {
15
location: ProgressLocation | {
16
viewId: string;
17
};
18
title?: string;
19
cancellable?: boolean;
20
}
21
22
export enum ProgressLocation {
23
SourceControl = 1,
24
Window = 10,
25
Notification = 15
26
}
27
28
export interface Progress<T> {
29
report(value: T): void;
30
}
31
32
export interface INotificationService {
33
readonly _serviceBrand: undefined;
34
35
showInformationMessage(message: string, ...items: string[]): Promise<string | undefined>;
36
showInformationMessage<T extends string>(message: string, options: MessageOptions, ...items: T[]): Promise<T | undefined>;
37
showWarningMessage(message: string, ...items: string[]): Promise<string | undefined>;
38
showQuotaExceededDialog(options: { isNoAuthUser: boolean }): Promise<unknown>;
39
withProgress<R>(options: ProgressOptions, task: (progress: Progress<{
40
message?: string;
41
increment?: number;
42
}>, token: CancellationToken) => Thenable<R>): Promise<R>;
43
}
44
45
export class NullNotificationService implements INotificationService {
46
declare readonly _serviceBrand: undefined;
47
48
showInformationMessage<T extends string>(message: string, options: MessageOptions, ...items: T[]): Promise<T | undefined>;
49
showInformationMessage(message: string, ...items: string[]): Promise<string | undefined>;
50
showInformationMessage<T extends string>(message: string, options: MessageOptions, ...items: T[]): Promise<T | undefined>;
51
showInformationMessage(message: string, optionsOrItem?: any, ...items: any[]): Promise<any> {
52
return Promise.resolve(undefined);
53
}
54
55
showWarningMessage(message: string, ...items: string[]): Promise<string | undefined> {
56
return Promise.resolve(undefined);
57
}
58
59
showQuotaExceededDialog(options: { isNoAuthUser: boolean }): Promise<unknown> {
60
return Promise.resolve();
61
}
62
63
withProgress<R>(options: ProgressOptions, task: (progress: Progress<{
64
message?: string;
65
increment?: number;
66
}>, token: CancellationToken) => Thenable<R>): Promise<R> {
67
return Promise.resolve(task({ report: () => { } }, CancellationToken.None));
68
}
69
}
70
71
export const INotificationService = createServiceIdentifier<INotificationService>('INotificationService');
72
73