diff --git a/app/components/main-gist.js b/app/components/main-gist.js index a6d37967..74bf5212 100644 --- a/app/components/main-gist.js +++ b/app/components/main-gist.js @@ -4,10 +4,11 @@ import ColumnsMixin from "../mixins/columns"; import FilesMixin from "../mixins/files"; import TestFilesMixin from "../mixins/test-files"; import AppBuilderMixin from "../mixins/app-builder"; +import { keyDown, EKMixin } from 'ember-keyboard'; -const { inject, computed, run } = Ember; +const { inject, computed, run, on } = Ember; -export default Ember.Component.extend(AppBuilderMixin, ColumnsMixin, FilesMixin, TestFilesMixin, { +export default Ember.Component.extend(AppBuilderMixin, ColumnsMixin, FilesMixin, TestFilesMixin, EKMixin, { emberCli: inject.service(), dependencyResolver: inject.service(), notify: inject.service(), @@ -24,9 +25,24 @@ export default Ember.Component.extend(AppBuilderMixin, ColumnsMixin, FilesMixin, isFastBoot: this.get('fastboot.isFastBoot') })); this.createColumns(); - this.set('activeEditorCol', '1'); + this.setProperties({ + activeEditorCol: '1', + keyboardActivated: true + }); }, + // eslint-disable-next-line ember/no-on-calls-in-components + onReloadCommand: on(keyDown('Enter+cmd'), function () { + this.send('runNow'); + }), + + // eslint-disable-next-line ember/no-on-calls-in-components + onSaveCommand: on(keyDown('cmd+KeyS'), function (event) { + this.saveGist(this.get('model')); + this.send('runNow'); + event.preventDefault(); + }), + /** * Output from the build, sets the `code` attr on the component * @type {String} diff --git a/app/routes/gist.js b/app/routes/gist.js index 5ca33dea..e1ed94ad 100644 --- a/app/routes/gist.js +++ b/app/routes/gist.js @@ -49,10 +49,12 @@ export default Ember.Route.extend({ actions: { saveGist(gist) { var newGist = gist.get('isNew'); + let controller = this.get('controller'); if (!newGist && gist.get('ownerLogin') !== this.get('session.currentUser.login')) { this.send('fork', gist); return; } + controller.set('isGistSaving', true); gist.save().then(() => { this.get('notify').info(`Saved to Gist ${gist.get('id')} on Github`); this.send('setSaved'); @@ -60,7 +62,8 @@ export default Ember.Route.extend({ gist.set('gistId', gist.get('id')); this.transitionTo('gist.edit', gist); } - }).catch((this.catchSaveError.bind(this))); + }).catch((this.catchSaveError.bind(this))) + .finally(() => controller.set('isGistSaving', false)); }, deleteGist(gist) { diff --git a/app/templates/components/gist-header.hbs b/app/templates/components/gist-header.hbs index 4c8f8586..450e21c4 100644 --- a/app/templates/components/gist-header.hbs +++ b/app/templates/components/gist-header.hbs @@ -2,7 +2,7 @@