From c0bb5e5cb20741d4ea211e455bf9baed8475bc9e Mon Sep 17 00:00:00 2001 From: Gerardo Galvez Date: Thu, 5 Oct 2017 16:57:46 -0500 Subject: [PATCH 1/2] Add moderator shortcuts to open search and switch between queues. --- .../src/components/ModerationKeysModal.js | 2 + .../Moderation/components/Moderation.js | 43 +++++++++++++++---- locales/en.yml | 2 + 3 files changed, 39 insertions(+), 8 deletions(-) diff --git a/client/coral-admin/src/components/ModerationKeysModal.js b/client/coral-admin/src/components/ModerationKeysModal.js index abdffa2b1..45304992c 100644 --- a/client/coral-admin/src/components/ModerationKeysModal.js +++ b/client/coral-admin/src/components/ModerationKeysModal.js @@ -10,6 +10,8 @@ const shortcuts = [ shortcuts: { 'j': 'modqueue.next_comment', 'k': 'modqueue.prev_comment', + 'ctrl+f': 'modqueue.toggle_search', + 't': 'modqueue.next_queue', 's': 'modqueue.singleview', '?': 'modqueue.thismenu' } diff --git a/client/coral-admin/src/routes/Moderation/components/Moderation.js b/client/coral-admin/src/routes/Moderation/components/Moderation.js index 668d013b0..cbee0330c 100644 --- a/client/coral-admin/src/routes/Moderation/components/Moderation.js +++ b/client/coral-admin/src/routes/Moderation/components/Moderation.js @@ -26,6 +26,8 @@ class Moderation extends Component { key('s', () => singleView()); key('shift+/', () => toggleModal(true)); key('esc', () => toggleModal(false)); + key('ctrl+f', () => this.openSearch()); + key('t', () => this.nextQueue()); key('j', () => this.select(true)); key('k', () => this.select(false)); key('f', () => this.moderate(false)); @@ -36,6 +38,26 @@ class Moderation extends Component { this.props.toggleModal(false); } + nextQueue = () => { + const queueConfig = this.props.queueConfig; + const activeTab = this.props.activeTab; + const assetId = this.props.data.variables.asset_id; + const menuItems = Object.keys(queueConfig).map((queue) => ({ + key: queue + })); + + let activeTabIndex, nextQueueIndex; + for (let i = 0; i < menuItems.length; i++) { + if (menuItems[i].key === activeTab){ + activeTabIndex = i; + break; + } + } + + nextQueueIndex = (activeTabIndex === menuItems.length - 1) ? 0 : activeTabIndex + 1; + this.props.router.push(this.props.getModPath(menuItems[nextQueueIndex].key, assetId)); + } + closeSearch = () => { const {toggleStorySearch} = this.props; toggleStorySearch(false); @@ -53,14 +75,17 @@ class Moderation extends Component { const {acceptComment, rejectComment} = this.props; const {selectedCommentId} = this.state; - const comments = this.getComments(); - const commentIdx = comments.findIndex((comment) => comment.id === selectedCommentId); - const comment = comments[commentIdx]; - - if (accept) { - comment.status !== 'ACCEPTED' && acceptComment({commentId: comment.id}); - } else { - comment.status !== 'REJECTED' && rejectComment({commentId: comment.id}); + // Accept or reject only if there's a selected comment + if(selectedCommentId != null){ + const comments = this.getComments(); + const commentIdx = comments.findIndex((comment) => comment.id === selectedCommentId); + const comment = comments[commentIdx]; + + if (accept) { + comment.status !== 'ACCEPTED' && acceptComment({commentId: comment.id}); + } else { + comment.status !== 'REJECTED' && rejectComment({commentId: comment.id}); + } } } @@ -147,6 +172,8 @@ class Moderation extends Component { key.unbind('s'); key.unbind('shift+/'); key.unbind('esc'); + key.unbind('ctrl+f'); + key.unbind('t'); key.unbind('j'); key.unbind('k'); key.unbind('f'); diff --git a/locales/en.yml b/locales/en.yml index a979739b5..1a934b695 100644 --- a/locales/en.yml +++ b/locales/en.yml @@ -275,6 +275,8 @@ en: newest_first: "Newest First" navigation: Navigation next_comment: "Go to the next comment" + toggle_search: "Open search" + next_queue: "Switch queues" oldest_first: "Oldest First" premod: pre-mod prev_comment: "Go to the previous comment" From cbd7337dbc51bbb38d502f103492598e1d8991c8 Mon Sep 17 00:00:00 2001 From: Gerardo Galvez Date: Fri, 6 Oct 2017 20:19:30 -0500 Subject: [PATCH 2/2] Add spanish translations and cleaner way to get the activeTabIndex --- .../src/routes/Moderation/components/Moderation.js | 11 +++-------- locales/es.yml | 2 ++ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/client/coral-admin/src/routes/Moderation/components/Moderation.js b/client/coral-admin/src/routes/Moderation/components/Moderation.js index cbee0330c..104da959b 100644 --- a/client/coral-admin/src/routes/Moderation/components/Moderation.js +++ b/client/coral-admin/src/routes/Moderation/components/Moderation.js @@ -42,19 +42,14 @@ class Moderation extends Component { const queueConfig = this.props.queueConfig; const activeTab = this.props.activeTab; const assetId = this.props.data.variables.asset_id; + const menuItems = Object.keys(queueConfig).map((queue) => ({ key: queue })); - let activeTabIndex, nextQueueIndex; - for (let i = 0; i < menuItems.length; i++) { - if (menuItems[i].key === activeTab){ - activeTabIndex = i; - break; - } - } + const activeTabIndex = menuItems.findIndex((item) => item.key === activeTab); + const nextQueueIndex = (activeTabIndex === menuItems.length - 1) ? 0 : activeTabIndex + 1; - nextQueueIndex = (activeTabIndex === menuItems.length - 1) ? 0 : activeTabIndex + 1; this.props.router.push(this.props.getModPath(menuItems[nextQueueIndex].key, assetId)); } diff --git a/locales/es.yml b/locales/es.yml index e9844667d..8b257b72e 100644 --- a/locales/es.yml +++ b/locales/es.yml @@ -267,6 +267,8 @@ es: newest_first: "Primero el más nuevo" navigation: Navegación next_comment: "Ir al siguiente comentario" + toggle_search: "Abrir búsqueda" + next_queue: "Próxima cola" oldest_first: "Primero el más antiguo" premod: pre-mod prev_comment: "Ir al comentario anterior"