-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathserverless-dashboard.js
46 lines (40 loc) · 1.33 KB
/
serverless-dashboard.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
'use babel'
import { CompositeDisposable } from 'atom'
import yaml from 'js-yaml'
import fs from 'fs'
const dashBoardUri = 'atom://serverless-dashboard'
export default {
serverlessDashboardView: null,
modalPanel: null,
subscriptions: null,
activate (state) {
// Events subscribed to in atom's system can be easily cleaned up with a CompositeDisposable
this.subscriptions = new CompositeDisposable()
this.subscriptions.add(atom.workspace.addOpener(((_this) => {
return (filePath) => {
if (filePath === dashBoardUri) {
return _this.openManagemantPanel()
}
}
})(this)))
// Register command that toggles this view
this.subscriptions.add(atom.commands.add('atom-workspace', {
'serverless-dashboard:open-management-panel': () => {
return atom.workspace.open(dashBoardUri)
}
}))
},
deactivate () {
this.modalPanel.destroy()
this.subscriptions.dispose()
},
openManagemantPanel () {
const remote = require('electron').remote
const files = remote.dialog.showOpenDialog(remote.getCurrentWindow(), {properties: ['openFile']})
if (files && files.length) {
const data = yaml.safeLoad(fs.readFileSync(files[0], 'utf8'))
const DashbordView = require('./serverless-dashboard-view')
return new DashbordView(data, files[0])
}
}
}