From 34170e77411174ab5a64dcefcf3206dd7bec9fdb Mon Sep 17 00:00:00 2001 From: Charles Gagnon Date: Wed, 18 Nov 2020 15:42:33 -0800 Subject: [PATCH] Fix Loading component removal (#13478) * Fix Loading component removal * More undefined checks --- .../modelComponents/loadingComponent.component.ts | 5 +++++ .../workbench/browser/modelComponents/viewBase.ts | 12 ++++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/sql/workbench/browser/modelComponents/loadingComponent.component.ts b/src/sql/workbench/browser/modelComponents/loadingComponent.component.ts index 0cb15ab635..ce7657c090 100644 --- a/src/sql/workbench/browser/modelComponents/loadingComponent.component.ts +++ b/src/sql/workbench/browser/modelComponents/loadingComponent.component.ts @@ -95,6 +95,11 @@ export default class LoadingComponent extends ComponentBase { + 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);