From 6a5f667336d7a382e8bc5458af0fdf04f05ab803 Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Wed, 22 Mar 2017 13:20:26 -0300 Subject: [PATCH 01/14] hover, menu order --- .../coral-admin/src/components/ui/Header.css | 6 ++- .../components/ModerationMenu.js | 48 +++++++++++++------ 2 files changed, 38 insertions(+), 16 deletions(-) diff --git a/client/coral-admin/src/components/ui/Header.css b/client/coral-admin/src/components/ui/Header.css index e30cb46d7e..eba94d8925 100644 --- a/client/coral-admin/src/components/ui/Header.css +++ b/client/coral-admin/src/components/ui/Header.css @@ -74,8 +74,12 @@ background-color: transparent; transition: background-color 200ms; + &:hover { + background-color: #232323; + } + &.active { - background-color: #232323; + background-color: #232323; } } diff --git a/client/coral-admin/src/containers/ModerationQueue/components/ModerationMenu.js b/client/coral-admin/src/containers/ModerationQueue/components/ModerationMenu.js index b8160e21b3..e428f6a526 100644 --- a/client/coral-admin/src/containers/ModerationQueue/components/ModerationMenu.js +++ b/client/coral-admin/src/containers/ModerationQueue/components/ModerationMenu.js @@ -1,35 +1,53 @@ -import React, {PropTypes} from 'react'; +import React, { PropTypes } from 'react'; import CommentCount from './CommentCount'; import styles from './styles.css'; -import {SelectField, Option} from 'react-mdl-selectfield'; +import { SelectField, Option } from 'react-mdl-selectfield'; import I18n from 'coral-framework/modules/i18n/i18n'; import translations from 'coral-admin/src/translations.json'; -import {Link} from 'react-router'; +import { Link } from 'react-router'; const lang = new I18n(translations); -const ModerationMenu = ({asset, premodCount, rejectedCount, flaggedCount, selectSort, sort}) => { - const premodPath = asset ? `/admin/moderate/premod/${asset.id}` : '/admin/moderate/premod'; - const rejectPath = asset ? `/admin/moderate/rejected/${asset.id}` : '/admin/moderate/rejected'; - const flagPath = asset ? `/admin/moderate/flagged/${asset.id}` : '/admin/moderate/flagged'; +const ModerationMenu = ( + { asset, premodCount, rejectedCount, flaggedCount, selectSort, sort } +) => { + const premodPath = asset + ? `/admin/moderate/premod/${asset.id}` + : '/admin/moderate/premod'; + const rejectPath = asset + ? `/admin/moderate/rejected/${asset.id}` + : '/admin/moderate/rejected'; + const flagPath = asset + ? `/admin/moderate/flagged/${asset.id}` + : '/admin/moderate/flagged'; + return ( -
+
-
+
- + {lang.t('modqueue.premod')} - - {lang.t('modqueue.rejected')} - - + {lang.t('modqueue.flagged')} + + {lang.t('modqueue.rejected')} +
selectSort(sort)}> From cd27ffe86a46e929d8882807105e35dc837059b4 Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Wed, 22 Mar 2017 13:37:44 -0300 Subject: [PATCH 02/14] wip --- .../src/containers/ModerationQueue/components/styles.css | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/client/coral-admin/src/containers/ModerationQueue/components/styles.css b/client/coral-admin/src/containers/ModerationQueue/components/styles.css index 9576045def..61902240b6 100644 --- a/client/coral-admin/src/containers/ModerationQueue/components/styles.css +++ b/client/coral-admin/src/containers/ModerationQueue/components/styles.css @@ -216,10 +216,12 @@ span { justify-content: space-between; .author { - font-weight: 600; + font-weight: 300; min-width: 230px; display: flex; align-items: center; + color: #262626; + font-size: 16px; } } @@ -242,10 +244,11 @@ span { } .created { - color: #666; - font-size: 13px; + color: #262626; + font-size: 14px; margin-left: 15px; line-height: 1px; + font-weight: 300; } .actionButton { From 71415877b3afb5a37cff53be598f5b1a2e15768c Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Wed, 22 Mar 2017 14:04:08 -0300 Subject: [PATCH 03/14] comment tweaks --- .../src/containers/ModerationQueue/components/styles.css | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/client/coral-admin/src/containers/ModerationQueue/components/styles.css b/client/coral-admin/src/containers/ModerationQueue/components/styles.css index 61902240b6..51086dfd4b 100644 --- a/client/coral-admin/src/containers/ModerationQueue/components/styles.css +++ b/client/coral-admin/src/containers/ModerationQueue/components/styles.css @@ -170,7 +170,7 @@ span { border-bottom: 1px solid #e0e0e0; font-size: 18px; width: 100%; - max-width: 660px; + max-width: 700px; min-width: 400px; margin: 0 auto; position: relative; @@ -192,7 +192,7 @@ span { } &.selected { - max-width: 670px; + max-width: 720px; max-height: 410px; } @@ -263,6 +263,7 @@ span { max-width: 500px; word-wrap: break-word; font-weight: 300; + font-size: 16px; } .flagged { From 5729b03656b2f1bbfa242b21137eb4892be8a3bf Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Wed, 22 Mar 2017 15:35:40 -0300 Subject: [PATCH 04/14] my-comments-ux --- client/coral-framework/actions/asset.js | 2 +- client/coral-framework/actions/auth.js | 2 +- .../coral-framework/actions/notification.js | 2 +- client/coral-framework/translations.json | 2 + client/coral-plugin-history/Comment.css | 60 ++++++++++++++++- client/coral-plugin-history/Comment.js | 39 +++++++++-- client/coral-ui/components/TabBar.css | 2 +- package.json | 7 +- yarn.lock | 65 ++++++++++--------- 9 files changed, 139 insertions(+), 42 deletions(-) diff --git a/client/coral-framework/actions/asset.js b/client/coral-framework/actions/asset.js index 02e72ea98a..609525986f 100644 --- a/client/coral-framework/actions/asset.js +++ b/client/coral-framework/actions/asset.js @@ -2,7 +2,7 @@ import * as actions from '../constants/asset'; import coralApi from '../helpers/response'; import {addNotification} from '../actions/notification'; -import I18n from 'coral-framework/modules/i18n/i18n'; +import I18n from '../../coral-framework/modules/i18n/i18n'; import translations from './../translations'; const lang = new I18n(translations); diff --git a/client/coral-framework/actions/auth.js b/client/coral-framework/actions/auth.js index 9dedaa2f2d..8dc47136c0 100644 --- a/client/coral-framework/actions/auth.js +++ b/client/coral-framework/actions/auth.js @@ -1,4 +1,4 @@ -import I18n from 'coral-framework/modules/i18n/i18n'; +import I18n from '../../coral-framework/modules/i18n/i18n'; import translations from './../translations'; const lang = new I18n(translations); import * as actions from '../constants/auth'; diff --git a/client/coral-framework/actions/notification.js b/client/coral-framework/actions/notification.js index f2cc053ec4..cb1aee5dd8 100644 --- a/client/coral-framework/actions/notification.js +++ b/client/coral-framework/actions/notification.js @@ -1,4 +1,4 @@ -import {pym} from 'coral-framework'; +import {pym} from '../../coral-framework'; export const addNotification = (notifType, text) => { pym.sendMessage('coral-alert', `${notifType}|${text}`); diff --git a/client/coral-framework/translations.json b/client/coral-framework/translations.json index b327a70974..d3e063a60a 100644 --- a/client/coral-framework/translations.json +++ b/client/coral-framework/translations.json @@ -1,5 +1,6 @@ { "en": { + "MY_COMMENTS": "My Comments", "profile": "Profile", "successUpdateSettings": "The changes you have made have been applied to the comment stream on this article", "successNameUpdate": "Your username has been updated", @@ -40,6 +41,7 @@ } }, "es": { + "MY_COMMENTS": "Mis Comentarios", "profile": "Perfil", "successUpdateSettings": "La configuración de este articulo fue actualizada", "successBioUpdate": "Tu bio fue actualizada", diff --git a/client/coral-plugin-history/Comment.css b/client/coral-plugin-history/Comment.css index f54b0ad29a..2c0dee0948 100644 --- a/client/coral-plugin-history/Comment.css +++ b/client/coral-plugin-history/Comment.css @@ -1,16 +1,74 @@ +@custom-media --big-viewport (min-width: 780px); + .myComment { border-bottom: 1px solid lightgrey; + display: flex; + align-items: baseline; + justify-content: space-between; } .myComment:last-child { - border-bottom: none; + border-bottom: solid 1px #EBEBEB; } .assetURL { font-size: 16px; color: black; + text-decoration: none; + font-weight: bold; } .commentBody { } + +.sidebar { + ul { + min-width: 136px; + } + + li { + margin-bottom: 10px; + + &:nth-child(1) { + color: #5394D7; + } + + &:nth-child(2) { + color: #909090; + } + + + i { + margin-right: 5px; + font-size: 15px; + vertical-align: bottom; + } + + a:hover { + cursor: pointer; + } + } +} + +@custom-media --mobile-viewport (max-width: 480px); + +@media (--mobile-viewport) { + .myComment { + flex-direction: column; + } + + .sidebar ul { + display: flex; + li { + margin-right: 20px; + } + } +} + +.pubdate { + display: inline-block; + font-size: inherit; + margin: inherit; + color: inherit; +} diff --git a/client/coral-plugin-history/Comment.js b/client/coral-plugin-history/Comment.js index 00dcc40c7b..707939536e 100644 --- a/client/coral-plugin-history/Comment.js +++ b/client/coral-plugin-history/Comment.js @@ -1,13 +1,42 @@ -import React, {PropTypes} from 'react'; +import React, { PropTypes } from 'react'; +import { Icon } from '../coral-ui'; import styles from './Comment.css'; +import PubDate from '../coral-plugin-pubdate/PubDate'; +import Content from '../coral-plugin-commentcontent/CommentContent'; const Comment = props => { return ( ); }; diff --git a/client/coral-ui/components/TabBar.css b/client/coral-ui/components/TabBar.css index 33a4c6d8b1..b5d44d5703 100644 --- a/client/coral-ui/components/TabBar.css +++ b/client/coral-ui/components/TabBar.css @@ -19,7 +19,7 @@ } .base li:hover { - background: #f3f3f3; + background: #d5d5d5; cursor: pointer; } diff --git a/package.json b/package.json index 9094522316..ab7a789e0d 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "build-watch": "NODE_ENV=development webpack --progress --config webpack.config.js --watch", "lint": "eslint bin/* .", "lint-fix": "eslint bin/* . --fix", - "test": "TEST_MODE=unit NODE_ENV=test mocha -R ${MOCHA_REPORTER:-spec}", + "test": "TEST_MODE=unit NODE_ENV=test mocha -r jsdom-global/register ${MOCHA_REPORTER:-spec}", "test-cover": "TEST_MODE=unit NODE_ENV=test istanbul cover _mocha --report text --check-coverage -- -R spec", "pree2e": "NODE_ENV=test TALK_PORT=3011 scripts/pree2e.sh", "e2e": "NODE_ENV=test nightwatch", @@ -62,14 +62,15 @@ "env-rewrite": "^1.0.2", "express": "^4.14.0", "express-session": "^1.14.2", - "gql-merge": "^0.0.4", "form-data": "^2.1.2", + "gql-merge": "^0.0.4", "graphql": "^0.8.2", "graphql-errors": "^2.1.0", "graphql-server-express": "^0.5.0", "graphql-tools": "^0.9.0", "helmet": "^3.1.0", "inquirer": "^3.0.1", + "jsdom-global": "^2.1.1", "jsonwebtoken": "^7.1.9", "kue": "^0.11.5", "linkify-it": "^2.0.3", @@ -133,7 +134,7 @@ "immutable": "^3.8.1", "imports-loader": "^0.6.5", "istanbul": "^1.1.0-alpha.1", - "jsdom": "^9.8.3", + "jsdom": "^9.12.0", "json-loader": "^0.5.4", "keymaster": "^1.6.2", "license-webpack-plugin": "^0.4.2", diff --git a/yarn.lock b/yarn.lock index 25171f74d7..ef0b4fa822 100644 --- a/yarn.lock +++ b/yarn.lock @@ -49,7 +49,7 @@ "@types/express-serve-static-core" "*" "@types/mime" "*" -abab@^1.0.0: +abab@^1.0.0, abab@^1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/abab/-/abab-1.0.3.tgz#b81de5f7274ec4e756d797cd834f303642724e5d" @@ -76,7 +76,7 @@ acorn-globals@^1.0.4: dependencies: acorn "^2.1.0" -acorn-globals@^3.0.0: +acorn-globals@^3.0.0, acorn-globals@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/acorn-globals/-/acorn-globals-3.1.0.tgz#fd8270f71fbb4996b004fa880ee5d46573a731bf" dependencies: @@ -2022,11 +2022,11 @@ csso@~2.3.1: clap "^1.0.9" source-map "^0.5.3" -cssom@0.3.x, "cssom@>= 0.3.0 < 0.4.0": +cssom@0.3.x, "cssom@>= 0.3.0 < 0.4.0", "cssom@>= 0.3.2 < 0.4.0": version "0.3.2" resolved "https://registry.yarnpkg.com/cssom/-/cssom-0.3.2.tgz#b8036170c79f07a90ff2f16e22284027a243848b" -"cssstyle@>= 0.2.29 < 0.3.0", "cssstyle@>= 0.2.36 < 0.3.0": +"cssstyle@>= 0.2.29 < 0.3.0", "cssstyle@>= 0.2.37 < 0.3.0": version "0.2.37" resolved "https://registry.yarnpkg.com/cssstyle/-/cssstyle-0.2.37.tgz#541097234cb2513c83ceed3acddc27ff27987d54" dependencies: @@ -3635,7 +3635,7 @@ iconv-lite@0.4.13: version "0.4.13" resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.13.tgz#1f88aba4ab0b1508e8312acc39345f36e992e2f2" -iconv-lite@0.4.15, iconv-lite@^0.4.13, iconv-lite@^0.4.5, iconv-lite@~0.4.13: +iconv-lite@0.4.15, iconv-lite@^0.4.5, iconv-lite@~0.4.13: version "0.4.15" resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.15.tgz#fe265a218ac6a57cfe854927e9d04c19825eddeb" @@ -4188,6 +4188,10 @@ jsbn@~0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-0.1.0.tgz#650987da0dd74f4ebf5a11377a2aa2d273e97dfd" +jsdom-global@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/jsdom-global/-/jsdom-global-2.1.1.tgz#47d46fe77f6167baf5d34431d3bb59fc41b0915a" + jsdom@^7.0.2: version "7.2.2" resolved "https://registry.yarnpkg.com/jsdom/-/jsdom-7.2.2.tgz#40b402770c2bda23469096bee91ab675e3b1fc6e" @@ -4208,30 +4212,29 @@ jsdom@^7.0.2: whatwg-url-compat "~0.6.5" xml-name-validator ">= 2.0.1 < 3.0.0" -jsdom@^9.8.3: - version "9.9.1" - resolved "https://registry.yarnpkg.com/jsdom/-/jsdom-9.9.1.tgz#84f3972ad394ab963233af8725211bce4d01bfd5" +jsdom@^9.12.0: + version "9.12.0" + resolved "https://registry.yarnpkg.com/jsdom/-/jsdom-9.12.0.tgz#e8c546fffcb06c00d4833ca84410fed7f8a097d4" dependencies: - abab "^1.0.0" - acorn "^2.4.0" - acorn-globals "^1.0.4" + abab "^1.0.3" + acorn "^4.0.4" + acorn-globals "^3.1.0" array-equal "^1.0.0" content-type-parser "^1.0.1" - cssom ">= 0.3.0 < 0.4.0" - cssstyle ">= 0.2.36 < 0.3.0" + cssom ">= 0.3.2 < 0.4.0" + cssstyle ">= 0.2.37 < 0.3.0" escodegen "^1.6.1" html-encoding-sniffer "^1.0.1" - iconv-lite "^0.4.13" nwmatcher ">= 1.3.9 < 2.0.0" parse5 "^1.5.1" - request "^2.55.0" - sax "^1.1.4" - symbol-tree ">= 3.1.0 < 4.0.0" - tough-cookie "^2.3.1" - webidl-conversions "^3.0.1" + request "^2.79.0" + sax "^1.2.1" + symbol-tree "^3.2.1" + tough-cookie "^2.3.2" + webidl-conversions "^4.0.0" whatwg-encoding "^1.0.1" - whatwg-url "^4.1.0" - xml-name-validator ">= 2.0.1 < 3.0.0" + whatwg-url "^4.3.0" + xml-name-validator "^2.0.1" jsesc@^1.3.0: version "1.3.0" @@ -6919,7 +6922,7 @@ sax@0.5.x: version "0.5.8" resolved "https://registry.yarnpkg.com/sax/-/sax-0.5.8.tgz#d472db228eb331c2506b0e8c15524adb939d12c1" -sax@^1.1.4, sax@~1.2.1: +sax@^1.1.4, sax@^1.2.1, sax@~1.2.1: version "1.2.1" resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.1.tgz#7b8e656190b228e81a66aea748480d828cd2d37a" @@ -7401,7 +7404,7 @@ symbol-observable@^1.0.2: version "1.0.4" resolved "https://registry.yarnpkg.com/symbol-observable/-/symbol-observable-1.0.4.tgz#29bf615d4aa7121bdd898b22d4b3f9bc4e2aa03d" -"symbol-tree@>= 3.1.0 < 4.0.0": +"symbol-tree@>= 3.1.0 < 4.0.0", symbol-tree@^3.2.1: version "3.2.1" resolved "https://registry.yarnpkg.com/symbol-tree/-/symbol-tree-3.2.1.tgz#8549dd1d01fa9f893c18cc9ab0b106b4d9b168cb" @@ -7565,7 +7568,7 @@ touch@1.0.0: dependencies: nopt "~1.0.10" -tough-cookie@^2.0.0, tough-cookie@^2.2.0, tough-cookie@^2.3.1, tough-cookie@~2.3.0: +tough-cookie@^2.0.0, tough-cookie@^2.2.0, tough-cookie@^2.3.2, tough-cookie@~2.3.0: version "2.3.2" resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.3.2.tgz#f081f76e4c85720e6c37a5faced737150d84072a" dependencies: @@ -7801,10 +7804,14 @@ webidl-conversions@^2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-2.0.1.tgz#3bf8258f7d318c7443c36f2e169402a1a6703506" -webidl-conversions@^3.0.0, webidl-conversions@^3.0.1: +webidl-conversions@^3.0.0: version "3.0.1" resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871" +webidl-conversions@^4.0.0: + version "4.0.1" + resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-4.0.1.tgz#8015a17ab83e7e1b311638486ace81da6ce206a0" + webpack-sources@^0.1.4: version "0.1.4" resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-0.1.4.tgz#ccc2c817e08e5fa393239412690bb481821393cd" @@ -7853,9 +7860,9 @@ whatwg-url-compat@~0.6.5: dependencies: tr46 "~0.0.1" -whatwg-url@^4.1.0: - version "4.3.0" - resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-4.3.0.tgz#92aaee21f4f2a642074357d70ef8500a7cbb171a" +whatwg-url@^4.3.0: + version "4.6.0" + resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-4.6.0.tgz#ef98da442273be04cf9632e176f257d2395a1ae4" dependencies: tr46 "~0.0.3" webidl-conversions "^3.0.0" @@ -7956,7 +7963,7 @@ xdg-basedir@^2.0.0: dependencies: os-homedir "^1.0.0" -"xml-name-validator@>= 2.0.1 < 3.0.0": +"xml-name-validator@>= 2.0.1 < 3.0.0", xml-name-validator@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/xml-name-validator/-/xml-name-validator-2.0.1.tgz#4d8b8f1eccd3419aa362061becef515e1e559635" From 4f50e8f19c3de4a72a211aa786b0fc0d768ebc06 Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Wed, 22 Mar 2017 16:19:05 -0300 Subject: [PATCH 05/14] Removing tests for now until we find a better solution for this --- package.json | 7 ++-- .../coral-plugin-history/Comment.spec.js | 30 -------------- .../CommentHistory.spec.js | 39 ------------------- 3 files changed, 3 insertions(+), 73 deletions(-) delete mode 100644 test/client/coral-plugin-history/Comment.spec.js delete mode 100644 test/client/coral-plugin-history/CommentHistory.spec.js diff --git a/package.json b/package.json index ab7a789e0d..9094522316 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "build-watch": "NODE_ENV=development webpack --progress --config webpack.config.js --watch", "lint": "eslint bin/* .", "lint-fix": "eslint bin/* . --fix", - "test": "TEST_MODE=unit NODE_ENV=test mocha -r jsdom-global/register ${MOCHA_REPORTER:-spec}", + "test": "TEST_MODE=unit NODE_ENV=test mocha -R ${MOCHA_REPORTER:-spec}", "test-cover": "TEST_MODE=unit NODE_ENV=test istanbul cover _mocha --report text --check-coverage -- -R spec", "pree2e": "NODE_ENV=test TALK_PORT=3011 scripts/pree2e.sh", "e2e": "NODE_ENV=test nightwatch", @@ -62,15 +62,14 @@ "env-rewrite": "^1.0.2", "express": "^4.14.0", "express-session": "^1.14.2", - "form-data": "^2.1.2", "gql-merge": "^0.0.4", + "form-data": "^2.1.2", "graphql": "^0.8.2", "graphql-errors": "^2.1.0", "graphql-server-express": "^0.5.0", "graphql-tools": "^0.9.0", "helmet": "^3.1.0", "inquirer": "^3.0.1", - "jsdom-global": "^2.1.1", "jsonwebtoken": "^7.1.9", "kue": "^0.11.5", "linkify-it": "^2.0.3", @@ -134,7 +133,7 @@ "immutable": "^3.8.1", "imports-loader": "^0.6.5", "istanbul": "^1.1.0-alpha.1", - "jsdom": "^9.12.0", + "jsdom": "^9.8.3", "json-loader": "^0.5.4", "keymaster": "^1.6.2", "license-webpack-plugin": "^0.4.2", diff --git a/test/client/coral-plugin-history/Comment.spec.js b/test/client/coral-plugin-history/Comment.spec.js deleted file mode 100644 index 6d69d54cdf..0000000000 --- a/test/client/coral-plugin-history/Comment.spec.js +++ /dev/null @@ -1,30 +0,0 @@ -import React from 'react'; -import {shallow, mount} from 'enzyme'; -import {expect} from 'chai'; -import Comment from '../../../client/coral-plugin-history/Comment'; - -describe('coral-plugin-history/Comment', () => { - let render; - const comment = {body: 'this is a comment', id: '123'}; - const asset = {url: 'https://google.com'}; - - beforeEach(() => { - render = shallow({}}/>); - }); - - it('should render the provided comment body', () => { - const wrapper = mount({}}/>); - expect(wrapper.find('.myCommentBody')).to.have.length(1); - expect(wrapper.find('.myCommentBody').text()).to.equal('this is a comment'); - }); - - it('should render the asset url as a link', () => { - const wrapper = mount({}}/>); - expect(wrapper.find('.myCommentAnchor')).to.have.length(1); - expect(wrapper.find('.myCommentAnchor').text()).to.equal('https://google.com'); - }); - - it('should render the comment with styles', () => { - expect(render.props().style).to.be.defined; - }); -}); diff --git a/test/client/coral-plugin-history/CommentHistory.spec.js b/test/client/coral-plugin-history/CommentHistory.spec.js deleted file mode 100644 index 671a50137f..0000000000 --- a/test/client/coral-plugin-history/CommentHistory.spec.js +++ /dev/null @@ -1,39 +0,0 @@ -import React from 'react'; -import {shallow, mount} from 'enzyme'; -import {expect} from 'chai'; -import CommentHistory from '../../../client/coral-plugin-history/CommentHistory'; - -describe('coral-plugin-history/CommentHistory', () => { - let render; - const comments = [{body: 'a comment or something', 'status_history':[{'type':'premod', 'created_at':'2016-12-09T01:40:53.327Z', 'assigned_by':null}, {'created_at':'2016-12-09T22:52:44.888Z', 'type':'accepted', 'assigned_by':'92256159-1164-4f66-9970-c7f23de7e461'}], 'asset_id':'96fddf96-7c83-4008-80ad-50091997d006', 'created_at':'2016-12-09T01:40:53.360Z', 'author_id':'92256159-1164-4f66-9970-c7f23de7e461', 'status':'accepted', '__v':0, 'updated_at':'2016-12-09T22:52:44.893Z', 'id':'3962c2ea-4ec4-42e4-b9bd-c571ff30f56b'}, {'body':'another comment', 'status_history':[{'type':'premod', 'created_at':'2016-12-09T22:53:43.148Z', 'assigned_by':null}], 'asset_id':'96fddf96-7c83-4008-80ad-50091997d006', 'created_at':'2016-12-09T22:53:43.158Z', 'author_id':'92256159-1164-4f66-9970-c7f23de7e461', 'status':'premod', '__v':0, 'updated_at':'2016-12-09T22:53:43.158Z', 'id':'b51e27af-bcfd-4932-91be-e3f01a4802e6'}, {'body':'can I comment?', 'status_history':[{'type':'premod', 'created_at':'2016-12-13T23:23:47.123Z', 'assigned_by':null}, {'created_at':'2016-12-13T23:23:58.487Z', 'type':'accepted', 'assigned_by':'92256159-1164-4f66-9970-c7f23de7e461'}], 'asset_id':'cef81015-1b53-4d70-b9af-6eca680f22fc', 'created_at':'2016-12-13T23:23:47.131Z', 'author_id':'92256159-1164-4f66-9970-c7f23de7e461', 'status':'accepted', '__v':0, 'updated_at':'2016-12-13T23:23:58.493Z', 'id':'dc9d7be1-b911-4dc3-8e1e-400e8b8d110e'}, {'body':'pre-mod comment', 'status_history':[{'type':'premod', 'created_at':'2016-12-08T21:34:56.994Z', 'assigned_by':null}, {'created_at':'2016-12-08T21:38:04.961Z', 'type':'rejected', 'assigned_by':'92256159-1164-4f66-9970-c7f23de7e461'}], 'asset_id':'96fddf96-7c83-4008-80ad-50091997d006', 'created_at':'2016-12-08T21:34:56.997Z', 'author_id':'92256159-1164-4f66-9970-c7f23de7e461', 'status':'rejected', '__v':0, 'updated_at':'2016-12-08T21:38:04.965Z', 'id':'6f02af16-a8f8-4ead-80ea-0d48824eb74d'}, {'body':'a flagged commetn', 'status_history':[{'type':'premod', 'created_at':'2016-12-08T21:38:26.342Z', 'assigned_by':null}, {'created_at':'2016-12-09T23:47:27.009Z', 'type':'accepted', 'assigned_by':'92256159-1164-4f66-9970-c7f23de7e461'}], 'asset_id':'96fddf96-7c83-4008-80ad-50091997d006', 'created_at':'2016-12-08T21:38:26.344Z', 'author_id':'92256159-1164-4f66-9970-c7f23de7e461', 'status':'accepted', '__v':0, 'updated_at':'2016-12-09T23:47:27.018Z', 'id':'784c5f91-36b9-4bda-b4ca-a114cef2c9f0'}, {'body':'a post mod comment', 'status_history':[{'type':'premod', 'created_at':'2016-12-08T22:19:05.870Z', 'assigned_by':null}, {'created_at':'2016-12-09T23:26:41.427Z', 'type':'accepted', 'assigned_by':'92256159-1164-4f66-9970-c7f23de7e461'}], 'asset_id':'96fddf96-7c83-4008-80ad-50091997d006', 'created_at':'2016-12-08T22:19:05.874Z', 'author_id':'92256159-1164-4f66-9970-c7f23de7e461', 'status':'accepted', '__v':0, 'updated_at':'2016-12-09T23:26:41.450Z', 'id':'e8b86039-f850-4e53-bd9d-f8c9186a9637'}, {'body':'an actual post-mod comment here', 'status_history':[], 'asset_id':'96fddf96-7c83-4008-80ad-50091997d006', 'created_at':'2016-12-08T22:20:11.147Z', 'author_id':'92256159-1164-4f66-9970-c7f23de7e461', 'status':null, '__v':0, 'updated_at':'2016-12-08T22:20:11.147Z', 'id':'cff1a318-50c6-431e-9a63-de7a7b7136bf'}]; - const asset = { - 'settings': null, - 'created_at':'2016-12-06T21:36:09.302Z', - 'url':'localhost:3000/', - 'scraped':null, - 'status':'open', - 'updated_at':'2016-12-08T02:11:15.943Z', - '_id':'58472f499e775a38f23d5da0', - 'type':'article', - 'closedMessage':null, - 'id':'7302e637-f884-47c0-9723-02cc10a18617', - 'closedAt':null - }; - - comments.forEach((comment) => { - comment.asset = asset; - }); - - beforeEach(() => { - render = shallow({}}/>); - }); - - it('should render Comments as children when given comments and assets', () => { - const wrapper = mount({}}/>); - expect(wrapper.find('.commentHistory__list').children()).to.have.length(7); - }); - - it('should render with styles', () => { - expect(render.props().style).to.be.defined; - }); -}); From 0bae6fe76c36e1af18ce0828f7a32338e838efdd Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Wed, 22 Mar 2017 17:06:41 -0300 Subject: [PATCH 06/14] design tweaks --- client/coral-embed-stream/src/Comment.css | 3 ++- client/coral-embed-stream/src/LoadMore.js | 17 +++++++++-------- client/coral-embed-stream/style/default.css | 11 ++++++++--- client/coral-framework/translations.json | 4 ++-- 4 files changed, 21 insertions(+), 14 deletions(-) diff --git a/client/coral-embed-stream/src/Comment.css b/client/coral-embed-stream/src/Comment.css index 6966d82abb..01022ae66a 100644 --- a/client/coral-embed-stream/src/Comment.css +++ b/client/coral-embed-stream/src/Comment.css @@ -1,9 +1,10 @@ .Reply { position: relative; + margin-bottom: 15px; } .Comment { - + margin-bottom: 15px; } .pendingComment { diff --git a/client/coral-embed-stream/src/LoadMore.js b/client/coral-embed-stream/src/LoadMore.js index 942a53b279..89dc0104c2 100644 --- a/client/coral-embed-stream/src/LoadMore.js +++ b/client/coral-embed-stream/src/LoadMore.js @@ -44,14 +44,15 @@ class LoadMore extends React.Component { render () { const {assetId, comments, loadMore, moreComments, parentId, replyCount, topLevel} = this.props; return moreComments - ? + ?
+ +
: null; } } diff --git a/client/coral-embed-stream/style/default.css b/client/coral-embed-stream/style/default.css index 629efd29fd..4c427543ee 100644 --- a/client/coral-embed-stream/style/default.css +++ b/client/coral-embed-stream/style/default.css @@ -212,6 +212,7 @@ hr { .coral-plugin-commentcontent-text { margin-bottom: 7px; + font-size: 16px; } .coral-plugin-author-name-text { @@ -417,8 +418,11 @@ button.comment__action-button[disabled], /* Load More */ -button.coral-load-more { - width: 100%; +.coral-load-more { + text-align: center; +} + +.coral-load-more button { text-align: center; color: #FFF; background-color: #2376D8; @@ -427,9 +431,10 @@ button.coral-load-more { border-radius: 2px; line-height: 1em; text-transform: capitalize; + display: inline-block; } -button.coral-load-more:hover { +.coral-load-more:hover button { background-color: #4399FF; } diff --git a/client/coral-framework/translations.json b/client/coral-framework/translations.json index b327a70974..e37d92bfcd 100644 --- a/client/coral-framework/translations.json +++ b/client/coral-framework/translations.json @@ -15,7 +15,7 @@ "viewReply": "view reply", "viewAllRepliesInitial": "view all {0} replies", "viewAllReplies": "view {0} replies", - "newCount": "View {0} more {1}", + "newCount": "View {0} new {1}", "comment": "comment", "comments": "comments", "error": { @@ -46,7 +46,7 @@ "contentNotAvailable": "El contenido no se encuentra disponible", "bannedAccountMsg": "Tu cuenta se encuentra suspendida. Esto significa que no puedes dar Like, Marcar o escribir commentarios.", "editNameMsg": "", - "viewMoreComments": "Var commentarios más", + "viewMoreComments": "Ver commentarios más", "viewReply": "ver respuesta", "viewAllRepliesInitial": "ver todas las {0} respuestas", "viewAllReplies": "ver {0} respuestas", From fb2f8ef07485a1532e99772ac9d4ec6cd31a61f2 Mon Sep 17 00:00:00 2001 From: Riley Davis Date: Wed, 22 Mar 2017 16:48:28 -0600 Subject: [PATCH 07/14] redirect to the parent url when resetting your password --- client/coral-framework/actions/auth.js | 4 +++- routes/admin/index.js | 2 +- routes/api/account/index.js | 12 ++++++------ services/users.js | 7 +++++-- views/admin/password-reset.ejs | 2 +- 5 files changed, 16 insertions(+), 11 deletions(-) diff --git a/client/coral-framework/actions/auth.js b/client/coral-framework/actions/auth.js index 9dedaa2f2d..2a0c2a4973 100644 --- a/client/coral-framework/actions/auth.js +++ b/client/coral-framework/actions/auth.js @@ -3,6 +3,7 @@ import translations from './../translations'; const lang = new I18n(translations); import * as actions from '../constants/auth'; import coralApi, {base} from '../helpers/response'; +import {pym} from 'coral-framework'; // Dialog Actions export const showSignInDialog = (offset = 0) => ({type: actions.SHOW_SIGNIN_DIALOG, offset}); @@ -135,7 +136,8 @@ const forgotPassowordFailure = () => ({type: actions.FETCH_FORGOT_PASSWORD_FAILU export const fetchForgotPassword = email => (dispatch) => { dispatch(forgotPassowordRequest(email)); - coralApi('/account/password/reset', {method: 'POST', body: {email}}) + const redirectUri = pym.parentUrl || location.href; + coralApi('/account/password/reset', {method: 'POST', body: {email, loc: redirectUri}}) .then(() => dispatch(forgotPassowordSuccess())) .catch(error => dispatch(forgotPassowordFailure(error))); }; diff --git a/routes/admin/index.js b/routes/admin/index.js index d250ea32a6..1a97695915 100644 --- a/routes/admin/index.js +++ b/routes/admin/index.js @@ -12,7 +12,7 @@ router.get('/password-reset', (req, res) => { // TODO: store the redirect uri in the token or something fancy. // admins and regular users should probably be redirected to different places. - res.render('admin/password-reset', {redirectUri: process.env.TALK_ROOT_URL}); + res.render('admin/password-reset'); }); router.get('*', (req, res) => { diff --git a/routes/api/account/index.js b/routes/api/account/index.js index 44b4b39534..3761aef95d 100644 --- a/routes/api/account/index.js +++ b/routes/api/account/index.js @@ -41,14 +41,14 @@ router.post('/email/verify', (req, res, next) => { * if it does, create a JWT and send an email */ router.post('/password/reset', (req, res, next) => { - const {email} = req.body; + const {email, loc} = req.body; if (!email) { return next('you must submit an email when requesting a password.'); } UsersService - .createPasswordResetToken(email) + .createPasswordResetToken(email, loc) .then((token) => { // Check to see if the token isn't defined. @@ -101,11 +101,11 @@ router.put('/password/reset', (req, res, next) => { UsersService .verifyPasswordResetToken(token) - .then((user) => { - return UsersService.changePassword(user.id, password); + .then(([user, loc]) => { + return Promise.all([UsersService.changePassword(user.id, password), loc]); }) - .then(() => { - res.status(204).end(); + .then(([_, loc]) => { + res.json({redirect: loc}); }) .catch(() => { next(authorization.ErrNotAuthorized); diff --git a/services/users.js b/services/users.js index 4e11962522..7f83da9f96 100644 --- a/services/users.js +++ b/services/users.js @@ -524,7 +524,7 @@ module.exports = class UsersService { * Creates a JWT from a user email. Only works for local accounts. * @param {String} email of the local user */ - static createPasswordResetToken(email) { + static createPasswordResetToken(email, loc) { if (!email || typeof email !== 'string') { return Promise.reject('email is required when creating a JWT for resetting passord'); } @@ -544,6 +544,7 @@ module.exports = class UsersService { const payload = { jti: uuid.v4(), email, + loc, userId: user.id, version: user.__v }; @@ -588,7 +589,9 @@ module.exports = class UsersService { }) // TODO: add search by __v as well - .then((decoded) => UsersService.findById(decoded.userId)); + .then((decoded) => { + return Promise.all([UsersService.findById(decoded.userId), decoded.loc]); + }); } /** diff --git a/views/admin/password-reset.ejs b/views/admin/password-reset.ejs index 06b9d2a869..4b25d1279f 100644 --- a/views/admin/password-reset.ejs +++ b/views/admin/password-reset.ejs @@ -126,7 +126,7 @@ }, data: JSON.stringify({password: password, token: location.hash.replace('#', '')}) }).then(function (success) { - location.href = '<%= redirectUri %>'; + location.href = success.redirect; }).catch(function (error) { showError(error.responseText); }); From 4b0d0fed534ef90c19846bdd573ca8e7171cb374 Mon Sep 17 00:00:00 2001 From: Riley Davis Date: Wed, 22 Mar 2017 17:10:11 -0600 Subject: [PATCH 08/14] unused variable --- routes/api/account/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routes/api/account/index.js b/routes/api/account/index.js index 3761aef95d..e1c73d6385 100644 --- a/routes/api/account/index.js +++ b/routes/api/account/index.js @@ -104,7 +104,7 @@ router.put('/password/reset', (req, res, next) => { .then(([user, loc]) => { return Promise.all([UsersService.changePassword(user.id, password), loc]); }) - .then(([_, loc]) => { + .then(([ , loc]) => { res.json({redirect: loc}); }) .catch(() => { From 464539d6a321ff50979f276818b07466e8230db0 Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Thu, 23 Mar 2017 09:50:18 -0300 Subject: [PATCH 09/14] missing tab name --- client/coral-embed-stream/src/Embed.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/coral-embed-stream/src/Embed.js b/client/coral-embed-stream/src/Embed.js index 4722a44b1d..e9ed0511b2 100644 --- a/client/coral-embed-stream/src/Embed.js +++ b/client/coral-embed-stream/src/Embed.js @@ -121,7 +121,7 @@ class Embed extends Component {
- {lang.t('profile')} + {lang.t('MY_COMMENTSg')} Configure Stream {loggedIn && this.props.logout().then(refetch)} changeTab={this.changeTab}/>} From 23833886bb59780e0a2996de092f1bbe463896f9 Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Thu, 23 Mar 2017 09:51:26 -0300 Subject: [PATCH 10/14] missing tab name --- client/coral-embed-stream/src/Embed.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/coral-embed-stream/src/Embed.js b/client/coral-embed-stream/src/Embed.js index e9ed0511b2..52fdf06f52 100644 --- a/client/coral-embed-stream/src/Embed.js +++ b/client/coral-embed-stream/src/Embed.js @@ -121,7 +121,7 @@ class Embed extends Component {
- {lang.t('MY_COMMENTSg')} + {lang.t('MY_COMMENTS')} Configure Stream {loggedIn && this.props.logout().then(refetch)} changeTab={this.changeTab}/>} From 903aa23f193b3d74b95c4205966bccead4111bed Mon Sep 17 00:00:00 2001 From: David Erwin Date: Thu, 23 Mar 2017 11:18:55 -0400 Subject: [PATCH 11/14] Revert "Story 138187767 - Moderate Flag User Names" --- .gitignore | 2 - client/coral-admin/src/AppRouter.js | 15 - client/coral-admin/src/actions/community.js | 29 +- client/coral-admin/src/components/Modal.js | 1 + .../SuspendUserModal.css} | 0 .../src/components/SuspendUserModal.js | 106 ++++++ client/coral-admin/src/components/User.js | 50 +++ client/coral-admin/src/constants/comments.js | 1 + client/coral-admin/src/constants/community.js | 10 - client/coral-admin/src/constants/users.js | 1 + .../src/containers/Community/Community.css | 230 ------------ .../Community/{People.js => Community.js} | 6 +- .../Community/CommunityContainer.js | 117 ++---- .../containers/Community/CommunityLayout.js | 9 - .../containers/Community/FlaggedAccounts.js | 45 --- .../src/containers/Community/Table.js | 2 +- .../Community/components/ActionButton.js | 24 -- .../Community/components/BanUserDialog.css | 164 --------- .../Community/components/BanUserDialog.js | 54 --- .../Community/components/CommunityMenu.js | 31 -- .../Community/components/SuspendUserDialog.js | 115 ------ .../containers/Community/components/User.js | 90 ----- .../Community/components/styles.css | 339 ------------------ .../ModerationQueue/components/Comment.js | 20 +- .../src/graphql/mutations/index.js | 32 +- .../src/graphql/mutations/suspendUser.graphql | 7 - .../coral-admin/src/graphql/queries/index.js | 3 - .../queries/modUserFlaggedQuery.graphql | 26 -- client/coral-admin/src/reducers/community.js | 72 ++-- client/coral-admin/src/translations.json | 51 +-- client/coral-plugin-flags/FlagComment.js | 4 +- graph/loaders/users.js | 41 --- graph/mutators/user.js | 30 +- graph/resolvers/flag_action.js | 12 +- graph/resolvers/root_mutation.js | 3 - graph/resolvers/root_query.js | 22 -- graph/typeDefs.graphql | 31 -- models/user.js | 5 +- services/email/suspension.ejs | 1 - services/email/suspension.txt.ejs | 1 - services/users.js | 46 --- test/graph/mutations/addCommentTag.js | 2 +- 42 files changed, 246 insertions(+), 1604 deletions(-) rename client/coral-admin/src/{containers/Community/components/SuspendUserDialog.css => components/SuspendUserModal.css} (100%) create mode 100644 client/coral-admin/src/components/SuspendUserModal.js create mode 100644 client/coral-admin/src/components/User.js rename client/coral-admin/src/containers/Community/{People.js => Community.js} (94%) delete mode 100644 client/coral-admin/src/containers/Community/CommunityLayout.js delete mode 100644 client/coral-admin/src/containers/Community/FlaggedAccounts.js delete mode 100644 client/coral-admin/src/containers/Community/components/ActionButton.js delete mode 100644 client/coral-admin/src/containers/Community/components/BanUserDialog.css delete mode 100644 client/coral-admin/src/containers/Community/components/BanUserDialog.js delete mode 100644 client/coral-admin/src/containers/Community/components/CommunityMenu.js delete mode 100644 client/coral-admin/src/containers/Community/components/SuspendUserDialog.js delete mode 100644 client/coral-admin/src/containers/Community/components/User.js delete mode 100644 client/coral-admin/src/containers/Community/components/styles.css delete mode 100644 client/coral-admin/src/graphql/mutations/suspendUser.graphql delete mode 100644 client/coral-admin/src/graphql/queries/modUserFlaggedQuery.graphql delete mode 100644 services/email/suspension.ejs delete mode 100644 services/email/suspension.txt.ejs diff --git a/.gitignore b/.gitignore index d91635c941..8775ac4879 100644 --- a/.gitignore +++ b/.gitignore @@ -12,8 +12,6 @@ dump.rdb *.cfg .idea/ coverage/ -.tags -.tags1 # remove plugin folders plugins diff --git a/client/coral-admin/src/AppRouter.js b/client/coral-admin/src/AppRouter.js index 2bd59b79d3..a2990677fe 100644 --- a/client/coral-admin/src/AppRouter.js +++ b/client/coral-admin/src/AppRouter.js @@ -5,13 +5,10 @@ import Stories from 'containers/Stories/Stories'; import Configure from 'containers/Configure/Configure'; import LayoutContainer from 'containers/LayoutContainer'; import InstallContainer from 'containers/Install/InstallContainer'; - -import CommunityLayout from 'containers/Community/CommunityLayout'; import CommunityContainer from 'containers/Community/CommunityContainer'; import ModerationLayout from 'containers/ModerationQueue/ModerationLayout'; import ModerationContainer from 'containers/ModerationQueue/ModerationContainer'; - import Dashboard from 'containers/Dashboard/Dashboard'; const routes = ( @@ -24,18 +21,6 @@ const routes = ( - {/* Community Routes */} - - - - - - - - - - - {/* Moderation Routes */} diff --git a/client/coral-admin/src/actions/community.js b/client/coral-admin/src/actions/community.js index 0f53ea3dab..c2d7384606 100644 --- a/client/coral-admin/src/actions/community.js +++ b/client/coral-admin/src/actions/community.js @@ -7,33 +7,28 @@ import { SORT_UPDATE, COMMENTERS_NEW_PAGE, SET_ROLE, - SET_COMMENTER_STATUS, - SHOW_BANUSER_DIALOG, - HIDE_BANUSER_DIALOG, - SHOW_SUSPENDUSER_DIALOG, - HIDE_SUSPENDUSER_DIALOG + SET_COMMENTER_STATUS } from '../constants/community'; import coralApi from '../../../coral-framework/helpers/response'; -export const fetchAccounts = (query = {}) => dispatch => { - - dispatch(requestFetchAccounts()); +export const fetchCommenters = (query = {}) => dispatch => { + dispatch(requestFetchCommenters()); coralApi(`/users?${qs.stringify(query)}`) - .then(({result, page, count, limit, totalPages}) =>{ + .then(({result, page, count, limit, totalPages}) => dispatch({ type: FETCH_COMMENTERS_SUCCESS, - accounts: result, + commenters: result, page, count, limit, totalPages - }); - }) + }) + ) .catch(error => dispatch({type: FETCH_COMMENTERS_FAILURE, error})); }; -const requestFetchAccounts = () => ({ +const requestFetchCommenters = () => ({ type: FETCH_COMMENTERS_REQUEST }); @@ -60,11 +55,3 @@ export const setCommenterStatus = (id, status) => (dispatch) => { return dispatch({type: SET_COMMENTER_STATUS, id, status}); }); }; - -// Ban User Dialog -export const showBanUserDialog = (user) => ({type: SHOW_BANUSER_DIALOG, user}); -export const hideBanUserDialog = () => ({type: HIDE_BANUSER_DIALOG}); - -// Suspend User Dialog -export const showSuspendUserDialog = (user) => ({type: SHOW_SUSPENDUSER_DIALOG, user}); -export const hideSuspendUserDialog = () => ({type: HIDE_SUSPENDUSER_DIALOG}); diff --git a/client/coral-admin/src/components/Modal.js b/client/coral-admin/src/components/Modal.js index b667258c29..99c27c3a17 100644 --- a/client/coral-admin/src/components/Modal.js +++ b/client/coral-admin/src/components/Modal.js @@ -1,3 +1,4 @@ + import React from 'react'; import {Button, Icon} from 'react-mdl'; import styles from './Modal.css'; diff --git a/client/coral-admin/src/containers/Community/components/SuspendUserDialog.css b/client/coral-admin/src/components/SuspendUserModal.css similarity index 100% rename from client/coral-admin/src/containers/Community/components/SuspendUserDialog.css rename to client/coral-admin/src/components/SuspendUserModal.css diff --git a/client/coral-admin/src/components/SuspendUserModal.js b/client/coral-admin/src/components/SuspendUserModal.js new file mode 100644 index 0000000000..5afb8ffee4 --- /dev/null +++ b/client/coral-admin/src/components/SuspendUserModal.js @@ -0,0 +1,106 @@ +import I18n from 'coral-framework/modules/i18n/i18n'; +import translations from '../translations.json'; +import React, {Component, PropTypes} from 'react'; +import Modal from 'components/Modal'; +import styles from './SuspendUserModal.css'; +import {Button} from 'coral-ui'; + +const stages = [ + { + title: 'suspenduser.title_0', + description: 'suspenduser.description_0', + options: { + 'j': 'suspenduser.no_cancel', + 'k': 'suspenduser.yes_suspend' + } + }, + { + title: 'suspenduser.title_1', + description: 'suspenduser.description_1', + options: { + 'j': 'bandialog.cancel', + 'k': 'suspenduser.send' + } + } +]; + +class SuspendUserModal extends Component { + + state = {email: '', stage: 0} + + static propTypes = { + stage: PropTypes.number, + actionType: PropTypes.string, + onClose: PropTypes.func.isRequired, + suspendUser: PropTypes.func.isRequired + } + + componentDidMount() { + const about = lang.t('suspenduser.username'); + this.setState({email: lang.t('suspenduser.email', about)}); + } + + /* + * When an admin clicks to suspend a user a dialog is shown, this function + * handles the possible actions for that dialog. + */ + onActionClick = (stage, menuOption) => () => { + const {suspendUser, action} = this.props; + const {stage, email} = this.state; + const cancel = this.props.onClose; + const next = () => this.setState({stage: stage + 1}); + const suspend = () => suspendUser(action.item_id, lang.t('suspenduser.email_subject'), email) + .then(this.props.onClose); + const suspendModalActions = [ + [ cancel, next ], + [ cancel, suspend ] + ]; + return suspendModalActions[stage][menuOption](); + } + + onEmailChange = (e) => this.setState({email: e.target.value}) + + render () { + const {action, onClose} = this.props; + + if (!action) { + return null; + } + + const {stage} = this.state; + const actionType = action.actionType; + const about = actionType === 'flag_bio' ? lang.t('suspenduser.bio') : lang.t('suspenduser.username'); + return +
{lang.t(stages[stage].title, about)}
+
+
+ {lang.t(stages[stage].description, about)} +
+ { + stage === 1 && +
+
{lang.t('suspenduser.write_message')}
+
+