mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
remove special case (#16779)
This commit is contained in:
@@ -26,8 +26,7 @@ import {
|
|||||||
} from 'sql/platform/connection/common/connectionManagement';
|
} from 'sql/platform/connection/common/connectionManagement';
|
||||||
import { QueryEditor } from 'sql/workbench/contrib/query/browser/queryEditor';
|
import { QueryEditor } from 'sql/workbench/contrib/query/browser/queryEditor';
|
||||||
import { IQueryModelService } from 'sql/workbench/services/query/common/queryModel';
|
import { IQueryModelService } from 'sql/workbench/services/query/common/queryModel';
|
||||||
import { SelectBox } from 'sql/base/browser/ui/selectBox/selectBox';
|
import { attachEditableDropdownStyler } from 'sql/platform/theme/common/styler';
|
||||||
import { attachEditableDropdownStyler, attachSelectBoxStyler } from 'sql/platform/theme/common/styler';
|
|
||||||
import { Dropdown } from 'sql/base/parts/editableDropdown/browser/dropdown';
|
import { Dropdown } from 'sql/base/parts/editableDropdown/browser/dropdown';
|
||||||
import { Task } from 'sql/workbench/services/tasks/browser/tasksRegistry';
|
import { Task } from 'sql/workbench/services/tasks/browser/tasksRegistry';
|
||||||
import { IObjectExplorerService } from 'sql/workbench/services/objectExplorer/browser/objectExplorerService';
|
import { IObjectExplorerService } from 'sql/workbench/services/objectExplorer/browser/objectExplorerService';
|
||||||
@@ -578,8 +577,6 @@ export class ListDatabasesActionItem extends Disposable implements IActionViewIt
|
|||||||
private _isConnected: boolean;
|
private _isConnected: boolean;
|
||||||
private _databaseListDropdown: HTMLElement;
|
private _databaseListDropdown: HTMLElement;
|
||||||
private _dropdown: Dropdown;
|
private _dropdown: Dropdown;
|
||||||
private _databaseSelectBox: SelectBox;
|
|
||||||
private _isInAccessibilityMode: boolean;
|
|
||||||
private readonly _selectDatabaseString: string = nls.localize("selectDatabase", "Select Database");
|
private readonly _selectDatabaseString: string = nls.localize("selectDatabase", "Select Database");
|
||||||
|
|
||||||
// CONSTRUCTOR /////////////////////////////////////////////////////////
|
// CONSTRUCTOR /////////////////////////////////////////////////////////
|
||||||
@@ -588,20 +585,10 @@ export class ListDatabasesActionItem extends Disposable implements IActionViewIt
|
|||||||
@IContextViewService contextViewProvider: IContextViewService,
|
@IContextViewService contextViewProvider: IContextViewService,
|
||||||
@IConnectionManagementService private readonly connectionManagementService: IConnectionManagementService,
|
@IConnectionManagementService private readonly connectionManagementService: IConnectionManagementService,
|
||||||
@INotificationService private readonly notificationService: INotificationService,
|
@INotificationService private readonly notificationService: INotificationService,
|
||||||
@IConfigurationService private readonly configurationService: IConfigurationService,
|
|
||||||
@ILogService private readonly logService: ILogService
|
@ILogService private readonly logService: ILogService
|
||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
this._databaseListDropdown = $('.databaseListDropdown');
|
this._databaseListDropdown = $('.databaseListDropdown');
|
||||||
this._isInAccessibilityMode = this.configurationService.getValue('editor.accessibilitySupport') === 'on';
|
|
||||||
|
|
||||||
if (this._isInAccessibilityMode) {
|
|
||||||
this._databaseSelectBox = new SelectBox([this._selectDatabaseString], this._selectDatabaseString, contextViewProvider, undefined, { ariaLabel: this._selectDatabaseString });
|
|
||||||
this._databaseSelectBox.render(this._databaseListDropdown);
|
|
||||||
this._databaseSelectBox.onDidSelect(e => { this.databaseSelected(e.selected); });
|
|
||||||
this._databaseSelectBox.disable();
|
|
||||||
|
|
||||||
} else {
|
|
||||||
this._dropdown = new Dropdown(this._databaseListDropdown, contextViewProvider, {
|
this._dropdown = new Dropdown(this._databaseListDropdown, contextViewProvider, {
|
||||||
strictSelection: true,
|
strictSelection: true,
|
||||||
placeholder: this._selectDatabaseString,
|
placeholder: this._selectDatabaseString,
|
||||||
@@ -609,9 +596,6 @@ export class ListDatabasesActionItem extends Disposable implements IActionViewIt
|
|||||||
});
|
});
|
||||||
this._register(this._dropdown.onValueChange(s => this.databaseSelected(s)));
|
this._register(this._dropdown.onValueChange(s => this.databaseSelected(s)));
|
||||||
this._register(this._dropdown.onFocus(() => this.onDropdownFocus()));
|
this._register(this._dropdown.onFocus(() => this.onDropdownFocus()));
|
||||||
}
|
|
||||||
|
|
||||||
// Register event handlers
|
|
||||||
this._register(this.connectionManagementService.onConnectionChanged(params => this.onConnectionChanged(params)));
|
this._register(this.connectionManagementService.onConnectionChanged(params => this.onConnectionChanged(params)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -621,13 +605,8 @@ export class ListDatabasesActionItem extends Disposable implements IActionViewIt
|
|||||||
}
|
}
|
||||||
|
|
||||||
public style(styles) {
|
public style(styles) {
|
||||||
if (this._isInAccessibilityMode) {
|
|
||||||
this._databaseSelectBox.style(styles);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
this._dropdown.style(styles);
|
this._dropdown.style(styles);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public setActionContext(context: any): void {
|
public setActionContext(context: any): void {
|
||||||
}
|
}
|
||||||
@@ -637,28 +616,16 @@ export class ListDatabasesActionItem extends Disposable implements IActionViewIt
|
|||||||
}
|
}
|
||||||
|
|
||||||
public focus(): void {
|
public focus(): void {
|
||||||
if (this._isInAccessibilityMode) {
|
|
||||||
this._databaseSelectBox.focus();
|
|
||||||
} else {
|
|
||||||
this._dropdown.focus();
|
this._dropdown.focus();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public blur(): void {
|
public blur(): void {
|
||||||
if (this._isInAccessibilityMode) {
|
|
||||||
this._databaseSelectBox.blur();
|
|
||||||
} else {
|
|
||||||
this._dropdown.blur();
|
this._dropdown.blur();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public attachStyler(themeService: IThemeService): IDisposable {
|
public attachStyler(themeService: IThemeService): IDisposable {
|
||||||
if (this._isInAccessibilityMode) {
|
|
||||||
return attachSelectBoxStyler(this, themeService);
|
|
||||||
} else {
|
|
||||||
return attachEditableDropdownStyler(this, themeService);
|
return attachEditableDropdownStyler(this, themeService);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// EVENT HANDLERS FROM EDITOR //////////////////////////////////////////
|
// EVENT HANDLERS FROM EDITOR //////////////////////////////////////////
|
||||||
public onConnected(): void {
|
public onConnected(): void {
|
||||||
@@ -670,14 +637,9 @@ export class ListDatabasesActionItem extends Disposable implements IActionViewIt
|
|||||||
this._isConnected = false;
|
this._isConnected = false;
|
||||||
this._currentDatabaseName = undefined;
|
this._currentDatabaseName = undefined;
|
||||||
|
|
||||||
if (this._isInAccessibilityMode) {
|
|
||||||
this._databaseSelectBox.disable();
|
|
||||||
this._databaseSelectBox.setOptions([this._selectDatabaseString]);
|
|
||||||
} else {
|
|
||||||
this._dropdown.enabled = false;
|
this._dropdown.enabled = false;
|
||||||
this._dropdown.value = '';
|
this._dropdown.value = '';
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// PRIVATE HELPERS /////////////////////////////////////////////////////
|
// PRIVATE HELPERS /////////////////////////////////////////////////////
|
||||||
private databaseSelected(dbName: string): void {
|
private databaseSelected(dbName: string): void {
|
||||||
@@ -768,12 +730,8 @@ export class ListDatabasesActionItem extends Disposable implements IActionViewIt
|
|||||||
}
|
}
|
||||||
|
|
||||||
private resetDatabaseName() {
|
private resetDatabaseName() {
|
||||||
if (this._isInAccessibilityMode) {
|
|
||||||
this._databaseSelectBox.selectWithOptionName(this.getCurrentDatabaseName());
|
|
||||||
} else {
|
|
||||||
this._dropdown.value = this.getCurrentDatabaseName();
|
this._dropdown.value = this.getCurrentDatabaseName();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private onConnectionChanged(connParams: IConnectionParams): void {
|
private onConnectionChanged(connParams: IConnectionParams): void {
|
||||||
if (!connParams) {
|
if (!connParams) {
|
||||||
@@ -825,14 +783,6 @@ export class ListDatabasesActionItem extends Disposable implements IActionViewIt
|
|||||||
private updateConnection(databaseName: string): void {
|
private updateConnection(databaseName: string): void {
|
||||||
this._isConnected = true;
|
this._isConnected = true;
|
||||||
this._currentDatabaseName = databaseName;
|
this._currentDatabaseName = databaseName;
|
||||||
|
|
||||||
if (this._isInAccessibilityMode) {
|
|
||||||
this.getDatabaseNames()
|
|
||||||
.then(databaseNames => {
|
|
||||||
this._databaseSelectBox.setOptions(databaseNames);
|
|
||||||
this._databaseSelectBox.selectWithOptionName(databaseName);
|
|
||||||
}).catch(onUnexpectedError);
|
|
||||||
} else {
|
|
||||||
// Set the value immediately to the initial database so the user can see that, and then
|
// Set the value immediately to the initial database so the user can see that, and then
|
||||||
// populate the list with just that value to avoid displaying an error while we load
|
// populate the list with just that value to avoid displaying an error while we load
|
||||||
// the full list of databases
|
// the full list of databases
|
||||||
@@ -843,7 +793,6 @@ export class ListDatabasesActionItem extends Disposable implements IActionViewIt
|
|||||||
this._dropdown.values = databaseNames;
|
this._dropdown.values = databaseNames;
|
||||||
}).catch(onUnexpectedError);
|
}).catch(onUnexpectedError);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// TESTING PROPERTIES //////////////////////////////////////////////////
|
// TESTING PROPERTIES //////////////////////////////////////////////////
|
||||||
public get currentDatabaseName(): string {
|
public get currentDatabaseName(): string {
|
||||||
|
|||||||
@@ -472,7 +472,7 @@ suite('SQL QueryAction Tests', () => {
|
|||||||
connectionManagementService.setup(x => x.changeDatabase(TypeMoq.It.isAnyString(), TypeMoq.It.isAnyString())).returns(() => Promise.resolve(true));
|
connectionManagementService.setup(x => x.changeDatabase(TypeMoq.It.isAnyString(), TypeMoq.It.isAnyString())).returns(() => Promise.resolve(true));
|
||||||
|
|
||||||
// If I query without having initialized anything, state should be clear
|
// If I query without having initialized anything, state should be clear
|
||||||
listItem = new ListDatabasesActionItem(editor.object, undefined, connectionManagementService.object, undefined, configurationService.object, undefined);
|
listItem = new ListDatabasesActionItem(editor.object, undefined, connectionManagementService.object, undefined, undefined);
|
||||||
|
|
||||||
assert.equal(listItem.isEnabled(), false, 'do not expect dropdown enabled unless connected');
|
assert.equal(listItem.isEnabled(), false, 'do not expect dropdown enabled unless connected');
|
||||||
assert.equal(listItem.currentDatabaseName, undefined, 'do not expect dropdown to have entries unless connected');
|
assert.equal(listItem.currentDatabaseName, undefined, 'do not expect dropdown to have entries unless connected');
|
||||||
@@ -505,7 +505,7 @@ suite('SQL QueryAction Tests', () => {
|
|||||||
connectionManagementService.setup(x => x.changeDatabase(TypeMoq.It.isAnyString(), TypeMoq.It.isAnyString())).returns(() => Promise.resolve(true));
|
connectionManagementService.setup(x => x.changeDatabase(TypeMoq.It.isAnyString(), TypeMoq.It.isAnyString())).returns(() => Promise.resolve(true));
|
||||||
|
|
||||||
// ... Create a database dropdown that has been connected
|
// ... Create a database dropdown that has been connected
|
||||||
let listItem = new ListDatabasesActionItem(editor.object, undefined, connectionManagementService.object, undefined, configurationService.object, undefined);
|
let listItem = new ListDatabasesActionItem(editor.object, undefined, connectionManagementService.object, undefined, undefined);
|
||||||
listItem.onConnected();
|
listItem.onConnected();
|
||||||
|
|
||||||
// If: I raise a connection changed event
|
// If: I raise a connection changed event
|
||||||
@@ -529,7 +529,7 @@ suite('SQL QueryAction Tests', () => {
|
|||||||
connectionManagementService.setup(x => x.changeDatabase(TypeMoq.It.isAnyString(), TypeMoq.It.isAnyString())).returns(() => Promise.resolve(true));
|
connectionManagementService.setup(x => x.changeDatabase(TypeMoq.It.isAnyString(), TypeMoq.It.isAnyString())).returns(() => Promise.resolve(true));
|
||||||
|
|
||||||
// ... Create a database dropdown that has been connected
|
// ... Create a database dropdown that has been connected
|
||||||
let listItem = new ListDatabasesActionItem(editor.object, undefined, connectionManagementService.object, undefined, configurationService.object, undefined);
|
let listItem = new ListDatabasesActionItem(editor.object, undefined, connectionManagementService.object, undefined, undefined);
|
||||||
listItem.onConnected();
|
listItem.onConnected();
|
||||||
|
|
||||||
// If: I raise a connection changed event for the 'wrong' URI
|
// If: I raise a connection changed event for the 'wrong' URI
|
||||||
@@ -554,7 +554,7 @@ suite('SQL QueryAction Tests', () => {
|
|||||||
connectionManagementService.setup(x => x.onConnectionChanged).returns(() => dbChangedEmitter.event);
|
connectionManagementService.setup(x => x.onConnectionChanged).returns(() => dbChangedEmitter.event);
|
||||||
|
|
||||||
// ... Create a database dropdown
|
// ... Create a database dropdown
|
||||||
let listItem = new ListDatabasesActionItem(editor.object, undefined, connectionManagementService.object, undefined, configurationService.object, undefined);
|
let listItem = new ListDatabasesActionItem(editor.object, undefined, connectionManagementService.object, undefined, undefined);
|
||||||
|
|
||||||
// If: I raise a connection changed event
|
// If: I raise a connection changed event
|
||||||
let eventParams = <IConnectionParams>{
|
let eventParams = <IConnectionParams>{
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ suite('SQL QueryEditor Tests', () => {
|
|||||||
instantiationService.setup(x => x.createInstance(TypeMoq.It.isAny(), TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns((classDef, editor, action) => {
|
instantiationService.setup(x => x.createInstance(TypeMoq.It.isAny(), TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns((classDef, editor, action) => {
|
||||||
if (classDef.ID) {
|
if (classDef.ID) {
|
||||||
if (classDef.ID === 'listDatabaseQueryActionItem') {
|
if (classDef.ID === 'listDatabaseQueryActionItem') {
|
||||||
return new ListDatabasesActionItem(editor, undefined, connectionManagementService.object, undefined, configurationService.object, undefined);
|
return new ListDatabasesActionItem(editor, undefined, connectionManagementService.object, undefined, undefined);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Default
|
// Default
|
||||||
@@ -292,7 +292,7 @@ suite('SQL QueryEditor Tests', () => {
|
|||||||
queryActionInstantiationService.setup(x => x.createInstance(TypeMoq.It.isAny(), TypeMoq.It.isAny(), TypeMoq.It.isAny()))
|
queryActionInstantiationService.setup(x => x.createInstance(TypeMoq.It.isAny(), TypeMoq.It.isAny(), TypeMoq.It.isAny()))
|
||||||
.returns((definition, editor, action, selectBox) => {
|
.returns((definition, editor, action, selectBox) => {
|
||||||
if (definition.ID === 'listDatabaseQueryActionItem') {
|
if (definition.ID === 'listDatabaseQueryActionItem') {
|
||||||
let item = new ListDatabasesActionItem(editor, undefined, connectionManagementService.object, undefined, configurationService.object, undefined);
|
let item = new ListDatabasesActionItem(editor, undefined, connectionManagementService.object, undefined, undefined);
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
// Default
|
// Default
|
||||||
|
|||||||
Reference in New Issue
Block a user