Fix for manage access dialog focus (#9114)

* Fix for manage access dialog focus

* Leverage eventuallyRunOnInitialized
This commit is contained in:
Chris LaFreniere
2020-02-13 16:40:23 -08:00
committed by GitHub
parent bbf6fcb0fc
commit 2503b18d4b

View File

@@ -13,6 +13,7 @@ import { HdfsError } from '../webhdfs';
import { ApiWrapper } from '../../apiWrapper';
import { IconPathHelper } from '../../iconHelper';
import { HdfsFileType } from '../fileStatus';
import { EventEmitter } from 'vscode';
const permissionsTypeIconColumnWidth = 35;
const permissionsDeleteColumnWidth = 50;
@@ -49,6 +50,7 @@ export class ManageAccessDialog {
private posixPermissionCheckboxesMapping: PermissionCheckboxesMapping[] = [];
private namedSectionInheritCheckboxes: azdata.CheckBoxComponent[] = [];
private addUserOrGroupSelectedType: AclType;
private onViewInitializedEvent: EventEmitter<void> = new EventEmitter();
constructor(private hdfsPath: string, private fileSource: IFileSource, private readonly apiWrapper: ApiWrapper) {
this.hdfsModel = new HdfsModel(this.fileSource, this.hdfsPath);
@@ -92,7 +94,6 @@ export class ManageAccessDialog {
await modelView.initializeModel(this.rootLoadingComponent);
this.modelInitialized = true;
this.handlePermissionStatusUpdated(this.hdfsModel.permissionStatus);
this.addUserOrGroupInput.focus();
});
this.dialog.content = [tab];
}
@@ -238,6 +239,7 @@ export class ManageAccessDialog {
.component();
contentContainer.addItem(this.namedUsersAndGroupsPermissionsContainer, { flex: '1', CSSStyles: { 'overflow': 'scroll', 'min-height': '200px' } });
this.viewInitialized = true;
this.onViewInitializedEvent.fire();
}
private handlePermissionStatusUpdated(permissionStatus: PermissionStatus): void {
@@ -250,6 +252,7 @@ export class ManageAccessDialog {
this.initializeView(permissionStatus);
}
this.eventuallyRunOnInitialized(() => {
this.stickyCheckbox.checked = permissionStatus.stickyBit;
if (this.hdfsModel.fileStatus.type === HdfsFileType.Directory) {
this.inheritDefaultsCheckbox.checked =
@@ -324,6 +327,9 @@ export class ManageAccessDialog {
this.namedUsersAndGroupsPermissionsContainer.addItem(namedUsersAndGroupsTable);
this.rootLoadingComponent.loading = false;
this.addUserOrGroupInput.focus();
});
}
private createRadioButton(modelBuilder: azdata.ModelBuilder, label: string, name: string, aclEntryType: AclType): azdata.RadioButtonComponent {
@@ -583,6 +589,25 @@ export class ManageAccessDialog {
return sectionHeaderContainer;
}
/**
* Runs the specified action when the component is initialized. If already initialized just runs
* the action immediately.
* @param action The action to be ran when the page is initialized
*/
protected eventuallyRunOnInitialized(action: () => void): void {
if (!this.viewInitialized) {
this.onViewInitializedEvent.event(() => {
try {
action();
} catch (error) {
console.error(`Unexpected error running onInitialized action for Manage Access dialog : ${error}`);
}
});
} else {
action();
}
}
}
/**