Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Updating disabled package doesn't show restart notification #978

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions lib/package-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
27 changes: 27 additions & 0 deletions spec/package-card-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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}

Expand Down