mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Correctly announce loading state for arc cluster context loading (#15747)
* Correctly announce loading state for arc cluster context loading * localize * Fix compile * Fix test
This commit is contained in:
@@ -6,7 +6,7 @@ import * as azdata from 'azdata';
|
||||
import * as path from 'path';
|
||||
import * as vscode from 'vscode';
|
||||
import * as loc from '../../localizedConstants';
|
||||
|
||||
import { promises as fs } from 'fs';
|
||||
export interface RadioOptionsInfo {
|
||||
values?: string[],
|
||||
defaultValue: string
|
||||
@@ -20,14 +20,24 @@ export class FilePicker {
|
||||
modelBuilder: azdata.ModelBuilder,
|
||||
initialPath: string,
|
||||
onNewDisposableCreated: (disposable: vscode.Disposable) => void,
|
||||
ariaLabel: string
|
||||
ariaLabel: string,
|
||||
validationErrorMessage: string
|
||||
) {
|
||||
const buttonWidth = 80;
|
||||
this.filePathInputBox = modelBuilder.inputBox()
|
||||
.withProperties<azdata.InputBoxProperties>({
|
||||
value: initialPath,
|
||||
ariaLabel: ariaLabel,
|
||||
validationErrorMessage: validationErrorMessage,
|
||||
width: 350
|
||||
}).withValidation(async () => {
|
||||
try {
|
||||
await fs.stat(this.filePathInputBox.value || '');
|
||||
} catch (err) {
|
||||
console.log('Error checking config path ', err);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}).component();
|
||||
|
||||
this.filePickerButton = modelBuilder.button()
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import * as azdata from 'azdata';
|
||||
import * as vscode from 'vscode';
|
||||
import { getErrorMessage } from '../../common/utils';
|
||||
import * as loc from '../../localizedConstants';
|
||||
|
||||
export interface RadioOptionsInfo {
|
||||
values?: string[],
|
||||
@@ -20,7 +20,12 @@ export class RadioOptionsGroup {
|
||||
private _onRadioOptionChanged: vscode.EventEmitter<string | undefined> = new vscode.EventEmitter<string | undefined>();
|
||||
public onRadioOptionChanged: vscode.Event<string | undefined> = this._onRadioOptionChanged.event;
|
||||
|
||||
constructor(private _modelBuilder: azdata.ModelBuilder, private _onNewDisposableCreated: (disposable: vscode.Disposable) => void, private _groupName: string = `RadioOptionsGroup${RadioOptionsGroup.id++}`) {
|
||||
constructor(private _modelBuilder: azdata.ModelBuilder,
|
||||
private _onNewDisposableCreated: (disposable: vscode.Disposable) => void,
|
||||
private _groupName: string = `RadioOptionsGroup${RadioOptionsGroup.id++}`,
|
||||
private _loadingCompleteMessage: string,
|
||||
private _loadingCompleteErrorMessage: (error: any) => string
|
||||
) {
|
||||
this._divContainer = this._modelBuilder.divContainer().withProperties<azdata.DivContainerProperties>({ clickable: false }).component();
|
||||
this._loadingBuilder = this._modelBuilder.loadingComponent().withItem(this._divContainer);
|
||||
}
|
||||
@@ -59,10 +64,12 @@ export class RadioOptionsGroup {
|
||||
}));
|
||||
this._divContainer.addItem(radioOption);
|
||||
});
|
||||
this.component().loadingCompletedText = this._loadingCompleteMessage;
|
||||
}
|
||||
catch (e) {
|
||||
const errorLabel = this._modelBuilder.text().withProperties({ value: getErrorMessage(e), CSSStyles: { 'color': 'Red' } }).component();
|
||||
const errorLabel = this._modelBuilder.text().withProperties({ value: loc.loadingClusterContextsError(e), CSSStyles: { 'color': 'Red' } }).component();
|
||||
this._divContainer.addItem(errorLabel);
|
||||
this.component().loadingCompletedText = this._loadingCompleteErrorMessage(e);
|
||||
}
|
||||
this.component().loading = false;
|
||||
}
|
||||
|
||||
@@ -97,13 +97,14 @@ abstract class ControllerDialogBase extends InitializingComponent {
|
||||
this.modelBuilder,
|
||||
controllerInfo?.kubeConfigFilePath || getDefaultKubeConfigPath(),
|
||||
(disposable) => this._toDispose.push(disposable),
|
||||
loc.controllerKubeConfig
|
||||
loc.controllerKubeConfig,
|
||||
loc.invalidConfigPath
|
||||
);
|
||||
this.modelBuilder.inputBox()
|
||||
.withProps({
|
||||
value: controllerInfo?.kubeConfigFilePath || getDefaultKubeConfigPath()
|
||||
}).component();
|
||||
this.clusterContextRadioGroup = new RadioOptionsGroup(this.modelBuilder, (disposable) => this._toDispose.push(disposable));
|
||||
this.clusterContextRadioGroup = new RadioOptionsGroup(this.modelBuilder, (disposable) => this._toDispose.push(disposable), undefined, loc.loadingClusterContextCompleted, loc.loadingClusterContextsError);
|
||||
this.loadRadioGroup(controllerInfo?.kubeClusterContext);
|
||||
this._toDispose.push(this.clusterContextRadioGroup.onRadioOptionChanged(newContext => this.updateNamespace(newContext)));
|
||||
this._toDispose.push(this.kubeConfigInputBox.onTextChanged(() => this.loadRadioGroup(controllerInfo?.kubeClusterContext)));
|
||||
|
||||
Reference in New Issue
Block a user