Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

Commit

Permalink
🔥 remove content screen keyboard shortcuts
Browse files Browse the repository at this point in the history
closes TryGhost/Ghost#8662
- removes `k`, `j`, `up`, `down` shortcuts for changing the active post (these were already mostly unusable in 1.0) and the associated `enter` and `ctrl/cmd+backspace` commands for opening and triggering the delete modal respectively
- removes the `c` shortcut for opening the new post screen
  • Loading branch information
kevinansfield committed Jul 7, 2017
1 parent 9e61497 commit 016d3f8
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 91 deletions.
6 changes: 0 additions & 6 deletions app/controllers/posts.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ export default Controller.extend({
_hasLoadedTags: false,
_hasLoadedAuthors: false,

showDeletePostModal: false,

availableTypes: [{
name: 'All posts',
value: null
Expand Down Expand Up @@ -101,10 +99,6 @@ export default Controller.extend({
}),

actions: {
toggleDeletePostModal() {
this.toggleProperty('showDeletePostModal');
},

changeType(type) {
this.set('type', get(type, 'value'));
},
Expand Down
75 changes: 1 addition & 74 deletions app/routes/posts.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import $ from 'jquery';
import AuthenticatedRoute from 'ghost-admin/routes/authenticated';
import InfinityRoute from 'ember-infinity/mixins/route';
import ShortcutsRoute from 'ghost-admin/mixins/shortcuts-route';
import {assign} from 'ember-platform';
import {isBlank} from 'ember-utils';

export default AuthenticatedRoute.extend(InfinityRoute, ShortcutsRoute, {
export default AuthenticatedRoute.extend(InfinityRoute, {
titleToken: 'Content',

perPage: 30,
Expand All @@ -32,7 +31,6 @@ export default AuthenticatedRoute.extend(InfinityRoute, ShortcutsRoute, {
},

_type: null,
_selectedPostIndex: null,

model(params) {
return this.get('session.user').then((user) => {
Expand Down Expand Up @@ -121,50 +119,8 @@ export default AuthenticatedRoute.extend(InfinityRoute, ShortcutsRoute, {
});
},

stepThroughPosts(step) {
let currentPost = this.get('controller.selectedPost');
let posts = this.get('controller.model');
let length = posts.get('length');
let newPosition;

// when the currentPost is deleted we won't be able to use indexOf.
// we keep track of the index locally so we can select next after deletion
if (this._selectedPostIndex !== null && length) {
newPosition = this._selectedPostIndex + step;
} else {
newPosition = posts.indexOf(currentPost) + step;
}

// if we are on the first or last item
// just do nothing (desired behavior is to not
// loop around)
if (newPosition >= length) {
return;
} else if (newPosition < 0) {
return;
}

this._selectedPostIndex = newPosition;
this.set('controller.selectedPost', posts.objectAt(newPosition));
},

shortcuts: {
'up, k': 'moveUp',
'down, j': 'moveDown',
'enter': 'editPost',
'c': 'newPost',
'command+backspace, ctrl+backspace': 'deletePost'
},

resetController() {
this.set('controller.selectedPost', null);
this.set('controller.showDeletePostModal', false);
},

actions: {
willTransition() {
this._selectedPostIndex = null;

if (this.get('controller')) {
this.resetController();
}
Expand All @@ -175,35 +131,6 @@ export default AuthenticatedRoute.extend(InfinityRoute, ShortcutsRoute, {
$('.content-list').scrollTop(0);

this._super(...arguments);
},

newPost() {
this.transitionTo('editor.new');
},

moveUp() {
this.stepThroughPosts(-1);
},

moveDown() {
this.stepThroughPosts(1);
},

editPost() {
let selectedPost = this.get('controller.selectedPost');

if (selectedPost) {
this.transitionTo('editor.edit', selectedPost.get('id'));
}
},

deletePost() {
this.get('controller').send('toggleDeletePostModal');
},

onPostDeletion() {
// select next post (re-select the current index)
this.stepThroughPosts(0);
}
}
});
11 changes: 0 additions & 11 deletions app/templates/posts.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@
{{#each model as |post|}}
{{gh-posts-list-item
post=post
active=(eq post selectedPost)
onDoubleClick="openEditor"
data-test-post-id=post.id}}
{{else}}
Expand All @@ -110,15 +109,5 @@
triggerOffset=1000}}
</section>

{{#if showDeletePostModal}}
{{gh-fullscreen-modal "delete-post"
model=(hash
post=selectedPost
onSuccess=(route-action 'onPostDeletion')
)
close=(action "toggleDeletePostModal")
modifier="action wide"}}
{{/if}}

{{outlet}}
</section>

0 comments on commit 016d3f8

Please sign in to comment.