diff --git a/extensions/import/src/test/wizard/pages/fileConfigPage.test.ts b/extensions/import/src/test/wizard/pages/fileConfigPage.test.ts index b677239966..8f4fb35a12 100644 --- a/extensions/import/src/test/wizard/pages/fileConfigPage.test.ts +++ b/extensions/import/src/test/wizard/pages/fileConfigPage.test.ts @@ -108,7 +108,6 @@ describe('File config page', function () { should.notEqual(fileConfigPage.tableNameTextBox, undefined, 'tableNameTextBox should not be undefined'); should.notEqual(fileConfigPage.schemaDropdown, undefined, 'schemaDropdown should not be undefined'); should.notEqual(fileConfigPage.form, undefined, 'form should not be undefined'); - should.notEqual(fileConfigPage.databaseLoader, undefined, 'databaseLoader should not be undefined'); should.notEqual(fileConfigPage.schemaLoader, undefined, 'schemaLoader should not be undefined'); await fileConfigPage.onPageLeave(); diff --git a/extensions/import/src/wizard/pages/fileConfigPage.ts b/extensions/import/src/wizard/pages/fileConfigPage.ts index c71a8c78b9..6844dd19ce 100644 --- a/extensions/import/src/wizard/pages/fileConfigPage.ts +++ b/extensions/import/src/wizard/pages/fileConfigPage.ts @@ -18,7 +18,6 @@ export class FileConfigPage extends ImportPage { private _schemaDropdown: azdata.DropDownComponent; private _form: azdata.FormContainer; - private _databaseLoader: azdata.LoadingComponent; private _schemaLoader: azdata.LoadingComponent; public get serverDropdown(): azdata.DropDownComponent { @@ -77,14 +76,6 @@ export class FileConfigPage extends ImportPage { this._form = form; } - public get databaseLoader(): azdata.LoadingComponent { - return this._databaseLoader; - } - - public set databaseLoader(databaseLoader: azdata.LoadingComponent) { - this._databaseLoader = databaseLoader; - } - public get schemaLoader(): azdata.LoadingComponent { return this._schemaLoader; } @@ -139,7 +130,7 @@ export class FileConfigPage extends ImportPage { public setupNavigationValidator() { this.instance.registerNavigationValidator((info) => { - if (this.schemaLoader.loading || this.databaseLoader.loading) { + if (this.schemaLoader.loading || this.databaseDropdown.loading) { return false; } return true; @@ -195,22 +186,20 @@ export class FileConfigPage extends ImportPage { this.populateSchemaDropdown(); }); - this.databaseLoader = this.view.modelBuilder.loadingComponent().withItem(this.databaseDropdown).component(); - return { - component: this.databaseLoader, + component: this.databaseDropdown, title: constants.databaseDropdownTitleText }; } private async populateDatabaseDropdown(): Promise { - this.databaseLoader.loading = true; + this.databaseDropdown.loading = true; this.databaseDropdown.updateProperties({ values: [] }); this.schemaDropdown.updateProperties({ values: [] }); if (!this.model.server) { //TODO handle error case - this.databaseLoader.loading = false; + this.databaseDropdown.loading = false; return false; } @@ -233,7 +222,7 @@ export class FileConfigPage extends ImportPage { }); this.databaseDropdown.value = { displayName: this.model.database, name: this.model.database }; - this.databaseLoader.loading = false; + this.databaseDropdown.loading = false; return true; } diff --git a/src/sql/azdata.proposed.d.ts b/src/sql/azdata.proposed.d.ts index a06d1462da..3a9b5483ac 100644 --- a/src/sql/azdata.proposed.d.ts +++ b/src/sql/azdata.proposed.d.ts @@ -6,6 +6,7 @@ // This is the place for API experiments and proposal. import * as vscode from 'vscode'; +import { LoadingComponentProperties } from 'azdata'; declare module 'azdata' { /** @@ -256,6 +257,9 @@ declare module 'azdata' { withProps(properties: TPropertyBag): ComponentBuilder; } + export interface DropDownProperties extends LoadingComponentProperties { + } + export interface RadioCard { id: string; descriptions: RadioCardDescription[]; diff --git a/src/sql/workbench/api/common/extHostModelView.ts b/src/sql/workbench/api/common/extHostModelView.ts index d10f11b195..f2067bd485 100644 --- a/src/sql/workbench/api/common/extHostModelView.ts +++ b/src/sql/workbench/api/common/extHostModelView.ts @@ -1450,6 +1450,22 @@ class DropDownWrapper extends ComponentWrapper implements azdata.DropDownCompone this.setProperty('fireOnTextChange', v); } + public get loading(): boolean { + return this.properties['loading']; + } + + public set loading(v: boolean) { + this.setProperty('loading', v); + } + + public get loadingText(): string { + return this.properties['loadingText']; + } + + public set loadingText(v: string) { + this.setProperty('loadingText', v); + } + public get onValueChanged(): vscode.Event { let emitter = this._emitterMap.get(ComponentEventType.onDidChange); return emitter && emitter.event; diff --git a/src/sql/workbench/browser/modelComponents/dropdown.component.ts b/src/sql/workbench/browser/modelComponents/dropdown.component.ts index f9b4cf49b9..5f9e048e30 100644 --- a/src/sql/workbench/browser/modelComponents/dropdown.component.ts +++ b/src/sql/workbench/browser/modelComponents/dropdown.component.ts @@ -21,12 +21,17 @@ import { IContextViewService } from 'vs/platform/contextview/browser/contextView import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { find } from 'vs/base/common/arrays'; import { IComponent, IComponentDescriptor, IModelStore, ComponentEventType } from 'sql/platform/dashboard/browser/interfaces'; +import { localize } from 'vs/nls'; @Component({ selector: 'modelview-dropdown', template: `
+
+
+
+
@@ -38,9 +43,11 @@ export default class DropDownComponent extends ComponentBase ChangeDetectorRef)) changeRef: ChangeDetectorRef, @Inject(IWorkbenchThemeService) private themeService: IWorkbenchThemeService, @@ -103,6 +110,12 @@ export default class DropDownComponent extends ComponentBase !this.required || this.editable || !!this._selectBox.value); } + + this._loadingBox = new SelectBox([this.getStatusText()], this.getStatusText(), this.contextViewService, this._loadingBoxContainer.nativeElement); + this._loadingBox.render(this._loadingBoxContainer.nativeElement); + this._register(this._loadingBox); + this._register(attachSelectBoxStyler(this._loadingBox, this.themeService)); + this._loadingBoxContainer.nativeElement.className = ''; // Removing the dropdown arrow icon from the right } ngOnDestroy(): void { @@ -122,6 +135,7 @@ export default class DropDownComponent extends ComponentBase((props) => props.showText, false); + } + + public get loading(): boolean { + return this.getPropertyOrDefault((props) => props.loading, false); + } + + public get loadingText(): string { + return this.getPropertyOrDefault((props) => props.loadingText, localize('loadingMessage', "Loading")); + } + + public get loadingCompletedText(): string { + return this.getPropertyOrDefault((props) => props.loadingCompletedText, localize('loadingCompletedMessage', "Loading completed")); + } + + public getStatusText(): string { + return this.loading ? this.loadingText : this.loadingCompletedText; + } }