From c4e59027fc03814d95d14b46cc5fd80572356705 Mon Sep 17 00:00:00 2001 From: udeeshagautam <46980425+udeeshagautam@users.noreply.github.com> Date: Thu, 30 May 2019 12:32:38 -0700 Subject: [PATCH] Backup to open correctly from insights dialog (#5737) * recreate modal dialog button to ensure onDidClick works properly * fixing comment message * Adding PR comments --- src/sql/workbench/browser/modal/modal.ts | 16 ++++++++++++++++ .../insights/browser/insightsDialogView.ts | 4 +++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/sql/workbench/browser/modal/modal.ts b/src/sql/workbench/browser/modal/modal.ts index 36a6fa8ca3..822e7a4e02 100644 --- a/src/sql/workbench/browser/modal/modal.ts +++ b/src/sql/workbench/browser/modal/modal.ts @@ -412,6 +412,22 @@ export abstract class Modal extends Disposable implements IThemable { }); } + /** + * removes the footer button matching the provided label + * @param label Label on the button + */ + protected removeFooterButton(label: string): void { + let buttonIndex = this._footerButtons.findIndex(e => { + return e && e.element && e.element.innerText === label; + }); + if (buttonIndex > -1 && buttonIndex < this._footerButtons.length) { + let button = this._footerButtons[buttonIndex]; + DOM.removeNode(button.element); + button.dispose(); + this._footerButtons.splice(buttonIndex, 1); + } + } + /** * Show an error in the error message element * @param message Text to show in the message diff --git a/src/sql/workbench/services/insights/browser/insightsDialogView.ts b/src/sql/workbench/services/insights/browser/insightsDialogView.ts index 25affeabbe..2ee4605deb 100644 --- a/src/sql/workbench/services/insights/browser/insightsDialogView.ts +++ b/src/sql/workbench/services/insights/browser/insightsDialogView.ts @@ -337,7 +337,9 @@ export class InsightsDialogView extends Modal { let task = tasks.includes(action); let commandAction = MenuRegistry.getCommand(action); let commandLabel = types.isString(commandAction.title) ? commandAction.title : commandAction.title.value; - if (task && !this.findFooterButton(commandLabel)) { + if (task) { + // need to remove and add fresh because the onDidClick action from previous addition is not called + this.removeFooterButton(commandLabel); let button = this.addFooterButton(commandLabel, () => { let element = this._topTable.getSelectedRows(); let resource: ListResource;