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

Commit

Permalink
Merge pull request #287 from atom/provide-reload-button-when-initiali…
Browse files Browse the repository at this point in the history
…zation-fails

Provide "reload" button when displaying initialization error
  • Loading branch information
jasonrudolph authored Jan 2, 2018
2 parents d869f07 + ef85f3b commit d052e60
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 5 deletions.
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const TeletypePackage = require('./lib/teletype-package')
module.exports = new TeletypePackage({
workspace: atom.workspace,
notificationManager: atom.notifications,
packageManager: atom.packages,
commandRegistry: atom.commands,
tooltipManager: atom.tooltips,
clipboard: atom.clipboard,
Expand Down
17 changes: 17 additions & 0 deletions lib/package-initialization-error-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,28 @@ class PackageInitializationErrorComponent {
return $.div({className: 'PackageInitializationErrorComponent'},
$.h3(null, 'Teletype initialization failed'),
$.p(null, 'Make sure your internet connection is working and restart the package.'),
$.div(null,
$.button(
{
ref: 'reloadButton',
type: 'button',
className: 'btn btn-primary inline-block-tight',
onClick: this.restartTeletype
},
'Restart Teletype'
)
),
$.p(null,
'If the problem persists, visit ',
$.a({href: 'https://github.com/atom/teletype/issues/new', className: 'text-info'}, 'atom/teletype'),
' and open an issue.'
)
)
}

async restartTeletype () {
const {packageManager} = this.props
await packageManager.deactivatePackage('teletype')
await packageManager.activatePackage('teletype')
}
}
5 changes: 3 additions & 2 deletions lib/popover-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class PopoverComponent {
const {
isClientOutdated, initializationError,
authenticationProvider, portalBindingManager,
commandRegistry, clipboard, workspace, notificationManager
commandRegistry, clipboard, workspace, notificationManager, packageManager
} = this.props

let activeComponent
Expand All @@ -34,7 +34,8 @@ class PopoverComponent {
})
} else if (initializationError) {
activeComponent = $(PackageInitializationErrorComponent, {
ref: 'packageInitializationErrorComponent'
ref: 'packageInitializationErrorComponent',
packageManager
})
} else if (this.props.authenticationProvider.isSignedIn()) {
activeComponent = $(PortalListComponent, {
Expand Down
11 changes: 8 additions & 3 deletions lib/teletype-package.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ module.exports =
class TeletypePackage {
constructor (options) {
const {
workspace, notificationManager, commandRegistry, tooltipManager, clipboard,
credentialCache, pubSubGateway, pusherKey, pusherOptions, baseURL, tetherDisconnectWindow
baseURL, clipboard, commandRegistry, credentialCache, notificationManager,
packageManager, pubSubGateway, pusherKey, pusherOptions,
tetherDisconnectWindow, tooltipManager, workspace
} = options

this.workspace = workspace
this.notificationManager = notificationManager
this.packageManager = packageManager
this.commandRegistry = commandRegistry
this.tooltipManager = tooltipManager
this.clipboard = clipboard
Expand Down Expand Up @@ -63,6 +65,8 @@ class TeletypePackage {
}

async deactivate () {
this.initializationError = null

if (this.subscriptions) this.subscriptions.dispose() // Package is not activated in specs
if (this.portalStatusBarIndicator) this.portalStatusBarIndicator.destroy()

Expand Down Expand Up @@ -127,7 +131,8 @@ class TeletypePackage {
commandRegistry: this.commandRegistry,
clipboard: this.clipboard,
workspace: this.workspace,
notificationManager: this.notificationManager
notificationManager: this.notificationManager,
packageManager: this.packageManager
})

this.portalStatusBarIndicator.attach()
Expand Down
4 changes: 4 additions & 0 deletions styles/teletype.less
Original file line number Diff line number Diff line change
Expand Up @@ -415,4 +415,8 @@
color: @text-color;
text-align: center;
padding: 0 @component-padding @component-padding @component-padding;

.btn {
margin-bottom: @component-padding * 1.5;
}
}

0 comments on commit d052e60

Please sign in to comment.