From 787486bccf80c68cc99e66b993b69058de3b9eb6 Mon Sep 17 00:00:00 2001 From: David Jay Date: Fri, 9 Dec 2016 17:46:45 -0500 Subject: [PATCH] Posting bio flags to backend. --- .../coral-embed-stream/src/CommentStream.js | 12 ++++++- client/coral-embed-stream/style/default.css | 12 +++++-- client/coral-plugin-author-name/AuthorName.js | 11 +++++- client/coral-plugin-flags/FlagBio.js | 35 +++++++++++++++++++ client/coral-plugin-flags/FlagButton.js | 13 +++++-- client/coral-plugin-flags/translations.json | 4 +++ models/user.js | 2 +- 7 files changed, 82 insertions(+), 7 deletions(-) diff --git a/client/coral-embed-stream/src/CommentStream.js b/client/coral-embed-stream/src/CommentStream.js index c3a5a0264..7ec042ea1 100644 --- a/client/coral-embed-stream/src/CommentStream.js +++ b/client/coral-embed-stream/src/CommentStream.js @@ -139,7 +139,17 @@ class CommentStream extends Component { const comment = comments[commentId]; return

- +
diff --git a/client/coral-embed-stream/style/default.css b/client/coral-embed-stream/style/default.css index 13c7c205e..c27baf406 100644 --- a/client/coral-embed-stream/style/default.css +++ b/client/coral-embed-stream/style/default.css @@ -127,6 +127,10 @@ hr { font-weight: bolder; } +.coral-plugin-author-name-bio-flag { + float: right; +} + /* Reply styles */ @@ -199,10 +203,14 @@ hr { /* Flag Styles */ +.coral-plugin-flags-container { + position: relative; +} + .coral-plugin-flags-popup span { - min-width: 100px; + min-width: 280px; bottom: 36px; - right: 75px; + left: -190px; position: absolute; } diff --git a/client/coral-plugin-author-name/AuthorName.js b/client/coral-plugin-author-name/AuthorName.js index 56b868726..bf970b3c4 100644 --- a/client/coral-plugin-author-name/AuthorName.js +++ b/client/coral-plugin-author-name/AuthorName.js @@ -1,5 +1,6 @@ import React, {Component} from 'react'; import {Tooltip} from 'coral-ui'; +import FlagBio from '../coral-plugin-flags/FlagBio'; const packagename = 'coral-plugin-author-name'; export default class AuthorName extends Component { @@ -36,7 +37,15 @@ export default class AuthorName extends Component { onMouseLeave={this.handleMouseLeave} > {author && author.displayName} - { showTooltip && {author.settings.bio}} + { showTooltip && +
+ {author.settings.bio} +
+
+ +
+
+ }
); } diff --git a/client/coral-plugin-flags/FlagBio.js b/client/coral-plugin-flags/FlagBio.js index e69de29bb..90cc11a7a 100644 --- a/client/coral-plugin-flags/FlagBio.js +++ b/client/coral-plugin-flags/FlagBio.js @@ -0,0 +1,35 @@ +import React from 'react'; +import FlagButton from './FlagButton'; +import {I18n} from '../coral-framework'; +import translations from './translations.json'; + +const FlagBio = (props) => ; + +const getPopupMenu = [ + () => { + return { + header: lang.t('step-2-header'), + itemType: 'user', + field: 'bio', + options: [ + {val: 'This bio is offensive', text: lang.t('bio-offensive')}, + {val: 'I don\'t like this bio', text: lang.t('no-like-bio')}, + {val: 'This looks like an ad/marketing', text: lang.t('marketing')}, + {val: 'other', text: lang.t('other')} + ], + button: lang.t('continue'), + sets: 'detail' + }; + }, + () => { + return { + header: lang.t('step-3-header'), + text: lang.t('thank-you'), + button: lang.t('done'), + }; + } +]; + +export default FlagBio; + +const lang = new I18n(translations); diff --git a/client/coral-plugin-flags/FlagButton.js b/client/coral-plugin-flags/FlagButton.js index 5d8f6c0c2..d0b9cb6b4 100644 --- a/client/coral-plugin-flags/FlagButton.js +++ b/client/coral-plugin-flags/FlagButton.js @@ -33,7 +33,7 @@ class FlagButton extends Component { const {itemType, field, detail, step, otherText, posted} = this.state; //Proceed to the next step or close the menu if we've reached the end - if (step + 1 >= this.getPopupMenu.length) { + if (step + 1 >= this.props.getPopupMenu.length) { this.setState({showMenu: false}); } else { this.setState({step: step + 1}); @@ -79,6 +79,15 @@ class FlagButton extends Component { this.setState({field: 'username'}); } + // Set itemType and field if they are defined in the popupMenu + const currentMenu = this.props.getPopupMenu[this.state.step](); + if (currentMenu.itemType) { + this.setState({itemType: currentMenu.itemType}); + } + if (currentMenu.field) { + this.setState({field: currentMenu.field}); + } + this.setState({[sets]: e.target.value}); } @@ -147,7 +156,7 @@ class FlagButton extends Component { }
- {this.state.step + 1} of {this.getPopupMenu.length} + {this.state.step + 1} of {getPopupMenu.length}
{ popupMenu.button &&