Fix Loading component removal (#13478)

* Fix Loading component removal

* More undefined checks
This commit is contained in:
Charles Gagnon
2020-11-18 15:42:33 -08:00
committed by GitHub
parent f5e4b32d01
commit 34170e7741
2 changed files with 17 additions and 0 deletions

View File

@@ -95,6 +95,11 @@ export default class LoadingComponent extends ComponentBase<azdata.LoadingCompon
this.layout();
}
public removeFromContainer(_componentDescriptor: IComponentDescriptor): void {
this._component = undefined;
this.layout();
}
public getStatusText(): string {
return this.loading ? this.loadingText : this.loadingCompletedText;
}

View File

@@ -88,6 +88,10 @@ export abstract class ViewBase extends AngularDisposable implements IModelView {
clearContainer(componentId: string): void {
this.logService.debug(`Queuing action to clear component ${componentId}`);
this.queueAction(componentId, (component) => {
if (!component.clearContainer) {
this.logService.warn(`Trying to clear container ${componentId} but does not implement clearContainer!`);
return;
}
this.logService.debug(`Clearing component ${componentId}`);
component.clearContainer();
});
@@ -97,6 +101,10 @@ export abstract class ViewBase extends AngularDisposable implements IModelView {
this.logService.debug(`Queueing action to add component ${itemConfig.componentShape.id} to container ${containerId}`);
// Do not return the promise as this should be non-blocking
this.queueAction(containerId, (component) => {
if (!component.addToContainer) {
this.logService.warn(`Container ${containerId} is trying to add component ${itemConfig.componentShape.id} but does not implement addToContainer!`);
return;
}
this.logService.debug(`Adding component ${itemConfig.componentShape.id} to container ${containerId}`);
let childDescriptor = this.defineComponent(itemConfig.componentShape);
component.addToContainer(childDescriptor, itemConfig.config, index);
@@ -107,6 +115,10 @@ export abstract class ViewBase extends AngularDisposable implements IModelView {
this.logService.debug(`Queueing action to remove component ${itemConfig.componentShape.id} from container ${containerId}`);
let childDescriptor = this.modelStore.getComponentDescriptor(itemConfig.componentShape.id);
this.queueAction(containerId, (component) => {
if (!component.removeFromContainer) {
this.logService.warn(`Container ${containerId} is trying to remove component ${itemConfig.componentShape.id} but does not implement removeFromContainer!`);
return;
}
this.logService.debug(`Removing component ${itemConfig.componentShape.id} from container ${containerId}`);
component.removeFromContainer(childDescriptor);
this.removeComponent(itemConfig.componentShape);