This repository was archived by the owner on Dec 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 324
/
Copy pathpackage-initialization-error-component.js
68 lines (60 loc) · 1.8 KB
/
package-initialization-error-component.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
const etch = require('etch')
const {URL} = require('url')
const $ = etch.dom
module.exports =
class PackageInitializationErrorComponent {
constructor (props) {
this.props = props
etch.initialize(this)
}
update (props) {
Object.assign(this.props, props)
return etch.update(this)
}
render () {
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: 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
}