From 8bd385b36d690b4075cb96df1c2a1c386d942f83 Mon Sep 17 00:00:00 2001 From: Lucas Nestor Date: Fri, 11 Aug 2017 11:31:09 -0400 Subject: [PATCH] Updating disabled package doesn't show restart notification --- lib/package-card.js | 18 ++++++++++-------- spec/package-card-spec.coffee | 27 +++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 8 deletions(-) diff --git a/lib/package-card.js b/lib/package-card.js index d2faf6d3..e8218d17 100644 --- a/lib/package-card.js +++ b/lib/package-card.js @@ -207,14 +207,16 @@ export default class PackageCard { const updateButtonClickHandler = (event) => { event.stopPropagation() this.update().then(() => { - const buttons = [{ - text: 'Restart', - onDidClick () { return atom.restartApplication() } - }] - - atom.notifications.addSuccess(`Restart Atom to complete the update of \`${this.pack.name}\`.`, { - dismissable: true, buttons - }) + if (!this.isDisabled()) { + const buttons = [{ + text: 'Restart', + onDidClick () { return atom.restartApplication() } + }] + + atom.notifications.addSuccess(`Restart Atom to complete the update of \`${this.pack.name}\`.`, { + dismissable: true, buttons + }) + } }) } this.refs.updateButton.addEventListener('click', updateButtonClickHandler) diff --git a/spec/package-card-spec.coffee b/spec/package-card-spec.coffee index f63580fa..76f6e8b3 100644 --- a/spec/package-card-spec.coffee +++ b/spec/package-card-spec.coffee @@ -285,6 +285,33 @@ describe "PackageCard", -> runs -> expect(atom.packages.isPackageDisabled('package-with-config')).toBe true + it "doesn't prompt to restart if package is disabled", -> + pack = atom.packages.getLoadedPackage('package-with-config') + pack.latestVersion = '1.1.0' + pack.disable() + packageUpdated = false + + packageManager.on 'package-updated', -> packageUpdated = true + packageManager.runCommand.andCallFake (args, callback) -> + callback(0, '', '') + onWillThrowError: -> + + originalLoadPackage = atom.packages.loadPackage + spyOn(atom.packages, 'loadPackage').andCallFake -> + originalLoadPackage.call(atom.packages, path.join(__dirname, 'fixtures', 'package-with-config')) + + card = new PackageCard(pack, new SettingsView(), packageManager) + jasmine.attachToDOM(card.element) + expect(card.refs.updateButton).toBeVisible() + + card.refs.updateButton.click() + + waits 0 # Wait for PackageCard.update promise to resolve + + runs -> + notifications = atom.notifications.getNotifications() + expect(notifications.length).toBe 0 + it "is uninstalled when the uninstallButton is clicked", -> setPackageStatusSpies {installed: true, disabled: false}