mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-07 17:23:56 -05:00
Merge from vscode e5834d3280fcd04898efeac32b9cf1b893f9b127 (#9385)
* Merge from vscode e5834d3280fcd04898efeac32b9cf1b893f9b127 * distro
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { INotification, INotificationHandle, INotificationActions, INotificationProgress, NoOpNotification, Severity, NotificationMessage, IPromptChoice, IStatusMessageOptions, NotificationsFilter } from 'vs/platform/notification/common/notification';
|
||||
import { INotification, INotificationHandle, INotificationActions, INotificationProgress, NoOpNotification, Severity, NotificationMessage, IPromptChoice, IStatusMessageOptions, NotificationsFilter, INotificationProgressProperties } from 'vs/platform/notification/common/notification';
|
||||
import { toErrorMessage } from 'vs/base/common/errorMessage';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import { Disposable, IDisposable, toDisposable } from 'vs/base/common/lifecycle';
|
||||
@@ -92,6 +92,9 @@ export class NotificationHandle extends Disposable implements INotificationHandl
|
||||
private readonly _onDidClose = this._register(new Emitter<void>());
|
||||
readonly onDidClose = this._onDidClose.event;
|
||||
|
||||
private readonly _onDidChangeVisibility = this._register(new Emitter<boolean>());
|
||||
readonly onDidChangeVisibility = this._onDidChangeVisibility.event;
|
||||
|
||||
constructor(private readonly item: INotificationViewItem, private readonly onClose: (item: INotificationViewItem) => void) {
|
||||
super();
|
||||
|
||||
@@ -99,6 +102,11 @@ export class NotificationHandle extends Disposable implements INotificationHandl
|
||||
}
|
||||
|
||||
private registerListeners(): void {
|
||||
|
||||
// Visibility
|
||||
this._register(this.item.onDidChangeVisibility(visible => this._onDidChangeVisibility.fire(visible)));
|
||||
|
||||
// Closing
|
||||
Event.once(this.item.onDidClose)(() => {
|
||||
this._onDidClose.fire();
|
||||
|
||||
@@ -265,6 +273,7 @@ export interface INotificationViewItem {
|
||||
|
||||
readonly onDidChangeExpansion: Event<void>;
|
||||
readonly onDidClose: Event<void>;
|
||||
readonly onDidChangeVisibility: Event<boolean>;
|
||||
readonly onDidChangeLabel: Event<INotificationViewItemLabelChangeEvent>;
|
||||
|
||||
expand(): void;
|
||||
@@ -275,6 +284,8 @@ export interface INotificationViewItem {
|
||||
updateMessage(message: NotificationMessage): void;
|
||||
updateActions(actions?: INotificationActions): void;
|
||||
|
||||
updateVisibility(visible: boolean): void;
|
||||
|
||||
close(): void;
|
||||
|
||||
equals(item: INotificationViewItem): boolean;
|
||||
@@ -398,6 +409,7 @@ export class NotificationViewItem extends Disposable implements INotificationVie
|
||||
private static readonly MAX_MESSAGE_LENGTH = 1000;
|
||||
|
||||
private _expanded: boolean | undefined;
|
||||
private _visible: boolean = false;
|
||||
|
||||
private _actions: INotificationActions | undefined;
|
||||
private _progress: NotificationViewItemProgress | undefined;
|
||||
@@ -411,6 +423,9 @@ export class NotificationViewItem extends Disposable implements INotificationVie
|
||||
private readonly _onDidChangeLabel = this._register(new Emitter<INotificationViewItemLabelChangeEvent>());
|
||||
readonly onDidChangeLabel = this._onDidChangeLabel.event;
|
||||
|
||||
private readonly _onDidChangeVisibility = this._register(new Emitter<boolean>());
|
||||
readonly onDidChangeVisibility = this._onDidChangeVisibility.event;
|
||||
|
||||
static create(notification: INotification, filter: NotificationsFilter = NotificationsFilter.OFF): INotificationViewItem | undefined {
|
||||
if (!notification || !notification.message || isPromiseCanceledError(notification.message)) {
|
||||
return undefined; // we need a message to show
|
||||
@@ -435,7 +450,7 @@ export class NotificationViewItem extends Disposable implements INotificationVie
|
||||
actions = { primary: notification.message.actions };
|
||||
}
|
||||
|
||||
return new NotificationViewItem(severity, notification.sticky, notification.silent || filter === NotificationsFilter.SILENT || (filter === NotificationsFilter.ERROR && notification.severity !== Severity.Error), message, notification.source, actions);
|
||||
return new NotificationViewItem(severity, notification.sticky, notification.silent || filter === NotificationsFilter.SILENT || (filter === NotificationsFilter.ERROR && notification.severity !== Severity.Error), message, notification.source, notification.progress, actions);
|
||||
}
|
||||
|
||||
private static parseNotificationMessage(input: NotificationMessage): INotificationMessage | undefined {
|
||||
@@ -472,13 +487,30 @@ export class NotificationViewItem extends Disposable implements INotificationVie
|
||||
private _silent: boolean | undefined,
|
||||
private _message: INotificationMessage,
|
||||
private _source: string | undefined,
|
||||
progress: INotificationProgressProperties | undefined,
|
||||
actions?: INotificationActions
|
||||
) {
|
||||
super();
|
||||
|
||||
if (progress) {
|
||||
this.setProgress(progress);
|
||||
}
|
||||
|
||||
this.setActions(actions);
|
||||
}
|
||||
|
||||
private setProgress(progress: INotificationProgressProperties): void {
|
||||
if (progress.infinite) {
|
||||
this.progress.infinite();
|
||||
} else if (progress.total) {
|
||||
this.progress.total(progress.total);
|
||||
|
||||
if (progress.worked) {
|
||||
this.progress.worked(progress.worked);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private setActions(actions: INotificationActions = { primary: [], secondary: [] }): void {
|
||||
if (!Array.isArray(actions.primary)) {
|
||||
actions.primary = [];
|
||||
@@ -583,6 +615,14 @@ export class NotificationViewItem extends Disposable implements INotificationVie
|
||||
this._onDidChangeLabel.fire({ kind: NotificationViewItemLabelKind.ACTIONS });
|
||||
}
|
||||
|
||||
updateVisibility(visible: boolean): void {
|
||||
if (this._visible !== visible) {
|
||||
this._visible = visible;
|
||||
|
||||
this._onDidChangeVisibility.fire(visible);
|
||||
}
|
||||
}
|
||||
|
||||
expand(): void {
|
||||
if (this._expanded || !this.canCollapse) {
|
||||
return;
|
||||
|
||||
@@ -17,7 +17,7 @@ import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { IKeybindings } from 'vs/platform/keybinding/common/keybindingsRegistry';
|
||||
import { IAction, IActionViewItem } from 'vs/base/common/actions';
|
||||
import { ExtensionIdentifier } from 'vs/platform/extensions/common/extensions';
|
||||
import { flatten } from 'vs/base/common/arrays';
|
||||
import { flatten, mergeSort } from 'vs/base/common/arrays';
|
||||
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
|
||||
import { SetMap } from 'vs/base/common/collections';
|
||||
|
||||
@@ -53,6 +53,7 @@ export interface IViewContainerDescriptor {
|
||||
|
||||
readonly extensionId?: ExtensionIdentifier;
|
||||
|
||||
readonly rejectAddedViews?: boolean;
|
||||
}
|
||||
|
||||
export interface IViewContainersRegistry {
|
||||
@@ -211,9 +212,16 @@ export interface IViewDescriptorCollection extends IDisposable {
|
||||
readonly allViewDescriptors: IViewDescriptor[];
|
||||
}
|
||||
|
||||
export enum ViewContentPriority {
|
||||
Normal = 0,
|
||||
Low = 1,
|
||||
Lowest = 2
|
||||
}
|
||||
|
||||
export interface IViewContentDescriptor {
|
||||
readonly content: string;
|
||||
readonly when?: ContextKeyExpr | 'default';
|
||||
readonly priority?: ViewContentPriority;
|
||||
|
||||
/**
|
||||
* ordered preconditions for each button in the content
|
||||
@@ -247,6 +255,13 @@ export interface IViewsRegistry {
|
||||
}
|
||||
|
||||
function compareViewContentDescriptors(a: IViewContentDescriptor, b: IViewContentDescriptor): number {
|
||||
const aPriority = a.priority ?? ViewContentPriority.Normal;
|
||||
const bPriority = b.priority ?? ViewContentPriority.Normal;
|
||||
|
||||
if (aPriority !== bPriority) {
|
||||
return aPriority - bPriority;
|
||||
}
|
||||
|
||||
return a.content < b.content ? -1 : 1;
|
||||
}
|
||||
|
||||
@@ -328,8 +343,8 @@ class ViewsRegistry extends Disposable implements IViewsRegistry {
|
||||
|
||||
getViewWelcomeContent(id: string): IViewContentDescriptor[] {
|
||||
const result: IViewContentDescriptor[] = [];
|
||||
result.sort(compareViewContentDescriptors);
|
||||
this._viewWelcomeContents.forEach(id, descriptor => result.push(descriptor));
|
||||
mergeSort(result, compareViewContentDescriptors);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user