From e73c113e0d8250dee304478dcf6544ab1929722c Mon Sep 17 00:00:00 2001 From: Jeff Nelson Date: Fri, 25 Aug 2017 08:30:29 -0400 Subject: [PATCH 001/106] use mailgun since postmark has been deprecated --- app.json | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app.json b/app.json index 5faa23bc2..a2e75404b 100644 --- a/app.json +++ b/app.json @@ -14,8 +14,7 @@ "required": true }, "NODE_ENV": "production", - "TALK_SMTP_PORT": "2525", - "REWRITE_ENV": "TALK_PORT:PORT,TALK_MONGO_URL:MONGO_URI,TALK_REDIS_URL:REDIS_URL,TALK_SMTP_HOST:POSTMARK_SMTP_SERVER,TALK_SMTP_USERNAME:POSTMARK_API_TOKEN,TALK_SMTP_PASSWORD:POSTMARK_API_TOKEN", + "REWRITE_ENV": "TALK_PORT:PORT,TALK_MONGO_URL:MONGO_URI,TALK_REDIS_URL:REDIS_URL,TALK_SMTP_HOST:MAILGUN_SMTP_SERVER,TALK_SMTP_PORT:MAILGUN_SMTP_PORT,TALK_SMTP_USERNAME:MAILGUN_SMTP_LOGIN,TALK_SMTP_PASSWORD:MAILGUN_SMTP_PASSWORD", "NPM_CONFIG_PRODUCTION": "false" }, "addons": [{ @@ -25,8 +24,8 @@ "plan": "rediscloud:30", "as": "REDIS" }, { - "plan": "postmark:10k", - "as": "POSTMARK" + "plan": "mailgun:starter", + "as": "MAILGUN" }], "image": "heroku/nodejs", "success_url": "/admin/install" From faecd80543171e533807cd6247c8a9cf86e96585 Mon Sep 17 00:00:00 2001 From: Jeff Nelson Date: Fri, 25 Aug 2017 08:51:36 -0400 Subject: [PATCH 002/106] better handling for heroku dynamic port --- config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.js b/config.js index 4472af26e..f86f41f30 100644 --- a/config.js +++ b/config.js @@ -80,7 +80,7 @@ const CONFIG = { //------------------------------------------------------------------------------ // Port to bind to. - PORT: process.env.TALK_PORT || '3000', + PORT: process.env.TALK_PORT || || process.env.PORT || '3000', // The URL for this Talk Instance as viewable from the outside. ROOT_URL: process.env.TALK_ROOT_URL || null, From 4b7cc9ffcce37d8dbaee01df996047b05ee9e939 Mon Sep 17 00:00:00 2001 From: Jeff Nelson Date: Fri, 25 Aug 2017 08:55:26 -0400 Subject: [PATCH 003/106] whoops --- app.json | 2 +- config.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app.json b/app.json index a2e75404b..2316d1d1a 100644 --- a/app.json +++ b/app.json @@ -14,7 +14,7 @@ "required": true }, "NODE_ENV": "production", - "REWRITE_ENV": "TALK_PORT:PORT,TALK_MONGO_URL:MONGO_URI,TALK_REDIS_URL:REDIS_URL,TALK_SMTP_HOST:MAILGUN_SMTP_SERVER,TALK_SMTP_PORT:MAILGUN_SMTP_PORT,TALK_SMTP_USERNAME:MAILGUN_SMTP_LOGIN,TALK_SMTP_PASSWORD:MAILGUN_SMTP_PASSWORD", + "REWRITE_ENV": "TALK_MONGO_URL:MONGO_URI,TALK_REDIS_URL:REDIS_URL,TALK_SMTP_HOST:MAILGUN_SMTP_SERVER,TALK_SMTP_PORT:MAILGUN_SMTP_PORT,TALK_SMTP_USERNAME:MAILGUN_SMTP_LOGIN,TALK_SMTP_PASSWORD:MAILGUN_SMTP_PASSWORD", "NPM_CONFIG_PRODUCTION": "false" }, "addons": [{ diff --git a/config.js b/config.js index f86f41f30..faa911c83 100644 --- a/config.js +++ b/config.js @@ -80,7 +80,7 @@ const CONFIG = { //------------------------------------------------------------------------------ // Port to bind to. - PORT: process.env.TALK_PORT || || process.env.PORT || '3000', + PORT: process.env.TALK_PORT || process.env.PORT || '3000', // The URL for this Talk Instance as viewable from the outside. ROOT_URL: process.env.TALK_ROOT_URL || null, From 2f3d7c5329802af6d4d2c53eea2711eaf7645ed7 Mon Sep 17 00:00:00 2001 From: Jeff Nelson Date: Fri, 25 Aug 2017 09:17:51 -0400 Subject: [PATCH 004/106] set default root url --- app.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app.json b/app.json index 2316d1d1a..3c17023c4 100644 --- a/app.json +++ b/app.json @@ -13,6 +13,10 @@ "value": "", "required": true }, + "TALK_ROOT_URL": { + "value": "http://0.0.0.0", + "required": true + }, "NODE_ENV": "production", "REWRITE_ENV": "TALK_MONGO_URL:MONGO_URI,TALK_REDIS_URL:REDIS_URL,TALK_SMTP_HOST:MAILGUN_SMTP_SERVER,TALK_SMTP_PORT:MAILGUN_SMTP_PORT,TALK_SMTP_USERNAME:MAILGUN_SMTP_LOGIN,TALK_SMTP_PASSWORD:MAILGUN_SMTP_PASSWORD", "NPM_CONFIG_PRODUCTION": "false" From 28dafd3e07f73ed4029b6d20bca91d428cd2c9d8 Mon Sep 17 00:00:00 2001 From: Jeff Nelson Date: Fri, 25 Aug 2017 09:27:52 -0400 Subject: [PATCH 005/106] update --- app.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app.json b/app.json index 3c17023c4..aefe25861 100644 --- a/app.json +++ b/app.json @@ -1,7 +1,7 @@ { "name": "The Coral Project: Talk", "env": { - "TALK_SESSION_SECRET": { + "TALK_JWT_SECRET": { "description": "The session secret", "generator": "secret" }, From 50caddee56d7d9c47368582c1a502add7aad9c27 Mon Sep 17 00:00:00 2001 From: Jeff Nelson Date: Fri, 25 Aug 2017 09:47:40 -0400 Subject: [PATCH 006/106] update --- app.json | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app.json b/app.json index aefe25861..b0db1dcde 100644 --- a/app.json +++ b/app.json @@ -5,6 +5,11 @@ "description": "The session secret", "generator": "secret" }, + "TALK_ROOT_URL": { + "description": "Please copy the App Name you choose above. If you did not choose one, please do so now and copy it here. Talk on Heroku will not work without this setting.", + "value":"https://.herokuapp.com", + "required": true + }, "TALK_FACEBOOK_APP_ID": { "value": "", "required": true @@ -13,10 +18,6 @@ "value": "", "required": true }, - "TALK_ROOT_URL": { - "value": "http://0.0.0.0", - "required": true - }, "NODE_ENV": "production", "REWRITE_ENV": "TALK_MONGO_URL:MONGO_URI,TALK_REDIS_URL:REDIS_URL,TALK_SMTP_HOST:MAILGUN_SMTP_SERVER,TALK_SMTP_PORT:MAILGUN_SMTP_PORT,TALK_SMTP_USERNAME:MAILGUN_SMTP_LOGIN,TALK_SMTP_PASSWORD:MAILGUN_SMTP_PASSWORD", "NPM_CONFIG_PRODUCTION": "false" From cc66f1b45953c3bff17dd7de5e1d3f9117206cc4 Mon Sep 17 00:00:00 2001 From: Jeff Nelson Date: Fri, 25 Aug 2017 09:47:59 -0400 Subject: [PATCH 007/106] update --- app.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app.json b/app.json index b0db1dcde..6c85e3cc2 100644 --- a/app.json +++ b/app.json @@ -7,7 +7,7 @@ }, "TALK_ROOT_URL": { "description": "Please copy the App Name you choose above. If you did not choose one, please do so now and copy it here. Talk on Heroku will not work without this setting.", - "value":"https://.herokuapp.com", + "value":"https://.herokuapp.com", "required": true }, "TALK_FACEBOOK_APP_ID": { From 091d787e349ae32002b6d2d3d9dbc0a838c57019 Mon Sep 17 00:00:00 2001 From: Jeff Nelson Date: Fri, 25 Aug 2017 10:02:16 -0400 Subject: [PATCH 008/106] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index a58ac7c74..d1bcf2956 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # Talk [![CircleCI](https://circleci.com/gh/coralproject/talk.svg?style=svg)](https://circleci.com/gh/coralproject/talk) +[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/coralproject/talk/tree/feature/heroku-deploy&env[TALK_FACEBOOK_APP_ID]=ignore&env[TALK_FACEBOOK_APP_SECRET]=ignore) Online comments are broken. Our open-source Talk tool rethinks how moderation, comment display, and conversation function, creating the opportunity for safer, smarter discussions around your work. [Read more about Talk here.](https://coralproject.net/products/talk.html) From fe0c32898d2de2814213845ac30d82d566c65a26 Mon Sep 17 00:00:00 2001 From: Jeff Nelson Date: Fri, 25 Aug 2017 10:03:46 -0400 Subject: [PATCH 009/106] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d1bcf2956..4b12315e4 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Talk [![CircleCI](https://circleci.com/gh/coralproject/talk.svg?style=svg)](https://circleci.com/gh/coralproject/talk) -[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/coralproject/talk/tree/feature/heroku-deploy&env[TALK_FACEBOOK_APP_ID]=ignore&env[TALK_FACEBOOK_APP_SECRET]=ignore) +[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://dashboard.heroku.com/new?template=https%3A%2F%2Fgithub.com%2Fcoralproject%2Ftalk%2Ftree%2Ffeature%2Fheroku-deploy&env[TALK_FACEBOOK_APP_ID]=ignore&env[TALK_FACEBOOK_APP_SECRET]=ignore) Online comments are broken. Our open-source Talk tool rethinks how moderation, comment display, and conversation function, creating the opportunity for safer, smarter discussions around your work. [Read more about Talk here.](https://coralproject.net/products/talk.html) From 7c9e2297dffea8c8f159a18048e054abf363219b Mon Sep 17 00:00:00 2001 From: Jeff Nelson Date: Mon, 28 Aug 2017 09:54:20 -0400 Subject: [PATCH 010/106] don't hardcode branch --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4b12315e4..4bec86d07 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Talk [![CircleCI](https://circleci.com/gh/coralproject/talk.svg?style=svg)](https://circleci.com/gh/coralproject/talk) -[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://dashboard.heroku.com/new?template=https%3A%2F%2Fgithub.com%2Fcoralproject%2Ftalk%2Ftree%2Ffeature%2Fheroku-deploy&env[TALK_FACEBOOK_APP_ID]=ignore&env[TALK_FACEBOOK_APP_SECRET]=ignore) +[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://dashboard.heroku.com/new?template=https%3A%2F%2Fgithub.com%2Fcoralproject%2Ftalk&env[TALK_FACEBOOK_APP_ID]=ignore&env[TALK_FACEBOOK_APP_SECRET]=ignore) Online comments are broken. Our open-source Talk tool rethinks how moderation, comment display, and conversation function, creating the opportunity for safer, smarter discussions around your work. [Read more about Talk here.](https://coralproject.net/products/talk.html) @@ -20,7 +20,7 @@ endpoint when the server is running with built assets. - Blog: https://blog.coralproject.net -- Community Guides for Journalism: https://guides.coralproject.net/ +- Community Guides for Journalism: https://guides.coralproject.net/ ## License From 12d66a49d049b0f8b2b47be3a299620a9aae3b6f Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Mon, 28 Aug 2017 12:17:01 -0300 Subject: [PATCH 011/106] Adding commentAuthorTags --- client/coral-embed-stream/src/components/Comment.js | 8 ++++++++ client/coral-embed-stream/src/containers/Comment.js | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/client/coral-embed-stream/src/components/Comment.js b/client/coral-embed-stream/src/components/Comment.js index 79dfb1b34..3eecc80ea 100644 --- a/client/coral-embed-stream/src/components/Comment.js +++ b/client/coral-embed-stream/src/components/Comment.js @@ -447,6 +447,14 @@ export default class Comment extends React.Component { {isStaff(comment.tags) ? Staff : null} + + { diff --git a/client/coral-embed-stream/src/containers/Comment.js b/client/coral-embed-stream/src/containers/Comment.js index e34218883..f955066aa 100644 --- a/client/coral-embed-stream/src/containers/Comment.js +++ b/client/coral-embed-stream/src/containers/Comment.js @@ -16,7 +16,8 @@ const slots = [ 'commentContent', 'commentReactions', 'commentAvatar', - 'commentAuthorName' + 'commentAuthorName', + 'commentAuthorTags' ]; /** From 93c1ecd12d88dbd3da3af863f8398e860497e6bf Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Mon, 28 Aug 2017 16:25:26 -0300 Subject: [PATCH 012/106] My Comment Reactions --- client/coral-framework/utils/index.js | 8 +++++++ .../containers/ProfileContainer.js | 5 ++++ client/talk-plugin-history/Comment.css | 11 +++++++-- client/talk-plugin-history/Comment.js | 24 ++++++++++++++----- 4 files changed, 40 insertions(+), 8 deletions(-) diff --git a/client/coral-framework/utils/index.js b/client/coral-framework/utils/index.js index 533ed85db..df264d360 100644 --- a/client/coral-framework/utils/index.js +++ b/client/coral-framework/utils/index.js @@ -184,3 +184,11 @@ export function getShallowChanges(a, b) { return union(Object.keys(a), Object.keys(b)) .filter((key) => a[key] !== b[key]); } + +export function getTotalReactionsCount(actionSummaries) { + return actionSummaries + .filter((s) => s.__typename !== 'FlagActionSummary') + .reduce((total, summary) => { + return total + summary.count; + }, 0); +} diff --git a/client/coral-settings/containers/ProfileContainer.js b/client/coral-settings/containers/ProfileContainer.js index f5ea64005..907839a92 100644 --- a/client/coral-settings/containers/ProfileContainer.js +++ b/client/coral-settings/containers/ProfileContainer.js @@ -108,6 +108,11 @@ const CommentFragment = gql` nodes { id body + replyCount + action_summaries { + count + __typename + } asset { id title diff --git a/client/talk-plugin-history/Comment.css b/client/talk-plugin-history/Comment.css index 646e1f054..ba63aaeb1 100644 --- a/client/talk-plugin-history/Comment.css +++ b/client/talk-plugin-history/Comment.css @@ -6,6 +6,7 @@ display: flex; align-items: baseline; justify-content: space-between; + padding-bottom: 20px; } .myComment:last-child { @@ -16,11 +17,17 @@ text-decoration: none; font-weight: bold; font-size: 12px; - color: #2c3e50; + color: #757575; } -.commentBody { +.commentSummary { + font-size: 14px; + margin: 30px 0 10px; + color: #424242; +} +.commentSummaryReactions { + margin-right: 5px; } .sidebar { diff --git a/client/talk-plugin-history/Comment.js b/client/talk-plugin-history/Comment.js index 4cf9d875c..f3bb47914 100644 --- a/client/talk-plugin-history/Comment.js +++ b/client/talk-plugin-history/Comment.js @@ -4,6 +4,8 @@ import styles from './Comment.css'; import Slot from 'coral-framework/components/Slot'; import PubDate from '../talk-plugin-pubdate/PubDate'; import CommentContent from '../coral-embed-stream/src/components/CommentContent'; +import cn from 'classnames'; +import {getTotalReactionsCount} from 'coral-framework/utils'; import t from 'coral-framework/services/i18n'; @@ -11,24 +13,34 @@ class Comment extends React.Component { render() { const {comment, link, data, root} = this.props; + // console.log(comment.action_summaries, getTotalReactionsCount(comment.action_summaries)); + return (
    @@ -38,7 +50,7 @@ class Comment extends React.Component {
  • - + Date: Mon, 28 Aug 2017 16:30:17 -0300 Subject: [PATCH 013/106] Translations added --- client/talk-plugin-history/Comment.js | 8 +++----- locales/en.yml | 3 +++ locales/es.yml | 3 +++ 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/client/talk-plugin-history/Comment.js b/client/talk-plugin-history/Comment.js index f3bb47914..c9851b43c 100644 --- a/client/talk-plugin-history/Comment.js +++ b/client/talk-plugin-history/Comment.js @@ -13,7 +13,6 @@ class Comment extends React.Component { render() { const {comment, link, data, root} = this.props; - // console.log(comment.action_summaries, getTotalReactionsCount(comment.action_summaries)); return (
    @@ -27,18 +26,17 @@ class Comment extends React.Component { />
    - {getTotalReactionsCount(comment.action_summaries)} reactions + {getTotalReactionsCount(comment.action_summaries)} {t('common.reactions')} - - {comment.replyCount} replies + {comment.replyCount} {t('common.replies')}
    diff --git a/locales/en.yml b/locales/en.yml index 2ec0c816c..da7bd54d1 100644 --- a/locales/en.yml +++ b/locales/en.yml @@ -41,6 +41,9 @@ en: common: copy: 'Copy' error: 'An error has occurred.' + replies: 'replies' + reactions: 'reactions' + story: 'Story' community: account_creation_date: "Account Creation Date" active: Active diff --git a/locales/es.yml b/locales/es.yml index 877a42841..8c3683021 100644 --- a/locales/es.yml +++ b/locales/es.yml @@ -41,6 +41,9 @@ es: common: copy: 'Copiar' error: 'Ha ocurrido un error.' + replies: 'respuestas' + reactions: 'reacciones' + story: 'Artículo' community: account_creation_date: "Fecha de creación de la cuenta" active: Activa From e77bdf0b900853d329fa9e31a7a4073413ef1b45 Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Mon, 28 Aug 2017 16:31:46 -0300 Subject: [PATCH 014/106] linting --- client/coral-settings/containers/ProfileContainer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/coral-settings/containers/ProfileContainer.js b/client/coral-settings/containers/ProfileContainer.js index 907839a92..571952639 100644 --- a/client/coral-settings/containers/ProfileContainer.js +++ b/client/coral-settings/containers/ProfileContainer.js @@ -109,7 +109,7 @@ const CommentFragment = gql` id body replyCount - action_summaries { + action_summaries { count __typename } From eb586f217b11f741402fca085b54f58f688ad165 Mon Sep 17 00:00:00 2001 From: Wyatt Johnson Date: Mon, 28 Aug 2017 14:06:54 -0600 Subject: [PATCH 015/106] Upgraded/pruned deps, applied linting fixes --- .eslintrc.json | 61 +- bin/cli-jobs | 21 +- bin/cli-plugins | 2 +- bin/cli-users | 83 +- bin/verifications/database/comments.js | 2 +- client/.eslintrc.json | 1 + client/coral-admin/src/actions/community.js | 12 +- client/coral-admin/src/actions/install.js | 20 +- .../coral-admin/src/components/AdminLogin.js | 28 +- .../src/components/SuspendUserDialog.js | 4 +- .../coral-admin/src/components/UserDetail.js | 48 +- .../src/components/UserDetailComment.js | 12 +- .../coral-admin/src/components/ui/Header.js | 60 +- client/coral-admin/src/containers/Layout.js | 8 +- .../coral-admin/src/containers/UserDetail.js | 14 +- .../Community/components/FlaggedAccounts.js | 28 +- .../src/routes/Community/components/People.js | 4 +- .../components/RejectUsernameDialog.js | 56 +- .../src/routes/Community/components/Table.js | 6 +- .../src/routes/Community/components/User.js | 2 +- .../routes/Community/containers/Community.js | 16 +- .../routes/Configure/components/Configure.js | 48 +- .../Configure/components/StreamSettings.js | 8 +- .../Dashboard/components/ActivityWidget.js | 26 +- .../routes/Dashboard/components/FlagWidget.js | 34 +- .../routes/Dashboard/components/LikeWidget.js | 28 +- .../routes/Dashboard/containers/Dashboard.js | 18 +- .../components/Steps/CreateYourAccount.js | 14 +- .../routes/Moderation/components/Comment.js | 12 +- .../Moderation/components/ModerationQueue.js | 4 +- .../Moderation/components/StorySearch.js | 26 +- .../Moderation/containers/StorySearch.js | 16 +- .../src/routes/Stories/components/Stories.js | 26 +- .../components/ConfigureCommentStream.js | 14 +- .../components/QuestionBoxBuilder.js | 48 +- .../containers/ConfigureStreamContainer.js | 2 +- .../src/components/AllCommentsPane.js | 52 +- .../src/components/Comment.js | 54 +- .../src/components/EditableCommentContent.js | 8 +- .../src/components/NewCount.js | 12 +- .../src/components/Stream.js | 26 +- .../src/components/SuspendedAccount.js | 54 +- .../src/components/TopRightMenu.js | 2 +- .../coral-embed-stream/src/graphql/utils.js | 4 +- client/coral-framework/helpers/validate.js | 2 +- client/coral-framework/hocs/withMutation.js | 44 +- client/coral-framework/hocs/withQuery.js | 28 +- client/coral-framework/services/plugins.js | 12 +- client/coral-framework/utils/index.js | 2 +- client/coral-framework/utils/user.js | 2 +- .../coral-settings/components/IgnoredUsers.js | 2 +- .../containers/ProfileContainer.js | 12 +- client/coral-ui/components/CoralLogo.js | 52 +- client/coral-ui/components/Dialog.js | 2 +- client/coral-ui/components/Pager.js | 14 +- client/coral-ui/components/Wizard.js | 12 +- .../components/FlagButton.js | 44 +- .../components/FlagComment.js | 26 +- client/talk-plugin-infobox/InfoBox.js | 8 +- .../talk-plugin-moderation/ModerationLink.js | 12 +- graph/loaders/comments.js | 8 +- graph/loaders/metrics.js | 16 +- graph/loaders/users.js | 2 +- graph/mutators/comment.js | 2 +- graph/mutators/tag.js | 2 +- graph/mutators/user.js | 6 +- package.json | 49 +- plugin-api/beta/client/hocs/withTags.js | 28 +- plugin-api/beta/server/getReactionConfig.js | 67 +- .../client/components/ForgotContent.js | 8 +- .../client/components/SignInButton.js | 4 +- .../client/components/SignInContainer.js | 3 + .../client/components/SignInContent.js | 104 +- .../client/components/ModTag.js | 8 +- .../client/components/Tag.js | 20 +- .../client/components/PermalinkButton.js | 2 +- routes/api/users/index.js | 12 +- routes/assets/index.js | 49 +- services/cache.js | 110 +- services/mailer.js | 20 +- services/metadata.js | 2 +- services/passport.js | 39 +- services/scraper.js | 46 +- services/users.js | 18 +- services/wordlist.js | 51 +- test/helpers/mongoose.js | 12 +- test/server/graph/context.js | 12 +- test/server/graph/mutations/createComment.js | 32 +- test/server/routes/api/account/index.js | 12 +- test/server/routes/api/auth/index.js | 23 +- test/server/routes/api/user/index.js | 18 +- test/server/services/users.js | 149 +- yarn.lock | 1235 +++++++++-------- 93 files changed, 1758 insertions(+), 1709 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 12355ac34..237650932 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -7,51 +7,53 @@ "parserOptions": { "ecmaVersion": 2017 }, + "plugins": [ + "promise", + "json" + ], "rules": { "indent": ["error", 2 ], - "no-console": [ - 0 - ], + "no-console": "off", "linebreak-style": ["error", "unix"], "quotes": ["error", "single"], "semi": ["error", "always"], - "no-template-curly-in-string": [1], - "no-unsafe-negation": [1], - "array-callback-return": [1], + "no-template-curly-in-string": "warn", + "no-unsafe-negation": "warn", + "array-callback-return": "warn", "arrow-parens": ["warn", "always"], "template-curly-spacing": "warn", - "eqeqeq": [2, "smart"], - "no-eval": [2], - "no-global-assign": [2], - "no-implied-eval": [2], + "eqeqeq": ["error", "smart"], + "no-eval": "error", + "no-global-assign": "error", + "no-implied-eval": "error", "lines-around-comment": ["warn", {"beforeLineComment": true}], "spaced-comment": ["warn", "always", { "line": { "exceptions": ["-", "="] } }], - "no-script-url": [2], - "no-throw-literal": [2], - "yoda": [1], - "no-path-concat": [2], - "eol-last": [1], - "no-nested-ternary": [1], - "no-tabs": [2], - "no-unneeded-ternary": [1], - "object-curly-spacing": [1], + "no-script-url": "error", + "no-throw-literal": "error", + "yoda": "warn", + "no-path-concat": "error", + "eol-last": "warn", + "no-nested-ternary": "warn", + "no-tabs": "error", + "no-unneeded-ternary": "warn", + "object-curly-spacing": "warn", "space-infix-ops": ["error"], "space-in-parens": ["error", "never"], "space-unary-ops": ["error", { "words": true, "nonwords": false }], - "no-const-assign": [2], - "no-duplicate-imports": [2], - "prefer-template": [1], + "no-const-assign": "error", + "no-duplicate-imports": "error", + "prefer-template": "warn", "comma-spacing": ["error", { "after": true }], - "no-var": [2], - "no-lonely-if": [2], - "curly": [2], + "no-var": "error", + "no-lonely-if": "error", + "curly": "error", "no-unused-vars": ["error", { "argsIgnorePattern": "^_|next", "varsIgnorePattern": "^_" @@ -61,6 +63,13 @@ }], "newline-per-chained-call": ["error", { "ignoreChainWithDepth": 2 - }] + }], + "promise/no-return-wrap": "error", + "promise/param-names": "error", + "promise/catch-or-return": "error", + "promise/no-native": "off", + "promise/no-nesting": "warn", + "promise/no-promise-in-callback": "warn", + "promise/no-callback-in-promise": "warn" } } diff --git a/bin/cli-jobs b/bin/cli-jobs index f22e1068b..c5aefc518 100755 --- a/bin/cli-jobs +++ b/bin/cli-jobs @@ -78,18 +78,23 @@ function rangeJobsByState(state = 'complete', limit) { /** * Cleans up the jobs that are in the queue. */ -function cleanupJobs(options) { +async function cleanupJobs(options) { const n = 100; - Promise.all([ - rangeJobsByState('complete', n), - options.stuck ? rangeJobsByState('failed', n) : false - ]) - .then((joblists) => joblists.filter((jobs) => jobs).map(removeJobs)) - .then(() => { + try { + const joblists = await Promise.all([ + rangeJobsByState('complete', n), + options.stuck ? rangeJobsByState('failed', n) : false + ]); + + await joblists.filter((jobs) => jobs).map(removeJobs); + util.shutdown(); console.log('Removed old jobs'); - }); + } catch (err) { + console.error(err); + util.shutdown(1); + } } //============================================================================== diff --git a/bin/cli-plugins b/bin/cli-plugins index 1de1c97d4..b7e301fce 100755 --- a/bin/cli-plugins +++ b/bin/cli-plugins @@ -53,7 +53,7 @@ function versionMatch(name, version) { } } -const EXTERNAL = /^\w[a-z\-0-9\.]+$/; // Match "react", "path", "fs", "lodash.random", etc. +const EXTERNAL = /^\w[a-z\-0-9.]+$/; // Match "react", "path", "fs", "lodash.random", etc. function reconcilePackages({quiet = false, upgradeRemote = false}) { const fetchable = []; diff --git a/bin/cli-users b/bin/cli-users index 057c0a806..c6555ab28 100755 --- a/bin/cli-users +++ b/bin/cli-users @@ -98,39 +98,32 @@ function getUserCreateAnswers(options) { /** * Prompts for input and registers a user based on those. */ -function createUser(options) { - getUserCreateAnswers(options) - .then((answers) => { - if (answers.password !== answers.confirmPassword) { - return Promise.reject(new Error('Passwords do not match')); - } +async function createUser(options) { + try { + const answers = await getUserCreateAnswers(options); + if (answers.password !== answers.confirmPassword) { + throw new Error('Passwords do not match'); + } - return answers; - }) - .then((answers) => { - return UsersService - .createLocalUser(answers.email.trim(), answers.password.trim(), answers.username.trim()) - .then((user) => { - console.log(`Created user ${user.id}.`); + const user = await UsersService.createLocalUser(answers.email.trim(), answers.password.trim(), answers.username.trim()); + console.log(`Created user ${user.id}.`); - if (answers.roles.length > 0) { - return Promise.all(answers.roles.map((role) => { - return UsersService - .addRoleToUser(user.id, role) - .then(() => { - console.log(`Added the role ${role} to User ${user.id}.`); - }); - })); - } - }); - }) - .then(() => { - util.shutdown(); - }) - .catch((err) => { - console.error(err); - util.shutdown(); - }); + if (answers.roles.length > 0) { + return Promise.all(answers.roles.map((role) => { + return UsersService + .addRoleToUser(user.id, role) + .then(() => { + console.log(`Added the role ${role} to User ${user.id}.`); + }); + })); + } + + util.shutdown(); + + } catch (err) { + console.error(err); + util.shutdown(); + } } /** @@ -169,21 +162,21 @@ function passwd(userID) { validate: validateRequired('Confirm Password is required') } ]) - .then((answers) => { - if (answers.password !== answers.confirmPassword) { - return Promise.reject(new Error('Password mismatch')); - } + .then((answers) => { + if (answers.password !== answers.confirmPassword) { + throw new Error('Password mismatch'); + } - return UsersService.changePassword(userID, answers.password); - }) - .then(() => { - console.log('Password changed.'); - util.shutdown(); - }) - .catch((err) => { - console.error(err); - util.shutdown(1); - }); + return UsersService.changePassword(userID, answers.password); + }) + .then(() => { + console.log('Password changed.'); + util.shutdown(); + }) + .catch((err) => { + console.error(err); + util.shutdown(1); + }); } /** diff --git a/bin/verifications/database/comments.js b/bin/verifications/database/comments.js index f7dd4d397..231badabb 100644 --- a/bin/verifications/database/comments.js +++ b/bin/verifications/database/comments.js @@ -125,7 +125,7 @@ module.exports = async ({fix, limit, batch}) => { // Check that the action summaries match the cached counts. if (!comment.action_counts || !(ACTION_COUNT_FIELD in comment.action_counts) || comment.action_counts[ACTION_COUNT_FIELD] !== count) { - // Batch updates for those changes. + // Batch updates for those changes. commentOperations.push({ [`action_counts.${ACTION_COUNT_FIELD}`]: count, }); diff --git a/client/.eslintrc.json b/client/.eslintrc.json index 5735a91a1..cde3942fa 100644 --- a/client/.eslintrc.json +++ b/client/.eslintrc.json @@ -4,6 +4,7 @@ "es6": true, "mocha": true }, + "extends": "../.eslintrc.json", "parserOptions": { "sourceType": "module", "ecmaFeatures": { diff --git a/client/coral-admin/src/actions/community.js b/client/coral-admin/src/actions/community.js index 402a32e5d..890d834b4 100644 --- a/client/coral-admin/src/actions/community.js +++ b/client/coral-admin/src/actions/community.js @@ -52,16 +52,16 @@ export const newPage = () => ({ export const setRole = (id, role) => (dispatch, _, {rest}) => { return rest(`/users/${id}/role`, {method: 'POST', body: {role}}) - .then(() => { - return dispatch({type: SET_ROLE, id, role}); - }); + .then(() => { + return dispatch({type: SET_ROLE, id, role}); + }); }; export const setCommenterStatus = (id, status) => (dispatch, _, {rest}) => { return rest(`/users/${id}/status`, {method: 'POST', body: {status}}) - .then(() => { - return dispatch({type: SET_COMMENTER_STATUS, id, status}); - }); + .then(() => { + return dispatch({type: SET_COMMENTER_STATUS, id, status}); + }); }; // Ban User Dialog diff --git a/client/coral-admin/src/actions/install.js b/client/coral-admin/src/actions/install.js index d7210782a..d6b27115a 100644 --- a/client/coral-admin/src/actions/install.js +++ b/client/coral-admin/src/actions/install.js @@ -26,19 +26,19 @@ const validation = (formData, dispatch, next) => { // Required Validation const empty = validKeys - .filter((name) => { - const cond = !formData[name].length; + .filter((name) => { + const cond = !formData[name].length; - if (cond) { + if (cond) { - // Adding Error - dispatch(addError(name, 'This field is required.')); - } else { - dispatch(addError(name, '')); - } + // Adding Error + dispatch(addError(name, 'This field is required.')); + } else { + dispatch(addError(name, '')); + } - return cond; - }); + return cond; + }); if (empty.length) { dispatch(hasError()); diff --git a/client/coral-admin/src/components/AdminLogin.js b/client/coral-admin/src/components/AdminLogin.js index e75e66d23..014773a1b 100644 --- a/client/coral-admin/src/components/AdminLogin.js +++ b/client/coral-admin/src/components/AdminLogin.js @@ -69,23 +69,23 @@ class AdminLogin extends React.Component { ); const requestPasswordForm = ( this.props.passwordRequestSuccess - ?

    { - location.href = location.href; - }}> + ?

    { + location.href = location.href; + }}> {this.props.passwordRequestSuccess} Sign in

    - :
    - this.setState({email: e.target.value})} /> - - + :
    + this.setState({email: e.target.value})} /> + + ); return ( diff --git a/client/coral-admin/src/components/SuspendUserDialog.js b/client/coral-admin/src/components/SuspendUserDialog.js index d2ef23891..0ed947506 100644 --- a/client/coral-admin/src/components/SuspendUserDialog.js +++ b/client/coral-admin/src/components/SuspendUserDialog.js @@ -65,7 +65,7 @@ class SuspendUserDialog extends React.Component { {t('suspenduser.title_suspend')}

    - {t('suspenduser.description_suspend', username)} + {t('suspenduser.description_suspend', username)}

    {t('suspenduser.select_duration')} @@ -103,7 +103,7 @@ class SuspendUserDialog extends React.Component { {t('suspenduser.title_notify')}

    - {t('suspenduser.description_notify', username)} + {t('suspenduser.description_notify', username)}

    {t('suspenduser.write_message')} diff --git a/client/coral-admin/src/components/UserDetail.js b/client/coral-admin/src/components/UserDetail.js index 11cd444e1..a7eadbac3 100644 --- a/client/coral-admin/src/components/UserDetail.js +++ b/client/coral-admin/src/components/UserDetail.js @@ -139,29 +139,29 @@ export default class UserDetail extends React.Component {
    { selectedCommentIds.length === 0 - ? ( -
      -
    • All
    • -
    • Rejected
    • -
    - ) - : ( -
    - - - {`${selectedCommentIds.length} comments selected`} -
    - ) + ? ( +
      +
    • All
    • +
    • Rejected
    • +
    + ) + : ( +
    + + + {`${selectedCommentIds.length} comments selected`} +
    + ) }
    @@ -190,7 +190,7 @@ export default class UserDetail extends React.Component { className={styles.loadMore} loadMore={loadMore} showLoadMore={hasNextPage} - /> + /> ); diff --git a/client/coral-admin/src/components/UserDetailComment.js b/client/coral-admin/src/components/UserDetailComment.js index dc809b9c7..4e31d338b 100644 --- a/client/coral-admin/src/components/UserDetailComment.js +++ b/client/coral-admin/src/components/UserDetailComment.js @@ -54,8 +54,8 @@ class UserDetailComment extends React.Component { { (comment.editing && comment.editing.edited) - ?  ({t('comment.edited')}) - : null + ?  ({t('comment.edited')}) + : null }
    @@ -121,10 +121,10 @@ class UserDetailComment extends React.Component {
    {flagActions && flagActions.length ? + actions={flagActions} + actionSummaries={flagActionSummaries} + viewUserDetail={viewUserDetail} + /> : null}
  • ); diff --git a/client/coral-admin/src/components/ui/Header.js b/client/coral-admin/src/components/ui/Header.js index ca1cc1f30..b43fa8b35 100644 --- a/client/coral-admin/src/components/ui/Header.js +++ b/client/coral-admin/src/components/ui/Header.js @@ -13,9 +13,9 @@ const CoralHeader = ({ }) => (
    -
    - { - auth && auth.user && can(auth.user, 'ACCESS_ADMIN') ? +
    + { + auth && auth.user && can(auth.user, 'ACCESS_ADMIN') ? : null - } -
    -
    +
    ); diff --git a/client/coral-admin/src/containers/Layout.js b/client/coral-admin/src/containers/Layout.js index 2c5e1621a..f2d71c93b 100644 --- a/client/coral-admin/src/containers/Layout.js +++ b/client/coral-admin/src/containers/Layout.js @@ -55,10 +55,10 @@ class LayoutContainer extends Component { toggleShortcutModal={toggleShortcutModal} {...this.props} > - - - - {this.props.children} + + + + {this.props.children} ); } else if (loggedIn) { diff --git a/client/coral-admin/src/containers/UserDetail.js b/client/coral-admin/src/containers/UserDetail.js index e07b47261..0eb81a9a1 100644 --- a/client/coral-admin/src/containers/UserDetail.js +++ b/client/coral-admin/src/containers/UserDetail.js @@ -88,13 +88,13 @@ class UserDetailContainer extends React.Component { }); } }) - .then(() => { - this.isLoadingMore = false; - }) - .catch((err) => { - this.isLoadingMore = false; - throw err; - }); + .then(() => { + this.isLoadingMore = false; + }) + .catch((err) => { + this.isLoadingMore = false; + throw err; + }); }; componentWillReceiveProps(next) { diff --git a/client/coral-admin/src/routes/Community/components/FlaggedAccounts.js b/client/coral-admin/src/routes/Community/components/FlaggedAccounts.js index bb8504293..826e1299a 100644 --- a/client/coral-admin/src/routes/Community/components/FlaggedAccounts.js +++ b/client/coral-admin/src/routes/Community/components/FlaggedAccounts.js @@ -14,21 +14,21 @@ const FlaggedAccounts = (props) => {
    { hasResults - ? commenters.map((commenter, index) => { - return { + return ; - }) - : {t('community.no_flagged_accounts')} + }) + : {t('community.no_flagged_accounts')} }
diff --git a/client/coral-admin/src/routes/Community/components/People.js b/client/coral-admin/src/routes/Community/components/People.js index 464f3bc5b..aef4d250a 100644 --- a/client/coral-admin/src/routes/Community/components/People.js +++ b/client/coral-admin/src/routes/Community/components/People.js @@ -45,12 +45,12 @@ const People = ({commenters, searchValue, onSearchChange, ...props}) => {
{ hasResults - ? - : {t('community.no_results')} + : {t('community.no_results')} } this.setState({stage: stage + 1}); const suspend = () => { rejectUsername({id: user.user.id, message: this.state.email}) - .then(() => { - this.props.handleClose(); - }); + .then(() => { + this.props.handleClose(); + }); }; const suspendModalActions = [ @@ -71,21 +71,21 @@ class RejectUsernameDialog extends Component { const {stage} = this.state; return -
- {t(stages[stage].title, t('reject_username.username'))} -
-
-
- {t(stages[stage].description, t('reject_username.username'))} -
- { - stage === 1 && + className={styles.suspendDialog} + id="rejectUsernameDialog" + open={open} + onClose={handleClose} + onCancel={handleClose} + title={t('reject_username.suspend_user')}> +
+ {t(stages[stage].title, t('reject_username.username'))} +
+
+
+ {t(stages[stage].description, t('reject_username.username'))} +
+ { + stage === 1 &&
{t('reject_username.write_message')}
@@ -96,16 +96,16 @@ class RejectUsernameDialog extends Component { onChange={this.onEmailChange}/>
- } -
- {Object.keys(stages[stage].options).map((key, i) => ( - - ))} -
-
-
; + } +
+ {Object.keys(stages[stage].options).map((key, i) => ( + + ))} +
+ + ; } } diff --git a/client/coral-admin/src/routes/Community/components/Table.js b/client/coral-admin/src/routes/Community/components/Table.js index f851b1f84..c5bb494c0 100644 --- a/client/coral-admin/src/routes/Community/components/Table.js +++ b/client/coral-admin/src/routes/Community/components/Table.js @@ -9,9 +9,9 @@ export default ({headers, commenters, onHeaderClickHandler, onRoleChange, onComm
{headers.map((header, i) =>( ))} diff --git a/client/coral-admin/src/routes/Community/components/User.js b/client/coral-admin/src/routes/Community/components/User.js index 2d921a1c7..5225e0ee9 100644 --- a/client/coral-admin/src/routes/Community/components/User.js +++ b/client/coral-admin/src/routes/Community/components/User.js @@ -59,7 +59,7 @@ const User = (props) => {
flag{t('community.flags')}({ user.actions.length }): - { user.action_summaries.map( + { user.action_summaries.map( (action, i) => { return {shortReasons[action.reason]} ({action.count}) diff --git a/client/coral-admin/src/routes/Community/containers/Community.js b/client/coral-admin/src/routes/Community/containers/Community.js index b04fc0281..bfb634f18 100644 --- a/client/coral-admin/src/routes/Community/containers/Community.js +++ b/client/coral-admin/src/routes/Community/containers/Community.js @@ -77,14 +77,14 @@ export const withCommunityQuery = withQuery(gql` } } `, { - options: ({params: {action_type = 'FLAG'}}) => { - return { - variables: { - action_type: action_type - } - }; - } -}); + options: ({params: {action_type = 'FLAG'}}) => { + return { + variables: { + action_type: action_type + } + }; + } + }); const mapStateToProps = (state) => ({ community: state.community, diff --git a/client/coral-admin/src/routes/Configure/components/Configure.js b/client/coral-admin/src/routes/Configure/components/Configure.js index 84e47dfb7..15ff69b69 100644 --- a/client/coral-admin/src/routes/Configure/components/Configure.js +++ b/client/coral-admin/src/routes/Configure/components/Configure.js @@ -111,20 +111,20 @@ export default class Configure extends Component { (bool, error) => this.state.errors[error] ? false : bool, this.state.changed); return ( -
-
- - - {t('configure.stream_settings')} - - - {t('configure.moderation_settings')} - - - {t('configure.tech_settings')} - - -
+
+
+ + + {t('configure.stream_settings')} + + + {t('configure.moderation_settings')} + + + {t('configure.tech_settings')} + + +
{ showSave ? - : + : + {t('configure.save_changes')} + } -
+
-
-
- { this.props.saveFetchingError } - { this.props.fetchSettingsError } - { section } -
+
+ { this.props.saveFetchingError } + { this.props.fetchSettingsError } + { section } +
+
); } } diff --git a/client/coral-admin/src/routes/Configure/components/StreamSettings.js b/client/coral-admin/src/routes/Configure/components/StreamSettings.js index 9c216a853..1427f949e 100644 --- a/client/coral-admin/src/routes/Configure/components/StreamSettings.js +++ b/client/coral-admin/src/routes/Configure/components/StreamSettings.js @@ -93,15 +93,15 @@ const StreamSettings = ({updateSettings, settingsError, settings, errors}) => { value={settings.charCount} disabled={settings.charCountEnable ? '' : 'disabled'} /> - {t('configure.comment_count_text_post')} - { - errors.charCount && + {t('configure.comment_count_text_post')} + { + errors.charCount &&
{t('configure.comment_count_error')}
- } + }

diff --git a/client/coral-admin/src/routes/Dashboard/components/ActivityWidget.js b/client/coral-admin/src/routes/Dashboard/components/ActivityWidget.js index d92b2bd14..5b43a605c 100644 --- a/client/coral-admin/src/routes/Dashboard/components/ActivityWidget.js +++ b/client/coral-admin/src/routes/Dashboard/components/ActivityWidget.js @@ -14,19 +14,19 @@ const ActivityWidget = ({assets}) => {
{ assets.length - ? assets.map((asset) => { - return ( -
- Moderate -

{asset.commentCount}

- -

{asset.title}

-
-

{asset.author} — Published: {new Date(asset.created_at).toLocaleDateString()}

-
- ); - }) - :
{t('dashboard.no_activity')}
+ ? assets.map((asset) => { + return ( +
+ Moderate +

{asset.commentCount}

+ +

{asset.title}

+
+

{asset.author} — Published: {new Date(asset.created_at).toLocaleDateString()}

+
+ ); + }) + :
{t('dashboard.no_activity')}
}
diff --git a/client/coral-admin/src/routes/Dashboard/components/FlagWidget.js b/client/coral-admin/src/routes/Dashboard/components/FlagWidget.js index ef4a6857e..5dfbfb3ac 100644 --- a/client/coral-admin/src/routes/Dashboard/components/FlagWidget.js +++ b/client/coral-admin/src/routes/Dashboard/components/FlagWidget.js @@ -16,24 +16,24 @@ const FlagWidget = ({assets}) => {
{ assets.length - ? assets.map((asset) => { - let flagSummary = null; - if (asset.action_summaries) { - flagSummary = asset.action_summaries.find((s) => s.__typename === 'FlagAssetActionSummary'); - } + ? assets.map((asset) => { + let flagSummary = null; + if (asset.action_summaries) { + flagSummary = asset.action_summaries.find((s) => s.__typename === 'FlagAssetActionSummary'); + } - return ( -
- Moderate -

{flagSummary ? flagSummary.actionCount : 0}

- -

{asset.title}

-
-

{asset.author} — Published: {new Date(asset.created_at).toLocaleDateString()}

-
- ); - }) - :
{t('dashboard.no_flags')}
+ return ( +
+ Moderate +

{flagSummary ? flagSummary.actionCount : 0}

+ +

{asset.title}

+
+

{asset.author} — Published: {new Date(asset.created_at).toLocaleDateString()}

+
+ ); + }) + :
{t('dashboard.no_flags')}
}
diff --git a/client/coral-admin/src/routes/Dashboard/components/LikeWidget.js b/client/coral-admin/src/routes/Dashboard/components/LikeWidget.js index a61f888bf..aeb31c318 100644 --- a/client/coral-admin/src/routes/Dashboard/components/LikeWidget.js +++ b/client/coral-admin/src/routes/Dashboard/components/LikeWidget.js @@ -15,20 +15,20 @@ const LikeWidget = ({assets}) => {
{ assets.length - ? assets.map((asset) => { - const likeSummary = asset.action_summaries.find((s) => s.type === 'LikeAssetActionSummary'); - return ( -
- Moderate -

{likeSummary ? likeSummary.actionCount : 0}

- -

{asset.title}

-
-

{asset.author} — Published: {new Date(asset.created_at).toLocaleDateString()}

-
- ); - }) - :
{t('dashboard.no_likes')}
+ ? assets.map((asset) => { + const likeSummary = asset.action_summaries.find((s) => s.type === 'LikeAssetActionSummary'); + return ( +
+ Moderate +

{likeSummary ? likeSummary.actionCount : 0}

+ +

{asset.title}

+
+

{asset.author} — Published: {new Date(asset.created_at).toLocaleDateString()}

+
+ ); + }) + :
{t('dashboard.no_likes')}
}
diff --git a/client/coral-admin/src/routes/Dashboard/containers/Dashboard.js b/client/coral-admin/src/routes/Dashboard/containers/Dashboard.js index fe3680c76..2bb192f2e 100644 --- a/client/coral-admin/src/routes/Dashboard/containers/Dashboard.js +++ b/client/coral-admin/src/routes/Dashboard/containers/Dashboard.js @@ -42,15 +42,15 @@ export const witDashboardQuery = withQuery(gql` } } `, { - options: ({settings: {dashboardWindowStart, dashboardWindowEnd}}) => { - return { - variables: { - from: dashboardWindowStart, - to: dashboardWindowEnd - } - }; - } -}); + options: ({settings: {dashboardWindowStart, dashboardWindowEnd}}) => { + return { + variables: { + from: dashboardWindowStart, + to: dashboardWindowEnd + } + }; + } + }); const mapStateToProps = (state) => { return { diff --git a/client/coral-admin/src/routes/Install/components/Steps/CreateYourAccount.js b/client/coral-admin/src/routes/Install/components/Steps/CreateYourAccount.js index 2a5b87e5f..d4d43dc92 100644 --- a/client/coral-admin/src/routes/Install/components/Steps/CreateYourAccount.js +++ b/client/coral-admin/src/routes/Install/components/Steps/CreateYourAccount.js @@ -19,7 +19,7 @@ const InitialStep = (props) => { showErrors={install.showErrors} errorMsg={install.errors.email} noValidate - /> + /> { onChange={handleUserChange} showErrors={install.showErrors} errorMsg={install.errors.username} - /> + /> { onChange={handleUserChange} showErrors={install.showErrors} errorMsg={install.errors.password} - /> + /> { onChange={handleUserChange} showErrors={install.showErrors} errorMsg={install.errors.confirmPassword} - /> + /> { !props.install.isLoading ? - - : - + + : + } {props.install.installRequest === 'FAILURE' &&
Error: {props.install.installRequestError}
} diff --git a/client/coral-admin/src/routes/Moderation/components/Comment.js b/client/coral-admin/src/routes/Moderation/components/Comment.js index c73d15eaa..0fa2ba8bb 100644 --- a/client/coral-admin/src/routes/Moderation/components/Comment.js +++ b/client/coral-admin/src/routes/Moderation/components/Comment.js @@ -91,8 +91,8 @@ class Comment extends React.Component { { (comment.editing && comment.editing.edited) - ?  ({t('comment.edited')}) - : null + ?  ({t('comment.edited')}) + : null } {currentUserId !== comment.user.id && @@ -192,10 +192,10 @@ class Comment extends React.Component { /> {flagActions && flagActions.length ? + actions={flagActions} + actionSummaries={flagActionSummaries} + viewUserDetail={viewUserDetail} + /> : null} ); diff --git a/client/coral-admin/src/routes/Moderation/components/ModerationQueue.js b/client/coral-admin/src/routes/Moderation/components/ModerationQueue.js index 7f96c7c90..e8b5b8191 100644 --- a/client/coral-admin/src/routes/Moderation/components/ModerationQueue.js +++ b/client/coral-admin/src/routes/Moderation/components/ModerationQueue.js @@ -97,7 +97,7 @@ class ModerationQueue extends React.Component { rejectComment={props.rejectComment} currentAsset={props.currentAsset} currentUserId={this.props.currentUserId} - />; + />; }) } @@ -110,7 +110,7 @@ class ModerationQueue extends React.Component { + /> ); } diff --git a/client/coral-admin/src/routes/Moderation/components/StorySearch.js b/client/coral-admin/src/routes/Moderation/components/StorySearch.js index f19560549..748f80b0f 100644 --- a/client/coral-admin/src/routes/Moderation/components/StorySearch.js +++ b/client/coral-admin/src/routes/Moderation/components/StorySearch.js @@ -61,20 +61,20 @@ const StorySearch = (props) => { { loading - ? - : assets.map((story, i) => { - const storyOpen = story.closedAt === null || new Date(story.closedAt) > new Date(); + ? + : assets.map((story, i) => { + const storyOpen = story.closedAt === null || new Date(story.closedAt) > new Date(); - return ; - }) + return ; + }) } {assets.length === 0 &&
No results
} diff --git a/client/coral-admin/src/routes/Moderation/containers/StorySearch.js b/client/coral-admin/src/routes/Moderation/containers/StorySearch.js index 4175479e6..04472d219 100644 --- a/client/coral-admin/src/routes/Moderation/containers/StorySearch.js +++ b/client/coral-admin/src/routes/Moderation/containers/StorySearch.js @@ -98,14 +98,14 @@ export const withAssetSearchQuery = withQuery(gql` } } `, { - options: ({moderation: {storySearchString = ''}}) => { - return { - variables: { - value: storySearchString - } - }; - } -}); + options: ({moderation: {storySearchString = ''}}) => { + return { + variables: { + value: storySearchString + } + }; + } + }); export default compose( withRouter, diff --git a/client/coral-admin/src/routes/Stories/components/Stories.js b/client/coral-admin/src/routes/Stories/components/Stories.js index 7f9098fba..5b931e6fc 100644 --- a/client/coral-admin/src/routes/Stories/components/Stories.js +++ b/client/coral-admin/src/routes/Stories/components/Stories.js @@ -134,20 +134,20 @@ export default class Stories extends Component { {t('streams.closed')}
{t('streams.sort_by')}
- - {t('streams.newest')} - {t('streams.oldest')} - - + + {t('streams.newest')} + {t('streams.oldest')} + + { assetsIds.length - ?
+ ?
{t('streams.article')} @@ -162,7 +162,7 @@ export default class Stories extends Component { page={this.state.page} onNewPageHandler={this.onPageClick} />
- : {t('streams.empty_result')} + : {t('streams.empty_result')} }
); diff --git a/client/coral-configure/components/ConfigureCommentStream.js b/client/coral-configure/components/ConfigureCommentStream.js index 726b54e19..ec5a43c15 100644 --- a/client/coral-configure/components/ConfigureCommentStream.js +++ b/client/coral-configure/components/ConfigureCommentStream.js @@ -56,13 +56,13 @@ export default ({handleChange, handleApply, changed, ...props}) => ( title: t('configure.enable_questionbox'), description: t('configure.enable_questionbox_description') }} /> - { - props.questionBoxEnable && - } + { + props.questionBoxEnable && + } diff --git a/client/coral-configure/components/QuestionBoxBuilder.js b/client/coral-configure/components/QuestionBoxBuilder.js index 8ccc6ba31..285df40ed 100644 --- a/client/coral-configure/components/QuestionBoxBuilder.js +++ b/client/coral-configure/components/QuestionBoxBuilder.js @@ -41,39 +41,39 @@ class QuestionBoxBuilder extends React.Component {
  • + styles.qbItemIcon, + {[styles.qbItemIconActive]: questionBoxIcon === 'default'} + )} + id="qboxicon" + onClick={handleChange} + data-icon="default" >
  • + styles.qbItemIcon, + {[styles.qbItemIconActive]: questionBoxIcon === 'forum'} + )} + id="qboxicon" + onClick={handleChange} + data-icon="forum" >
  • + styles.qbItemIcon, + {[styles.qbItemIconActive]: questionBoxIcon === 'build'} + )} + id="qboxicon" + onClick={handleChange} + data-icon="build" >
  • + styles.qbItemIcon, + {[styles.qbItemIconActive]: questionBoxIcon === 'format_quote'} + )} + id="qboxicon" + onClick={handleChange} + data-icon="format_quote" >
diff --git a/client/coral-configure/containers/ConfigureStreamContainer.js b/client/coral-configure/containers/ConfigureStreamContainer.js index 2d4a16795..c009bbb76 100644 --- a/client/coral-configure/containers/ConfigureStreamContainer.js +++ b/client/coral-configure/containers/ConfigureStreamContainer.js @@ -115,7 +115,7 @@ class ConfigureStreamContainer extends Component { />

{closedAt === 'open' ? t('configure.close') : t('configure.open')} {t('configure.comment_stream')}

- {(closedAt === 'open' && closedTimeout) ?

{t('configure.comment_stream_will_close')} {this.getClosedIn()}.

: ''} + {(closedAt === 'open' && closedTimeout) ?

{t('configure.comment_stream_will_close')} {this.getClosedIn()}.

: ''} : ; + commentClassNames={commentClassNames} + data={data} + root={root} + disableReply={disableReply} + setActiveReplyBox={setActiveReplyBox} + activeReplyBox={activeReplyBox} + notify={notify} + depth={0} + postComment={postComment} + asset={asset} + currentUser={currentUser} + postFlag={postFlag} + postDontAgree={postDontAgree} + ignoreUser={ignoreUser} + commentIsIgnored={commentIsIgnored} + loadMore={loadNewReplies} + deleteAction={deleteAction} + showSignInDialog={showSignInDialog} + key={comment.id} + comment={comment} + charCountEnable={charCountEnable} + maxCharCount={maxCharCount} + editComment={editComment} + emit={emit} + />; })} { (comment.editing && comment.editing.edited) - ?  ({t('comment.edited')}) - : null + ?  ({t('comment.edited')}) + : null } @@ -492,7 +492,7 @@ export default class Comment extends React.Component {
{ this.state.isEditing - ? - :
- + :
+
}
@@ -562,23 +562,23 @@ export default class Comment extends React.Component { {activeReplyBox === comment.id ? + commentPostedHandler={this.commentPostedHandler} + charCountEnable={charCountEnable} + maxCharCount={maxCharCount} + setActiveReplyBox={setActiveReplyBox} + parentId={(depth < THREADING_LEVEL) ? comment.id : parentId} + notify={notify} + postComment={postComment} + currentUser={currentUser} + assetId={asset.id} + /> : null} - {view.map((reply) => { - return commentIsIgnored(reply) - ? - : { + return commentIsIgnored(reply) + ? + : ; - })} + })}
{ this.isEditWindowExpired() - ? + ? {t('edit_comment.edit_window_expired')} { typeof this.props.stopEditing === 'function' - ?  {t('edit_comment.edit_window_expired_close')} - : null + ?  {t('edit_comment.edit_window_expired_close')} + : null } - : + : {t('edit_comment.edit_window_timer_prefix')} { return
{ count ? - - : null + + : null }
; }; diff --git a/client/coral-embed-stream/src/components/Stream.js b/client/coral-embed-stream/src/components/Stream.js index 6959ff662..62c43813b 100644 --- a/client/coral-embed-stream/src/components/Stream.js +++ b/client/coral-embed-stream/src/components/Stream.js @@ -257,16 +257,16 @@ class Stream extends React.Component { {open ?
- - - {!banned && + + + {!banned && temporarilySuspended && {t( @@ -275,13 +275,13 @@ class Stream extends React.Component { timeago(user.suspension.until) )} } - {banned && + {banned && } - {showCommentBox && + {showCommentBox && } -
+
:

{asset.settings.closedMessage}

} { - canEditName ? + canEditName ? t('framework.edit_name.msg') : {t('framework.banned_account_header')}
{t('framework.banned_account_body')}
- }
+ } { canEditName ? -
-
- {alert} -
- - this.setState({username: e.target.value})} - rows={3}/>
- -
: null +
+
+ {alert} +
+ + this.setState({username: e.target.value})} + rows={3}/>
+ +
: null } ; } diff --git a/client/coral-embed-stream/src/components/TopRightMenu.js b/client/coral-embed-stream/src/components/TopRightMenu.js index 7ae123b90..47147e853 100644 --- a/client/coral-embed-stream/src/components/TopRightMenu.js +++ b/client/coral-embed-stream/src/components/TopRightMenu.js @@ -51,7 +51,7 @@ export class TopRightMenu extends React.Component { user={comment.user} cancel={reset} ignoreUser={ignoreUserAndCloseMenuAndNotifyOnError} - /> + />
); diff --git a/client/coral-embed-stream/src/graphql/utils.js b/client/coral-embed-stream/src/graphql/utils.js index ac13382bc..0c46b45e3 100644 --- a/client/coral-embed-stream/src/graphql/utils.js +++ b/client/coral-embed-stream/src/graphql/utils.js @@ -60,7 +60,7 @@ function findAndInsertComment(parent, comment) { [connectionField]: { nodes: { $apply: (nodes) => - nodes.map((node) => findAndInsertComment(node, comment)) + nodes.map((node) => findAndInsertComment(node, comment)) }, }, }); @@ -176,7 +176,7 @@ function findAndInsertFetchedComments(parent, comments, parent_id) { [connectionField]: { nodes: { $apply: (nodes) => - nodes.map((node) => findAndInsertFetchedComments(node, comments, parent_id)) + nodes.map((node) => findAndInsertFetchedComments(node, comments, parent_id)) }, }, }); diff --git a/client/coral-framework/helpers/validate.js b/client/coral-framework/helpers/validate.js index dd36ae07f..6a8d37f53 100644 --- a/client/coral-framework/helpers/validate.js +++ b/client/coral-framework/helpers/validate.js @@ -1,5 +1,5 @@ export default { - email: (email) => (/^([A-Za-z0-9_\-\.\+])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/.test(email)), + email: (email) => (/^([A-Za-z0-9_\-.+])+@([A-Za-z0-9_\-.])+\.([A-Za-z]{2,4})$/.test(email)), password: (pass) => (/^(?=.{8,}).*$/.test(pass)), confirmPassword: () => true, username: (username) => (/^[a-zA-Z0-9_]+$/.test(username)), diff --git a/client/coral-framework/hocs/withMutation.js b/client/coral-framework/hocs/withMutation.js index 46ec19eb7..f16809322 100644 --- a/client/coral-framework/hocs/withMutation.js +++ b/client/coral-framework/hocs/withMutation.js @@ -84,8 +84,8 @@ export default (document, config = {}) => hoistStatics((WrappedComponent) => { const updateCallbacks = [base.update || config.options.update] - .concat(...configs.map((cfg) => cfg.update)) - .filter((i) => i); + .concat(...configs.map((cfg) => cfg.update)) + .filter((i) => i); const update = (proxy, result) => { if (getResponseErrors(result)) { @@ -101,28 +101,28 @@ export default (document, config = {}) => hoistStatics((WrappedComponent) => { base.updateQueries || config.options.updateQueries, ...configs.map((cfg) => cfg.updateQueries) ] - .filter((i) => i) - .reduce((res, map) => { - Object.keys(map).forEach((key) => { - if (!(key in res)) { - res[key] = (prev, result) => { - if (getResponseErrors(result.mutationResult)) { + .filter((i) => i) + .reduce((res, map) => { + Object.keys(map).forEach((key) => { + if (!(key in res)) { + res[key] = (prev, result) => { + if (getResponseErrors(result.mutationResult)) { // Do not run updates when we have mutation errors. - return prev; - } - return map[key](prev, result) || prev; - }; - } else { - const existing = res[key]; - res[key] = (prev, result) => { - const next = existing(prev, result); - return map[key](next, result) || next; - }; - } - }); - return res; - }, {}); + return prev; + } + return map[key](prev, result) || prev; + }; + } else { + const existing = res[key]; + res[key] = (prev, result) => { + const next = existing(prev, result); + return map[key](next, result) || next; + }; + } + }); + return res; + }, {}); const wrappedConfig = { variables, diff --git a/client/coral-framework/hocs/withQuery.js b/client/coral-framework/hocs/withQuery.js index c0825f28b..101dc45a9 100644 --- a/client/coral-framework/hocs/withQuery.js +++ b/client/coral-framework/hocs/withQuery.js @@ -129,18 +129,18 @@ export default (document, config = {}) => hoistStatics((WrappedComponent) => { ...lmArgs, query: resolvedDocument, }) - .then((res) => { - this.context.eventEmitter.emit( - `query.${name}.fetchMore.${fetchName}.success`, - {variables: lmArgs.variables, data: res.data}); - return Promise.resolve(res); - }) - .catch((err) => { - this.context.eventEmitter.emit( - `query.${name}.fetchMore.${fetchName}.error`, - {variables: lmArgs.variables, error: err}); - throw err; - }); + .then((res) => { + this.context.eventEmitter.emit( + `query.${name}.fetchMore.${fetchName}.success`, + {variables: lmArgs.variables, data: res.data}); + return Promise.resolve(res); + }) + .catch((err) => { + this.context.eventEmitter.emit( + `query.${name}.fetchMore.${fetchName}.error`, + {variables: lmArgs.variables, error: err}); + throw err; + }); }, }; } @@ -171,8 +171,8 @@ export default (document, config = {}) => hoistStatics((WrappedComponent) => { const configs = this.graphqlRegistry.getQueryOptions(name); const reducerCallbacks = [base.reducer || ((i) => i)] - .concat(...configs.map((cfg) => cfg.reducer)) - .filter((i) => i); + .concat(...configs.map((cfg) => cfg.reducer)) + .filter((i) => i); const reducer = withSkipOnErrors( reducerCallbacks.reduce( diff --git a/client/coral-framework/services/plugins.js b/client/coral-framework/services/plugins.js index 1aae0c662..301428c12 100644 --- a/client/coral-framework/services/plugins.js +++ b/client/coral-framework/services/plugins.js @@ -81,11 +81,11 @@ class PluginsService { const pluginConfig = reduxState.config.plugin_config || emptyConfig; return flatten(this.plugins - // Filter out components that have slots and have been disabled in `plugin_config` - .filter((o) => o.module.slots && (!pluginConfig || !pluginConfig[o.name] || !pluginConfig[o.name].disable_components)) + // Filter out components that have slots and have been disabled in `plugin_config` + .filter((o) => o.module.slots && (!pluginConfig || !pluginConfig[o.name] || !pluginConfig[o.name].disable_components)) - .filter((o) => o.module.slots[slot]) - .map((o) => o.module.slots[slot]) + .filter((o) => o.module.slots[slot]) + .map((o) => o.module.slots[slot]) ) .filter((component) => { if(!component.isExcluded) { @@ -114,8 +114,8 @@ class PluginsService { config: pluginConfig, ...( component.fragments - ? pick(queryData, Object.keys(component.fragments)) - : withWarnings(component, queryData) + ? pick(queryData, Object.keys(component.fragments)) + : withWarnings(component, queryData) ) }; } diff --git a/client/coral-framework/utils/index.js b/client/coral-framework/utils/index.js index 533ed85db..93ae55d7a 100644 --- a/client/coral-framework/utils/index.js +++ b/client/coral-framework/utils/index.js @@ -26,7 +26,7 @@ export const getMyActionSummary = (type, comment) => { .find((a) => a.current_user); }; - /** +/** * getActionSummary * retrieves the action summaries based on the type and the comment * array could be length > 1, as in the case of FlagActionSummary diff --git a/client/coral-framework/utils/user.js b/client/coral-framework/utils/user.js index 044583026..ccdf8ba42 100644 --- a/client/coral-framework/utils/user.js +++ b/client/coral-framework/utils/user.js @@ -1,4 +1,4 @@ - /** +/** * getReliability * retrieves reliability value as string */ diff --git a/client/coral-settings/components/IgnoredUsers.js b/client/coral-settings/components/IgnoredUsers.js index 32e485e4c..a8723161f 100644 --- a/client/coral-settings/components/IgnoredUsers.js +++ b/client/coral-settings/components/IgnoredUsers.js @@ -2,7 +2,7 @@ import React, {Component, PropTypes} from 'react'; import t from 'coral-framework/services/i18n'; import styles from './IgnoredUsers.css'; -export class IgnoredUsers extends Component { +class IgnoredUsers extends Component { static propTypes = { users: PropTypes.arrayOf(PropTypes.shape({ username: PropTypes.string, diff --git a/client/coral-settings/containers/ProfileContainer.js b/client/coral-settings/containers/ProfileContainer.js index f5ea64005..c5bfa257c 100644 --- a/client/coral-settings/containers/ProfileContainer.js +++ b/client/coral-settings/containers/ProfileContainer.js @@ -79,12 +79,12 @@ class ProfileContainer extends Component { {me.ignoredUsers && me.ignoredUsers.length ?
-

{t('framework.ignored_users')}

- -
+

{t('framework.ignored_users')}

+ + : null}
diff --git a/client/coral-ui/components/CoralLogo.js b/client/coral-ui/components/CoralLogo.js index 002b0cabc..91331523f 100644 --- a/client/coral-ui/components/CoralLogo.js +++ b/client/coral-ui/components/CoralLogo.js @@ -3,34 +3,34 @@ import styles from './CoralLogo.css'; const CoralLogo = ({className = ''}) => ( - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + - - - + ); CoralLogo.propTypes = { diff --git a/client/coral-ui/components/Dialog.js b/client/coral-ui/components/Dialog.js index 85ab570d3..6e2489fea 100644 --- a/client/coral-ui/components/Dialog.js +++ b/client/coral-ui/components/Dialog.js @@ -56,7 +56,7 @@ export default class Dialog extends Component { className={`mdl-dialog ${className}`} {...rest} > - {children} + {children} ); } diff --git a/client/coral-ui/components/Pager.js b/client/coral-ui/components/Pager.js index ffd1b9d0a..d14f2fc60 100644 --- a/client/coral-ui/components/Pager.js +++ b/client/coral-ui/components/Pager.js @@ -3,7 +3,7 @@ import styles from './Pager.css'; const Rows = (curr, total, onClickHandler) => Array.from(Array(total)).map((e, i) =>
  • onClickHandler(i + 1)}> + key={i} onClick={() => onClickHandler(i + 1)}> {i + 1}
  • ); @@ -17,18 +17,18 @@ const Pager = ({totalPages, page, onNewPageHandler}) => ( onClick={() => onNewPageHandler(page - 1)}> Prev - : + : null } {Rows(page, totalPages, onNewPageHandler)} { (page < totalPages && totalPages > 1) ? -
  • onNewPageHandler(page + 1)}> +
  • onNewPageHandler(page + 1)}> Next -
  • - : - null + + : + null } diff --git a/client/coral-ui/components/Wizard.js b/client/coral-ui/components/Wizard.js index eefa2a0b1..bc87a8bcc 100644 --- a/client/coral-ui/components/Wizard.js +++ b/client/coral-ui/components/Wizard.js @@ -7,12 +7,12 @@ const Wizard = (props) => { {React.Children.toArray(children) .filter((child, i) => i === currentStep) .map((child, i) => - React.cloneElement(child, { - i, - currentStep, - ...rest - }) - )} + React.cloneElement(child, { + i, + currentStep, + ...rest + }) + )} ); }; diff --git a/client/talk-plugin-flags/components/FlagButton.js b/client/talk-plugin-flags/components/FlagButton.js index bf3da6f01..a225bda41 100644 --- a/client/talk-plugin-flags/components/FlagButton.js +++ b/client/talk-plugin-flags/components/FlagButton.js @@ -93,18 +93,24 @@ export default class FlagButton extends Component { }; if (reason === 'COMMENT_NOAGREE') { postDontAgree(action) - .then(({data}) => { - if (itemType === 'COMMENTS') { - this.setState({localPost: data.createDontAgree.dontagree.id}); - } - }); + .then(({data}) => { + if (itemType === 'COMMENTS') { + this.setState({localPost: data.createDontAgree.dontagree.id}); + } + }) + .catch((err) => { + console.error(err); + }); } else { postFlag({...action, reason}) - .then(({data}) => { - if (itemType === 'COMMENTS') { - this.setState({localPost: data.createFlag.flag.id}); - } - }); + .then(({data}) => { + if (itemType === 'COMMENTS') { + this.setState({localPost: data.createFlag.flag.id}); + } + }) + .catch((err) => { + console.error(err); + }); } } } @@ -153,15 +159,15 @@ export default class FlagButton extends Component { className={cn(`${name}-button`, {[`${name}-button-flagged`]: flagged}, styles.button)}> { flagged - ? {t('reported')} - : {t('report')} + ? {t('reported')} + : {t('report')} } flag + aria-hidden={true}>flag { this.state.showMenu && @@ -190,10 +196,10 @@ export default class FlagButton extends Component { } { this.state.reason &&
    -
    -
    onHeaderClickHandler({field: header.field})}> + key={i} + className="mdl-data-table__cell--non-numeric" + onClick={() => onHeaderClickHandler({field: header.field})}> {header.title}