diff --git a/index.js b/index.js index 3cfeca95..c76ac6bc 100644 --- a/index.js +++ b/index.js @@ -11,5 +11,6 @@ module.exports = new TeletypePackage({ cluster: atom.config.get('teletype.pusherCluster'), disableStats: true }, - baseURL: atom.config.get('teletype.baseURL') + baseURL: atom.config.get('teletype.baseURL'), + getAtomVersion: atom.getVersion.bind(atom) }) diff --git a/lib/package-initialization-error-component.js b/lib/package-initialization-error-component.js index c06a975c..7178d541 100644 --- a/lib/package-initialization-error-component.js +++ b/lib/package-initialization-error-component.js @@ -1,4 +1,5 @@ const etch = require('etch') +const {URL} = require('url') const $ = etch.dom module.exports = @@ -16,7 +17,6 @@ class PackageInitializationErrorComponent { render () { return $.div({className: 'PackageInitializationErrorComponent'}, $.h3(null, 'Teletype initialization failed'), - $.p(null, 'Error: ' + this.props.initializationError.message), $.p(null, 'Make sure your internet connection is working and restart the package.'), $.div(null, $.button( @@ -31,15 +31,38 @@ class PackageInitializationErrorComponent { ), $.p(null, 'If the problem persists, visit ', - $.a({href: 'https://github.com/atom/teletype/issues/new', className: 'text-info'}, 'atom/teletype'), + $.a({href: this.getIssueURL(), className: 'text-info'}, 'atom/teletype'), ' and open an issue.' ) ) } + getIssueURL () { + const {initializationError} = this.props + + const url = new URL('https://github.com/atom/teletype/issues/new') + url.searchParams.append('title', 'Package Initialization Error') + url.searchParams.append('body', + '### Diagnostics\n\n' + + '```\n' + + initializationError.diagnosticMessage + '\n\n' + + '```\n' + + '### Versions\n\n' + + `**Teletype version**: v${getTeletypeVersion()}\n` + + `**Atom version**: ${this.props.getAtomVersion()}\n` + + `**Platform**: ${process.platform}\n` + ) + + return url.href + } + async restartTeletype () { const {packageManager} = this.props await packageManager.deactivatePackage('teletype') await packageManager.activatePackage('teletype') } } + +function getTeletypeVersion () { + return require('../package.json').version +} diff --git a/lib/popover-component.js b/lib/popover-component.js index 438160cb..5e1567d0 100644 --- a/lib/popover-component.js +++ b/lib/popover-component.js @@ -23,7 +23,7 @@ class PopoverComponent { const { isClientOutdated, initializationError, authenticationProvider, portalBindingManager, - commandRegistry, clipboard, workspace, notificationManager, packageManager + commandRegistry, clipboard, workspace, notificationManager, packageManager, getAtomVersion } = this.props let activeComponent @@ -36,6 +36,7 @@ class PopoverComponent { activeComponent = $(PackageInitializationErrorComponent, { ref: 'packageInitializationErrorComponent', packageManager, + getAtomVersion, initializationError }) } else if (this.props.authenticationProvider.isSignedIn()) { diff --git a/lib/teletype-package.js b/lib/teletype-package.js index 16b1c291..077d5362 100644 --- a/lib/teletype-package.js +++ b/lib/teletype-package.js @@ -9,9 +9,9 @@ module.exports = class TeletypePackage { constructor (options) { const { - baseURL, clipboard, commandRegistry, credentialCache, notificationManager, - packageManager, pubSubGateway, pusherKey, pusherOptions, - tetherDisconnectWindow, tooltipManager, workspace + baseURL, clipboard, commandRegistry, credentialCache, getAtomVersion, + notificationManager, packageManager, pubSubGateway, pusherKey, + pusherOptions, tetherDisconnectWindow, tooltipManager, workspace } = options this.workspace = workspace @@ -24,6 +24,7 @@ class TeletypePackage { this.pusherKey = pusherKey this.pusherOptions = pusherOptions this.baseURL = baseURL + this.getAtomVersion = getAtomVersion this.tetherDisconnectWindow = tetherDisconnectWindow this.credentialCache = credentialCache || new CredentialCache() this.client = new TeletypeClient({ @@ -132,7 +133,8 @@ class TeletypePackage { clipboard: this.clipboard, workspace: this.workspace, notificationManager: this.notificationManager, - packageManager: this.packageManager + packageManager: this.packageManager, + getAtomVersion: this.getAtomVersion }) this.portalStatusBarIndicator.attach() diff --git a/package.json b/package.json index b8b992cf..0a8462c5 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "temp": "^0.8.3" }, "dependencies": { - "@atom/teletype-client": "^0.32.0", + "@atom/teletype-client": "^0.33.0", "etch": "^0.12.6" }, "consumedServices": { diff --git a/test/teletype-package.test.js b/test/teletype-package.test.js index 7421616f..023238fc 100644 --- a/test/teletype-package.test.js +++ b/test/teletype-package.test.js @@ -1101,6 +1101,7 @@ suite('TeletypePackage', function () { commandRegistry: env.commands, tooltipManager: env.tooltips, clipboard: new FakeClipboard(), + getAtomVersion: function () { return 'x.y.z' }, tetherDisconnectWindow: 300, credentialCache })