diff --git a/client/coral-admin/src/AppRouter.js b/client/coral-admin/src/AppRouter.js index bfb2e197c..af3423acc 100644 --- a/client/coral-admin/src/AppRouter.js +++ b/client/coral-admin/src/AppRouter.js @@ -42,6 +42,9 @@ const routes = ( + + + diff --git a/client/coral-admin/src/components/ActionButton.js b/client/coral-admin/src/components/ActionButton.js index 1fcafeac0..ae75b829e 100644 --- a/client/coral-admin/src/components/ActionButton.js +++ b/client/coral-admin/src/components/ActionButton.js @@ -6,6 +6,13 @@ import {menuActionsMap} from '../containers/ModerationQueue/helpers/moderationQu const ActionButton = ({type = '', status, ...props}) => { const typeName = type.toLowerCase(); const active = ((type === 'REJECT' && status === 'REJECTED') || (type === 'APPROVE' && status === 'ACCEPTED')); + let text = menuActionsMap[type].text; + + if (text === 'Approve' && active) { + text = 'Approved'; + } else if (text === 'Reject' && active) { + text = 'Rejected'; + } return ( + >{text} ); }; diff --git a/client/coral-admin/src/containers/ModerationQueue/ModerationContainer.js b/client/coral-admin/src/containers/ModerationQueue/ModerationContainer.js index dffa4de26..eb59f369e 100644 --- a/client/coral-admin/src/containers/ModerationQueue/ModerationContainer.js +++ b/client/coral-admin/src/containers/ModerationQueue/ModerationContainer.js @@ -138,6 +138,9 @@ class ModerationContainer extends Component { case 'all': activeTabCount = data.allCount; break; + case 'accepted': + activeTabCount = data.acceptedCount; + break; case 'premod': activeTabCount = data.premodCount; break; @@ -155,6 +158,7 @@ class ModerationContainer extends Component { { function getPath (type) { @@ -28,6 +28,12 @@ const ModerationMenu = ( activeClassName={styles.active}> {lang.t('modqueue.all')} + + {lang.t('modqueue.approved')} + { + const comment = oldData.all.find(c => c.id === commentId); + comment.status = 'ACCEPTED'; const premod = oldData.premod.filter(c => c.id !== commentId); const flagged = oldData.flagged.filter(c => c.id !== commentId); + const accepted = [comment].concat(oldData.accepted); const rejected = oldData.rejected.filter(c => c.id !== commentId); const premodCount = premod.length < oldData.premod.length ? oldData.premodCount - 1 : oldData.premodCount; const flaggedCount = flagged.length < oldData.flagged.length ? oldData.flaggedCount - 1 : oldData.flaggedCount; const rejectedCount = rejected.length < oldData.rejected.length ? oldData.rejectedCount - 1 : oldData.rejectedCount; + const acceptedCount = oldData.acceptedCount + 1; return { ...oldData, premodCount, flaggedCount, + acceptedCount, rejectedCount, premod, flagged, + accepted, rejected, }; } @@ -82,21 +88,26 @@ export const setCommentStatus = graphql(SET_COMMENT_STATUS, { }, updateQueries: { ModQueue: (oldData) => { - const comment = oldData.premod.concat(oldData.flagged).filter(c => c.id === commentId)[0]; + const comment = oldData.all.find(c => c.id === commentId); + comment.status = 'REJECTED'; const rejected = [comment].concat(oldData.rejected); const premod = oldData.premod.filter(c => c.id !== commentId); const flagged = oldData.flagged.filter(c => c.id !== commentId); + const accepted = oldData.accepted.filter(c => c.id !== commentId); const premodCount = premod.length < oldData.premod.length ? oldData.premodCount - 1 : oldData.premodCount; const flaggedCount = flagged.length < oldData.flagged.length ? oldData.flaggedCount - 1 : oldData.flaggedCount; const rejectedCount = oldData.rejectedCount + 1; + const acceptedCount = accepted.length < oldData.accepted.length ? oldData.acceptedCount - 1 : oldData.acceptedCount; return { ...oldData, premodCount, flaggedCount, + acceptedCount, rejectedCount, premod, flagged, + accepted, rejected }; } diff --git a/client/coral-admin/src/graphql/queries/modQueueQuery.graphql b/client/coral-admin/src/graphql/queries/modQueueQuery.graphql index f124b87b5..80dec5ff7 100644 --- a/client/coral-admin/src/graphql/queries/modQueueQuery.graphql +++ b/client/coral-admin/src/graphql/queries/modQueueQuery.graphql @@ -8,6 +8,13 @@ query ModQueue ($asset_id: ID, $sort: SORT_ORDER) { }) { ...commentView } + accepted: comments(query: { + statuses: [ACCEPTED], + asset_id: $asset_id, + sort: $sort + }) { + ...commentView + } premod: comments(query: { statuses: [PREMOD], asset_id: $asset_id, @@ -38,6 +45,10 @@ query ModQueue ($asset_id: ID, $sort: SORT_ORDER) { allCount: commentCount(query: { asset_id: $asset_id }) + acceptedCount: commentCount(query: { + statuses: [ACCEPTED], + asset_id: $asset_id + }) premodCount: commentCount(query: { statuses: [PREMOD], asset_id: $asset_id diff --git a/client/coral-admin/src/translations.json b/client/coral-admin/src/translations.json index b6ac46b01..6401f4990 100644 --- a/client/coral-admin/src/translations.json +++ b/client/coral-admin/src/translations.json @@ -36,6 +36,7 @@ "modqueue": { "likes": "likes", "all": "all", + "approved": "approved", "premod": "pre-mod", "rejected": "rejected", "flagged": "flagged", @@ -227,6 +228,8 @@ "loading": "Cargando resultados" }, "modqueue": { + "all": "todos", + "approved": "aprobado", "likes": "gustos", "premod": "pre-mod", "rejected": "rechazado",