Skip to content

Commit 27c30c8

Browse files
authored
adding overlayService (microsoft#72014)
* adding overlayService * addressing feedback from UX meeting * relocating to progressService2 * remove overlayService and update progressService
1 parent 047b47b commit 27c30c8

7 files changed

Lines changed: 174 additions & 3 deletions

File tree

src/vs/base/browser/ui/dialog/dialog.css

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
align-items: center;
1616
}
1717

18+
.monaco-workbench .dialog-modal-block.dimmed {
19+
background: rgba(0, 0, 0, 0.3);
20+
}
21+
1822
/** Dialog: Container */
1923
.monaco-workbench .dialog-box {
2024
display: flex;
@@ -66,6 +70,10 @@
6670
background-repeat: no-repeat;
6771
}
6872

73+
.vs .monaco-workbench .dialog-box .dialog-message-row .dialog-icon.icon-pending {
74+
background-image: url('pending.svg');
75+
}
76+
6977
.vs .monaco-workbench .dialog-box .dialog-message-row .dialog-icon.icon-info {
7078
background-image: url('info.svg');
7179
}
@@ -78,6 +86,10 @@
7886
background-image: url('error.svg');
7987
}
8088

89+
.vs-dark .monaco-workbench .dialog-box .dialog-message-row .dialog-icon.icon-pending {
90+
background-image: url('pending-dark.svg');
91+
}
92+
8193
.vs-dark .monaco-workbench .dialog-box .dialog-message-row .dialog-icon.icon-info,
8294
.hc-black .monaco-workbench .dialog-box .dialog-message-row .dialog-icon.icon-info {
8395
background-image: url('info-inverse.svg');
@@ -93,6 +105,14 @@
93105
background-image: url('error-inverse.svg');
94106
}
95107

108+
.hc-black .monaco-workbench .dialog-box .dialog-message-row .dialog-icon.icon-pending {
109+
background-image: url('pending-hc.svg');
110+
}
111+
112+
.monaco-workbench .dialog-box .dialog-message-row .dialog-icon.icon-pending {
113+
background-size: 30px;
114+
}
115+
96116
/** Dialog: Message Container */
97117
.monaco-workbench .dialog-box .dialog-message-row .dialog-message-container {
98118
display: flex;

src/vs/base/browser/ui/dialog/dialog.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { mnemonicButtonLabel } from 'vs/base/common/labels';
1919
export interface IDialogOptions {
2020
cancelId?: number;
2121
detail?: string;
22-
type?: 'none' | 'info' | 'error' | 'question' | 'warning';
22+
type?: 'none' | 'info' | 'error' | 'question' | 'warning' | 'pending';
2323
}
2424

2525
export interface IDialogStyles extends IButtonStyles {
@@ -40,7 +40,7 @@ export class Dialog extends Disposable {
4040

4141
constructor(private container: HTMLElement, private message: string, private buttons: string[], private options: IDialogOptions) {
4242
super();
43-
this.modal = this.container.appendChild($('.dialog-modal-block'));
43+
this.modal = this.container.appendChild($(`.dialog-modal-block${options.type === 'pending' ? '.dimmed' : ''}`));
4444
this.element = this.modal.appendChild($('.dialog-box'));
4545
hide(this.element);
4646

@@ -129,6 +129,9 @@ export class Dialog extends Disposable {
129129
case 'warning':
130130
addClass(this.iconElement, 'icon-warning');
131131
break;
132+
case 'pending':
133+
addClass(this.iconElement, 'icon-pending');
134+
break;
132135
case 'none':
133136
case 'info':
134137
case 'question':
Lines changed: 31 additions & 0 deletions
Loading
Lines changed: 31 additions & 0 deletions
Loading
Lines changed: 31 additions & 0 deletions
Loading

src/vs/platform/progress/common/progress.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ export const enum ProgressLocation {
3030
Scm = 3,
3131
Extensions = 5,
3232
Window = 10,
33-
Notification = 15
33+
Notification = 15,
34+
Dialog = 20
3435
}
3536

3637
export interface IProgressOptions {

src/vs/workbench/services/progress/browser/progressService2.ts

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ import { INotificationService, Severity, INotificationHandle, INotificationActio
1616
import { Action } from 'vs/base/common/actions';
1717
import { Event } from 'vs/base/common/event';
1818
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
19+
import { ILayoutService } from 'vs/platform/layout/browser/layoutService';
20+
import { Dialog } from 'vs/base/browser/ui/dialog/dialog';
21+
import { attachDialogStyler } from 'vs/platform/theme/common/styler';
22+
import { IThemeService } from 'vs/platform/theme/common/themeService';
1923

2024
export class ProgressService2 implements IProgressService2 {
2125

@@ -29,6 +33,8 @@ export class ProgressService2 implements IProgressService2 {
2933
@IViewletService private readonly _viewletService: IViewletService,
3034
@INotificationService private readonly _notificationService: INotificationService,
3135
@IStatusbarService private readonly _statusbarService: IStatusbarService,
36+
@ILayoutService private readonly _layoutService: ILayoutService,
37+
@IThemeService private readonly _themeService: IThemeService
3238
) { }
3339

3440
withProgress<R = unknown>(options: IProgressOptions, task: (progress: IProgress<IProgressStep>) => Promise<R>, onDidCancel?: () => void): Promise<R> {
@@ -53,6 +59,8 @@ export class ProgressService2 implements IProgressService2 {
5359
return this._withViewletProgress('workbench.view.scm', task);
5460
case ProgressLocation.Extensions:
5561
return this._withViewletProgress('workbench.view.extensions', task);
62+
case ProgressLocation.Dialog:
63+
return this._withDialogProgress(options, task, onDidCancel);
5664
default:
5765
return Promise.reject(new Error(`Bad progress location: ${location}`));
5866
}
@@ -265,6 +273,52 @@ export class ProgressService2 implements IProgressService2 {
265273
promise.then(onDone, onDone);
266274
return promise;
267275
}
276+
277+
private _withDialogProgress<P extends Promise<R>, R = unknown>(options: IProgressOptions, task: (progress: IProgress<{ message?: string, increment?: number }>) => P, onDidCancel?: () => void): P {
278+
const disposables: IDisposable[] = [];
279+
280+
let dialog: Dialog;
281+
282+
const createDialog = (message: string) => {
283+
dialog = new Dialog(
284+
this._layoutService.container,
285+
message,
286+
[options.cancellable ? localize('cancel', "Cancel") : localize('dismiss', "Dismiss")],
287+
{ type: 'pending' }
288+
);
289+
290+
disposables.push(dialog);
291+
disposables.push(attachDialogStyler(dialog, this._themeService));
292+
293+
dialog.show().then(() => {
294+
if (options.cancellable && typeof onDidCancel === 'function') {
295+
onDidCancel();
296+
}
297+
298+
dispose(dialog);
299+
});
300+
301+
return dialog;
302+
};
303+
304+
const updateDialog = (message?: string) => {
305+
if (message && !dialog) {
306+
dialog = createDialog(message);
307+
}
308+
};
309+
310+
const p = task({
311+
report: progress => {
312+
updateDialog(progress.message);
313+
}
314+
});
315+
316+
p.finally(() => {
317+
dispose(disposables);
318+
});
319+
320+
return p;
321+
}
268322
}
269323

270324
registerSingleton(IProgressService2, ProgressService2, true);

0 commit comments

Comments
 (0)