Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove atom-space-pen-view #468

Merged
merged 11 commits into from
Feb 7, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: remove atom-space-pen-view
  • Loading branch information
UziTech committed Feb 7, 2020
commit a2768cc892d4a4e5ed63860b98a1ddf13b2cec82
68 changes: 32 additions & 36 deletions lib/fork-gistid-input-view.js
Original file line number Diff line number Diff line change
@@ -1,52 +1,48 @@
const { CompositeDisposable } = require('atom');
const { TextEditorView, View } = require('atom-space-pen-views');
const { CompositeDisposable } = require('atom')

let oldView = null;
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 () {
module.exports = class ForkGistIdInputView {
constructor (callbackInstance) {
if (oldView) {
oldView.destroy();
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()));
this.attach();
}
oldView = this

destroy () {
this.disposables.dispose();
this.detach();
}
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()

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

detach () {
this.panel.destroy();
super.detach(...arguments);
destroy () {
this.disposables.dispose()
this.panel.destroy()
}

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

setCallbackInstance (callbackInstance) {
this.callbackInstance = callbackInstance;
createElement () {
this.editor = document.createElement('atom-text-editor')
this.editor.setAttribute('mini', true)
this.editor.setAttribute('placeholder-text', 'Gist ID to fork')
this.editor.style.marginBottom = 0

this.element = document.createElement('div')
this.element.classList.add('command-palette')
this.element.append(this.editor)
}
};
}
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
"atomTestRunner": "atom-jasmine3-test-runner",
"dependencies": {
"@octokit/rest": "^16.43.1",
"atom-space-pen-views": "^2.2.0",
"semver": "^7.1.2",
"underscore-plus": "^1.7.0"
},
Expand Down