diff --git a/packages/plugin-ext/src/common/plugin-api-rpc.ts b/packages/plugin-ext/src/common/plugin-api-rpc.ts index 8d2d607a386d2..95988bd4f9e75 100644 --- a/packages/plugin-ext/src/common/plugin-api-rpc.ts +++ b/packages/plugin-ext/src/common/plugin-api-rpc.ts @@ -686,7 +686,7 @@ export interface DecorationProvider { } export interface NotificationMain { - $startProgress(options: string | NotificationMain.StartProgressOptions): Promise; + $startProgress(options: NotificationMain.StartProgressOptions): Promise; $stopProgress(id: string): void; $updateProgress(id: string, report: NotificationMain.ProgressReport): void; } @@ -694,6 +694,7 @@ export namespace NotificationMain { export interface StartProgressOptions { title: string; location?: string; + cancellable?: boolean; } export interface ProgressReport { message?: string; diff --git a/packages/plugin-ext/src/main/browser/notification-main.ts b/packages/plugin-ext/src/main/browser/notification-main.ts index 1b8e256a038a6..2568e0cfa6b32 100644 --- a/packages/plugin-ext/src/main/browser/notification-main.ts +++ b/packages/plugin-ext/src/main/browser/notification-main.ts @@ -38,7 +38,7 @@ export class NotificationMainImpl implements NotificationMain, Disposable { this.toDispose.dispose(); } - async $startProgress(options: string | NotificationMain.StartProgressOptions): Promise { + async $startProgress(options: NotificationMain.StartProgressOptions): Promise { const progressMessage = this.mapOptions(options); const progress = await this.progressService.showProgress(progressMessage); const id = progress.id; @@ -51,10 +51,9 @@ export class NotificationMainImpl implements NotificationMain, Disposable { } return id; } - protected mapOptions(options: string | NotificationMain.StartProgressOptions): ProgressMessage { - const text = typeof options === 'string' ? options : options.title; - const location = typeof options === 'string' ? 'notification' : options.location; - return { text, options: { location, cancelable: true } }; + protected mapOptions(options: NotificationMain.StartProgressOptions): ProgressMessage { + const { title, location, cancellable } = options; + return { text: title, options: { location, cancelable: cancellable } }; } $stopProgress(id: string): void { diff --git a/packages/plugin-ext/src/plugin/notification.ts b/packages/plugin-ext/src/plugin/notification.ts index dfc2d12557022..4f622166bf270 100644 --- a/packages/plugin-ext/src/plugin/notification.ts +++ b/packages/plugin-ext/src/plugin/notification.ts @@ -37,7 +37,8 @@ export class NotificationExtImpl implements NotificationExt { const progress = task({ report: async item => this.proxy.$updateProgress(await id.promise, item)}, tokenSource.token); const title = options.title ? options.title : ''; const location = this.mapLocation(options.location); - id.resolve(await this.proxy.$startProgress({ title, location })); + const cancellable = options.cancellable; + id.resolve(await this.proxy.$startProgress({ title, location, cancellable })); const stop = async () => this.proxy.$stopProgress(await id.promise); const promise = Promise.all([ progress,