Adding inline actions to OE (#23101)

This commit is contained in:
Aasim Khan
2023-05-13 09:24:49 -07:00
committed by GitHub
parent 31a88cc9eb
commit 2beba9ac08
18 changed files with 279 additions and 66 deletions

View File

@@ -46,6 +46,7 @@ import { ElementSizeObserver } from 'vs/editor/browser/config/elementSizeObserve
import { ICapabilitiesService } from 'sql/platform/capabilities/common/capabilitiesService';
import { onUnexpectedError } from 'vs/base/common/errors';
import { FieldSet } from 'sql/base/browser/ui/fieldset/fieldset';
import { KeyCode } from 'vs/base/common/keyCodes';
export interface OnShowUIResponse {
selectedProviderDisplayName: string;
@@ -357,34 +358,56 @@ export class ConnectionDialogWidget extends Modal {
};
const actionProvider = this.instantiationService.createInstance(RecentConnectionActionsProvider);
const controller = new RecentConnectionTreeController(leftClick, actionProvider, this.connectionManagementService, this.contextMenuService);
actionProvider.onRecentConnectionRemoved(() => {
const recentConnections: ConnectionProfile[] = this.connectionManagementService.getRecentConnections();
this.open(recentConnections.length > 0).catch(err => this.logService.error(`Unexpected error opening connection widget after a recent connection was removed from action provider: ${err}`));
});
controller.onRecentConnectionRemoved(() => {
const recentConnections: ConnectionProfile[] = this.connectionManagementService.getRecentConnections();
this.open(recentConnections.length > 0).catch(err => this.logService.error(`Unexpected error opening connection widget after a recent connection was removed from controller : ${err}`));
});
this._register(actionProvider.onRecentConnectionRemoved(async () => {
await this.refreshTree();
}));
this._register(controller.onRecentConnectionRemoved(async () => {
await this.refreshTree();
}));
this._register(this.connectionManagementService.onRecentConnectionProfileDeleted(async (e) => {
await this.refreshTree();
}));
this._recentConnectionTree = TreeCreationUtils.createConnectionTree(treeContainer, this.instantiationService, this._configurationService, localize('connectionDialog.recentConnections', "Recent Connections"), controller);
if (this._recentConnectionTree instanceof AsyncServerTree) {
this._recentConnectionTree.onMouseClick(e => {
this._register(this._recentConnectionTree.onMouseClick(e => {
if (e.element instanceof ConnectionProfile) {
this._connectionSource = 'recent';
this.onConnectionClick(e.element, false).catch(onUnexpectedError);
}
});
this._recentConnectionTree.onMouseDblClick(e => {
}));
this._register(this._recentConnectionTree.onMouseDblClick(e => {
if (e.element instanceof ConnectionProfile) {
this._connectionSource = 'recent';
this.onConnectionClick(e.element, true).catch(onUnexpectedError);
}
});
}));
this._register(this._recentConnectionTree.onKeyDown(e => {
const keyboardEvent = new StandardKeyboardEvent(e);
if (keyboardEvent.keyCode === KeyCode.Delete) {
const element = this._recentConnectionTree.getSelection()[0];
if (element instanceof ConnectionProfile) {
this.connectionManagementService.clearRecentConnection(element);
}
}
}));
}
// Theme styler
this._register(styler.attachListStyler(this._recentConnectionTree, this._themeService));
}
private async refreshTree() {
try {
const recentConnections: ConnectionProfile[] = this.connectionManagementService.getRecentConnections();
await this.open(recentConnections.length > 0);
} catch (err) {
this.logService.error(`Unexpected error opening connection widget after a recent connection was removed from controller : ${err}`);
}
}
private createRecentConnections() {
this.createRecentConnectionList();
const noRecentConnectionContainer = DOM.append(this._noRecentConnection, DOM.$('.connection-recent-content'));

View File

@@ -88,6 +88,8 @@ export class ConnectionManagementService extends Disposable implements IConnecti
private _onConnectionProfileGroupEdited = new Emitter<ConnectionProfileGroup>();
private _onConnectionProfileGroupMoved = new Emitter<ConnectionElementMovedParams>();
private _onRecentConnectionProfileDeleted = new Emitter<ConnectionProfile>();
private _mementoContext: Memento;
private _mementoObj: MementoObject;
private _connectionStore: ConnectionStore;
@@ -246,6 +248,10 @@ export class ConnectionManagementService extends Disposable implements IConnecti
return this._onConnectionProfileGroupMoved.event;
}
public get onRecentConnectionProfileDeleted(): Event<ConnectionProfile> {
return this._onRecentConnectionProfileDeleted.event;
}
public get providerNameToDisplayNameMap(): { readonly [providerDisplayName: string]: string } {
return this._providerNameToDisplayNameMap;
}
@@ -829,6 +835,7 @@ export class ConnectionManagementService extends Disposable implements IConnecti
public clearRecentConnection(connectionProfile: interfaces.IConnectionProfile): void {
this._connectionStore.removeRecentConnection(connectionProfile);
this._onRecentConnectionProfileDeleted.fire(<ConnectionProfile>connectionProfile);
}
public getActiveConnections(providers?: string[]): ConnectionProfile[] {