Skip to content

Commit

Permalink
fix: remove atom-space-pen-view (#468)
Browse files Browse the repository at this point in the history
* clean up code

* dispose disposables on deactivate

* create client mock

* add eslint rules

* clean up eslint config

* mergeFiles in client mock

* remove semi

* fix: remove atom-space-pen-view

* remove inline style

* clean up code

* move require
  • Loading branch information
UziTech authored Feb 7, 2020
1 parent f28fd70 commit 9732372
Show file tree
Hide file tree
Showing 12 changed files with 1,733 additions and 1,831 deletions.
43 changes: 20 additions & 23 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
module.exports = {
env: {
browser: true,
commonjs: true,
es6: true,
node: true,
jasmine: true,
atomtest: true
},
extends: [
'standard'
],
globals: {
atom: 'readonly',
Atomics: 'readonly',
SharedArrayBuffer: 'readonly'
},
parserOptions: {
ecmaVersion: 2018
},
rules: {
"handle-callback-err": "off",
camelcase: "off"
}
env: {
node: true,
jasmine: true,
atomtest: true,
},
extends: [
'standard',
],
globals: {
atom: 'readonly',
},
parserOptions: {
ecmaVersion: 2018,
},
rules: {
"no-warning-comments": "warn",
"comma-dangle": ["error", "always-multiline"],
indent: ["error", "tab"],
"no-tabs": ["error", { allowIndentationTabs: true }],
},
}
180 changes: 90 additions & 90 deletions lib/config.js
Original file line number Diff line number Diff line change
@@ -1,92 +1,92 @@
module.exports = {
personalAccessToken: {
description: 'Your personal GitHub access token',
type: 'string',
default: '',
order: 1
},
gistId: {
description: 'ID of gist to use for configuration storage',
type: 'string',
default: '',
order: 2
},
gistDescription: {
description: 'The description of the gist',
type: 'string',
default: 'automatic update by http://atom.io/packages/sync-settings',
order: 3
},
syncSettings: {
type: 'boolean',
default: true,
order: 4
},
blacklistedKeys: {
description: "Comma-seperated list of blacklisted keys (e.g. 'package-name,other-package-name.config-name')",
type: 'array',
default: [],
items: {
type: 'string'
},
order: 5
},
syncPackages: {
type: 'boolean',
default: true,
order: 6
},
syncKeymap: {
type: 'boolean',
default: true,
order: 7
},
syncStyles: {
type: 'boolean',
default: true,
order: 8
},
syncInit: {
type: 'boolean',
default: true,
order: 9
},
syncSnippets: {
type: 'boolean',
default: true,
order: 10
},
extraFiles: {
description: 'Comma-seperated list of files other than Atom\'s default config files in ~/.atom',
type: 'array',
default: [],
items: {
type: 'string'
},
order: 11
},
checkForUpdatedBackup: {
description: 'Check for newer backup on Atom start',
type: 'boolean',
default: true,
order: 12
},
_lastBackupHash: {
type: 'string',
default: '',
description: 'Hash of the last backup restored or created',
order: 13
},
quietUpdateCheck: {
type: 'boolean',
default: false,
description: "Mute 'Latest backup is already applied' message",
order: 14
},
removeObsoletePackages: {
description: 'Packages installed but not in the backup will be removed when restoring backups',
type: 'boolean',
default: false,
order: 15
}
personalAccessToken: {
description: 'Your personal GitHub access token',
type: 'string',
default: '',
order: 1,
},
gistId: {
description: 'ID of gist to use for configuration storage',
type: 'string',
default: '',
order: 2,
},
gistDescription: {
description: 'The description of the gist',
type: 'string',
default: 'automatic update by http://atom.io/packages/sync-settings',
order: 3,
},
syncSettings: {
type: 'boolean',
default: true,
order: 4,
},
blacklistedKeys: {
description: "Comma-seperated list of blacklisted keys (e.g. 'package-name,other-package-name.config-name')",
type: 'array',
default: [],
items: {
type: 'string',
},
order: 5,
},
syncPackages: {
type: 'boolean',
default: true,
order: 6,
},
syncKeymap: {
type: 'boolean',
default: true,
order: 7,
},
syncStyles: {
type: 'boolean',
default: true,
order: 8,
},
syncInit: {
type: 'boolean',
default: true,
order: 9,
},
syncSnippets: {
type: 'boolean',
default: true,
order: 10,
},
extraFiles: {
description: "Comma-seperated list of files other than Atom's default config files in ~/.atom",
type: 'array',
default: [],
items: {
type: 'string',
},
order: 11,
},
checkForUpdatedBackup: {
description: 'Check for newer backup on Atom start',
type: 'boolean',
default: true,
order: 12,
},
_lastBackupHash: {
type: 'string',
default: '',
description: 'Hash of the last backup restored or created',
order: 13,
},
quietUpdateCheck: {
type: 'boolean',
default: false,
description: "Mute 'Latest backup is already applied' message",
order: 14,
},
removeObsoletePackages: {
description: 'Packages installed but not in the backup will be removed when restoring backups',
type: 'boolean',
default: false,
order: 15,
},
}
93 changes: 42 additions & 51 deletions lib/fork-gistid-input-view.js
Original file line number Diff line number Diff line change
@@ -1,56 +1,47 @@
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* DS207: Consider shorter variations of null checks
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
const { CompositeDisposable } = require('atom')
const { TextEditorView, View } = require('atom-space-pen-views')

let oldView = null

module.exports = class ForkGistIdInputView extends View {
static content () {
return this.div({ class: 'command-palette' }, () => {
return this.subview('selectEditor', new TextEditorView({ mini: true, placeholderText: 'Gist ID to fork' }))
})
}

initialize () {
if (oldView != null) {
oldView.destroy()
}
oldView = this

this.disposables = new CompositeDisposable()
this.disposables.add(atom.commands.add('atom-text-editor', 'core:confirm', () => this.confirm()))
this.disposables.add(atom.commands.add('atom-text-editor', 'core:cancel', () => this.destroy()))
return this.attach()
}

destroy () {
this.disposables.dispose()
return this.detach()
}

attach () {
if (this.panel == null) { this.panel = atom.workspace.addModalPanel({ item: this }) }
this.panel.show()
return this.selectEditor.focus()
}

detach () {
this.panel.destroy()
return super.detach(...arguments)
}

confirm () {
const gistId = this.selectEditor.getText()
this.callbackInstance.forkGistId(gistId)
return this.destroy()
}

setCallbackInstance (callbackInstance) {
this.callbackInstance = callbackInstance
}
module.exports = class ForkGistIdInputView {
constructor (callbackInstance) {
if (oldView) {
oldView.destroy()
}
oldView = this

this.disposables = new CompositeDisposable()
this.disposables.add(
atom.commands.add('atom-text-editor', 'core:confirm', this.confirm.bind(this)),
atom.commands.add('atom-text-editor', 'core:cancel', this.destroy.bind(this)),
)
this.callbackInstance = callbackInstance
this.createElement()

if (!this.panel) {
this.panel = atom.workspace.addModalPanel({ item: this })
}
this.panel.show()
this.editor.focus()
}

destroy () {
this.disposables.dispose()
this.panel.destroy()
}

confirm () {
const gistId = this.editor.getText()
this.callbackInstance.forkGistId(gistId)
this.destroy()
}

createElement () {
this.editor = document.createElement('atom-text-editor')
this.editor.setAttribute('mini', true)
this.editor.setAttribute('placeholder-text', 'Gist ID to fork')

this.element = document.createElement('div')
this.element.classList.add('command-palette')
this.element.append(this.editor)
}
}
Loading

0 comments on commit 9732372

Please sign in to comment.