From 521082eb3eef8725c74d84e684e6b3d1de216a6b Mon Sep 17 00:00:00 2001 From: riley Date: Fri, 28 Apr 2017 11:39:37 -0600 Subject: [PATCH 01/33] add new query for counts --- .../src/graphql/fragments/counts.graphql | 22 +++++++++++++++++++ .../graphql/queries/getQueueCounts.graphql | 5 +++++ .../coral-admin/src/graphql/queries/index.js | 12 ++++++++++ .../src/graphql/queries/modQueueQuery.graphql | 22 ++----------------- 4 files changed, 41 insertions(+), 20 deletions(-) create mode 100644 client/coral-admin/src/graphql/fragments/counts.graphql create mode 100644 client/coral-admin/src/graphql/queries/getQueueCounts.graphql diff --git a/client/coral-admin/src/graphql/fragments/counts.graphql b/client/coral-admin/src/graphql/fragments/counts.graphql new file mode 100644 index 000000000..eb00be4da --- /dev/null +++ b/client/coral-admin/src/graphql/fragments/counts.graphql @@ -0,0 +1,22 @@ +fragment counts on RootQuery { + 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 + }) + rejectedCount: commentCount(query: { + statuses: [REJECTED], + asset_id: $asset_id + }) + flaggedCount: commentCount(query: { + action_type: FLAG, + asset_id: $asset_id, + statuses: [NONE, PREMOD] + }) +} diff --git a/client/coral-admin/src/graphql/queries/getQueueCounts.graphql b/client/coral-admin/src/graphql/queries/getQueueCounts.graphql new file mode 100644 index 000000000..a527c2538 --- /dev/null +++ b/client/coral-admin/src/graphql/queries/getQueueCounts.graphql @@ -0,0 +1,5 @@ +#import "../fragments/counts.graphql" + +query Counts ($asset_id: ID) { + ...counts +} diff --git a/client/coral-admin/src/graphql/queries/index.js b/client/coral-admin/src/graphql/queries/index.js index 53113558b..09da07bc0 100644 --- a/client/coral-admin/src/graphql/queries/index.js +++ b/client/coral-admin/src/graphql/queries/index.js @@ -4,6 +4,7 @@ import MOD_QUEUE_QUERY from './modQueueQuery.graphql'; import MOD_QUEUE_LOAD_MORE from './loadMore.graphql'; import MOD_USER_FLAGGED_QUERY from './modUserFlaggedQuery.graphql'; import METRICS from './metricsQuery.graphql'; +import GET_QUEUE_COUNTS from './getQueueCounts.graphql'; export const modQueueQuery = graphql(MOD_QUEUE_QUERY, { options: ({params: {id = null}}) => { @@ -90,3 +91,14 @@ export const modQueueResort = (id, fetchMore) => (sort) => { updateQuery: (oldData, {fetchMoreResult:{data}}) => data }); }; + +export const getQueueCounts = graphql(GET_QUEUE_COUNTS, { + options: ({params: {id = null}}) => { + return { + pollInterval: 5000, + variables: { + asset_id: id + } + }; + } +}); diff --git a/client/coral-admin/src/graphql/queries/modQueueQuery.graphql b/client/coral-admin/src/graphql/queries/modQueueQuery.graphql index 80dec5ff7..9250ba793 100644 --- a/client/coral-admin/src/graphql/queries/modQueueQuery.graphql +++ b/client/coral-admin/src/graphql/queries/modQueueQuery.graphql @@ -1,4 +1,5 @@ #import "../fragments/commentView.graphql" +#import "../fragments/counts.graphql" query ModQueue ($asset_id: ID, $sort: SORT_ORDER) { all: comments(query: { @@ -42,24 +43,5 @@ query ModQueue ($asset_id: ID, $sort: SORT_ORDER) { title url } - 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 - }) - rejectedCount: commentCount(query: { - statuses: [REJECTED], - asset_id: $asset_id - }) - flaggedCount: commentCount(query: { - action_type: FLAG, - asset_id: $asset_id, - statuses: [NONE, PREMOD] - }) + ...counts } From 41d4bd10126653e17757c80d9d3ed95dcd7f5114 Mon Sep 17 00:00:00 2001 From: Riley Davis Date: Fri, 28 Apr 2017 11:52:07 -0600 Subject: [PATCH 02/33] counts update --- .../src/containers/ModerationQueue/ModerationContainer.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/client/coral-admin/src/containers/ModerationQueue/ModerationContainer.js b/client/coral-admin/src/containers/ModerationQueue/ModerationContainer.js index eb59f369e..7a3aab909 100644 --- a/client/coral-admin/src/containers/ModerationQueue/ModerationContainer.js +++ b/client/coral-admin/src/containers/ModerationQueue/ModerationContainer.js @@ -5,7 +5,7 @@ import key from 'keymaster'; import isEqual from 'lodash/isEqual'; import styles from './components/styles.css'; -import {modQueueQuery} from '../../graphql/queries'; +import {modQueueQuery, getQueueCounts} from '../../graphql/queries'; import {banUser, setCommentStatus} from '../../graphql/mutations'; import {fetchSettings} from 'actions/settings'; @@ -220,6 +220,7 @@ const mapDispatchToProps = dispatch => ({ export default compose( connect(mapStateToProps, mapDispatchToProps), setCommentStatus, + getQueueCounts, modQueueQuery, banUser )(ModerationContainer); From ef40174be9f32aa54ef0aa432f63f763edbb0571 Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Mon, 1 May 2017 10:55:50 -0300 Subject: [PATCH 03/33] Adding Coral-Plugin-Like --- plugins/coral-plugin-like/client/.babelrc | 14 ++ .../coral-plugin-like/client/.eslintrc.json | 23 +++ .../client/components/Icon.js | 6 + .../client/components/LikeButton.js | 69 ++++++++ .../client/components/style.css | 30 ++++ .../client/containers/LikeButton.js | 163 ++++++++++++++++++ plugins/coral-plugin-like/client/index.js | 7 + .../client/translations.json | 10 ++ plugins/coral-plugin-like/index.js | 36 ++++ .../coral-plugin-like/server/typeDefs.graphql | 54 ++++++ 10 files changed, 412 insertions(+) create mode 100644 plugins/coral-plugin-like/client/.babelrc create mode 100644 plugins/coral-plugin-like/client/.eslintrc.json create mode 100644 plugins/coral-plugin-like/client/components/Icon.js create mode 100644 plugins/coral-plugin-like/client/components/LikeButton.js create mode 100644 plugins/coral-plugin-like/client/components/style.css create mode 100644 plugins/coral-plugin-like/client/containers/LikeButton.js create mode 100644 plugins/coral-plugin-like/client/index.js create mode 100644 plugins/coral-plugin-like/client/translations.json create mode 100644 plugins/coral-plugin-like/index.js create mode 100644 plugins/coral-plugin-like/server/typeDefs.graphql diff --git a/plugins/coral-plugin-like/client/.babelrc b/plugins/coral-plugin-like/client/.babelrc new file mode 100644 index 000000000..60be246eb --- /dev/null +++ b/plugins/coral-plugin-like/client/.babelrc @@ -0,0 +1,14 @@ +{ + "presets": [ + "es2015" + ], + "plugins": [ + "add-module-exports", + "transform-class-properties", + "transform-decorators-legacy", + "transform-object-assign", + "transform-object-rest-spread", + "transform-async-to-generator", + "transform-react-jsx" + ] +} \ No newline at end of file diff --git a/plugins/coral-plugin-like/client/.eslintrc.json b/plugins/coral-plugin-like/client/.eslintrc.json new file mode 100644 index 000000000..9fe56bd14 --- /dev/null +++ b/plugins/coral-plugin-like/client/.eslintrc.json @@ -0,0 +1,23 @@ +{ + "env": { + "browser": true, + "es6": true, + "mocha": true + }, + "parserOptions": { + "sourceType": "module", + "ecmaFeatures": { + "experimentalObjectRestSpread": true, + "jsx": true + } + }, + "parser": "babel-eslint", + "plugins": [ + "react" + ], + "rules": { + "react/jsx-uses-react": "error", + "react/jsx-uses-vars": "error", + "no-console": ["warn", { "allow": ["warn", "error"] }] + } +} diff --git a/plugins/coral-plugin-like/client/components/Icon.js b/plugins/coral-plugin-like/client/components/Icon.js new file mode 100644 index 000000000..c24841e97 --- /dev/null +++ b/plugins/coral-plugin-like/client/components/Icon.js @@ -0,0 +1,6 @@ +import React from 'react'; +import cn from 'classnames'; + +export default ({className}) => ( +