From 6aaca9130aef5074e698cb493916e34f8ffc37e8 Mon Sep 17 00:00:00 2001 From: Riley Davis Date: Thu, 13 Apr 2017 12:56:48 -0600 Subject: [PATCH 01/37] saving my place --- .gitignore | 1 + .../ModerationQueue/components/Comment.js | 2 +- .../ModerationQueue/components/FlagBox.js | 34 +++++++++++++------ 3 files changed, 26 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index 8982613ac..c938dd984 100644 --- a/.gitignore +++ b/.gitignore @@ -17,4 +17,5 @@ coverage/ plugins.json plugins/* !plugins/coral-plugin-facebook-auth +**/node_modules/* !plugins/coral-plugin-respect diff --git a/client/coral-admin/src/containers/ModerationQueue/components/Comment.js b/client/coral-admin/src/containers/ModerationQueue/components/Comment.js index a2bbbf092..f125460fa 100644 --- a/client/coral-admin/src/containers/ModerationQueue/components/Comment.js +++ b/client/coral-admin/src/containers/ModerationQueue/components/Comment.js @@ -45,7 +45,7 @@ const Comment = ({actions = [], ...props}) => {
Story: {props.comment.asset.title} {!props.currentAsset && ( - Moderate → + Moderate → )}
diff --git a/client/coral-admin/src/containers/ModerationQueue/components/FlagBox.js b/client/coral-admin/src/containers/ModerationQueue/components/FlagBox.js index 00b7d4273..0006c182d 100644 --- a/client/coral-admin/src/containers/ModerationQueue/components/FlagBox.js +++ b/client/coral-admin/src/containers/ModerationQueue/components/FlagBox.js @@ -2,6 +2,11 @@ import React, {Component, PropTypes} from 'react'; import {Icon} from 'coral-ui'; import styles from './FlagBox.css'; +const shortReasons = { + 'This comment is offensive': 'Offensive', + 'This looks like an ad/marketing': 'Spam/Ads' +}; + class FlagBox extends Component { constructor () { super(); @@ -16,6 +21,13 @@ class FlagBox extends Component { })); } + reasonMap = (reason) => { + const shortReason = shortReasons[reason]; + + // if the short reason isn't found, just return the long one. + return shortReason ? shortReason : reason; + } + render() { const {props} = this; return ( @@ -23,19 +35,19 @@ class FlagBox extends Component {

Flags ({props.actionSummaries.length}):

-
    +
    {props.actionSummaries.map((action, i) => -
  • {!action.reason ? No reason provided : action.reason} ({action.count})
  • + {this.reasonMap(action.reason)} ({action.count}) )} -
- {/* More detail*/} +
+ More detail
{this.state.showDetail && (
-
    - {props.actionSummaries.map((action, i) => -
  • {!action.reason ? No reason provided : action.reason} ({action.count})
  • - )} -
+
    + {props.actionSummaries.map((action, i) => +
  • {this.reasonMap(action.reason)} ({action.count})
  • + )} +
)}
@@ -44,7 +56,9 @@ class FlagBox extends Component { } FlagBox.propTypes = { - actionSummaries: PropTypes.array.isRequired + actionSummaries: PropTypes.arrayOf(PropTypes.shape({ + + })).isRequired }; export default FlagBox; From ff3cffdc8f193729c3ffc8031ff737176658f935 Mon Sep 17 00:00:00 2001 From: Riley Davis Date: Fri, 14 Apr 2017 14:59:51 -0600 Subject: [PATCH 02/37] load actions --- .../ModerationQueue/components/Comment.js | 31 ++++++++++--------- .../ModerationQueue/components/FlagBox.js | 3 ++ .../src/graphql/fragments/commentView.graphql | 6 ++++ 3 files changed, 26 insertions(+), 14 deletions(-) diff --git a/client/coral-admin/src/containers/ModerationQueue/components/Comment.js b/client/coral-admin/src/containers/ModerationQueue/components/Comment.js index f125460fa..6a4b8d36b 100644 --- a/client/coral-admin/src/containers/ModerationQueue/components/Comment.js +++ b/client/coral-admin/src/containers/ModerationQueue/components/Comment.js @@ -17,25 +17,27 @@ import I18n from 'coral-framework/modules/i18n/i18n'; import translations from 'coral-admin/src/translations.json'; const lang = new I18n(translations); -const Comment = ({actions = [], ...props}) => { - const links = linkify.getMatches(props.comment.body); +const Comment = ({actions = [], comment, ...props}) => { + const links = linkify.getMatches(comment.body); const linkText = links ? links.map(link => link.raw) : []; - const actionSummaries = props.comment.action_summaries; + const actionSummaries = comment.action_summaries; + const flagActions = comment.actions.filter(a => a.__typename === 'FlagAction'); + return (
  • - {props.comment.user.name} + {comment.user.name} - {timeago().format(props.comment.created_at || (Date.now() - props.index * 60 * 1000), lang.getLocale().replace('-', '_'))} + {timeago().format(comment.created_at || (Date.now() - props.index * 60 * 1000), lang.getLocale().replace('-', '_'))} - props.showBanUserDialog(props.comment.user, props.comment.id, props.comment.status !== 'REJECTED')} /> + props.showBanUserDialog(comment.user, comment.id, comment.status !== 'REJECTED')} />
    - {props.comment.user.status === 'banned' ? + {comment.user.status === 'banned' ? {lang.t('comment.banned_user')} @@ -43,16 +45,16 @@ const Comment = ({actions = [], ...props}) => { : null}
    - Story: {props.comment.asset.title} + Story: {comment.asset.title} {!props.currentAsset && ( - Moderate → + Moderate → )}

    + textToHighlight={comment.body} />

    {links ? Contains Link : null} @@ -60,16 +62,16 @@ const Comment = ({actions = [], ...props}) => { {actions.map((action, i) => props.acceptComment({commentId: props.comment.id})} - rejectComment={() => props.rejectComment({commentId: props.comment.id})} + user={comment.user} + acceptComment={() => props.acceptComment({commentId: comment.id})} + rejectComment={() => props.rejectComment({commentId: comment.id})} /> )}
    - {actionSummaries && } + {flagActions && }
  • ); }; @@ -83,6 +85,7 @@ Comment.propTypes = { comment: PropTypes.shape({ body: PropTypes.string.isRequired, action_summaries: PropTypes.array, + actions: PropTypes.array, created_at: PropTypes.string.isRequired, user: PropTypes.shape({ status: PropTypes.string diff --git a/client/coral-admin/src/containers/ModerationQueue/components/FlagBox.js b/client/coral-admin/src/containers/ModerationQueue/components/FlagBox.js index 0006c182d..3b1843629 100644 --- a/client/coral-admin/src/containers/ModerationQueue/components/FlagBox.js +++ b/client/coral-admin/src/containers/ModerationQueue/components/FlagBox.js @@ -58,6 +58,9 @@ class FlagBox extends Component { FlagBox.propTypes = { actionSummaries: PropTypes.arrayOf(PropTypes.shape({ + })).isRequired, + flagActions: PropTypes.arrayOf(PropTypes.shape({ + })).isRequired }; diff --git a/client/coral-admin/src/graphql/fragments/commentView.graphql b/client/coral-admin/src/graphql/fragments/commentView.graphql index e78c28a28..36943602e 100644 --- a/client/coral-admin/src/graphql/fragments/commentView.graphql +++ b/client/coral-admin/src/graphql/fragments/commentView.graphql @@ -12,4 +12,10 @@ fragment commentView on Comment { id title } + actions { + ... on FlagAction { + reason + message + } + } } From d5ff9d3eeb1dbd8a6027bda80a6872d9a8e7e2fd Mon Sep 17 00:00:00 2001 From: Riley Davis Date: Fri, 14 Apr 2017 15:32:06 -0600 Subject: [PATCH 03/37] show the details --- .gitignore | 1 - .../ModerationQueue/components/Comment.js | 2 +- .../ModerationQueue/components/FlagBox.css | 14 ++++++ .../ModerationQueue/components/FlagBox.js | 49 +++++++++++++------ .../src/graphql/fragments/commentView.graphql | 3 ++ 5 files changed, 51 insertions(+), 18 deletions(-) diff --git a/.gitignore b/.gitignore index a160b7f6e..f4014b561 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,5 @@ coverage/ plugins.json plugins/* !plugins/coral-plugin-facebook-auth -**/node_modules/* !plugins/coral-plugin-respect **/node_modules/* diff --git a/client/coral-admin/src/containers/ModerationQueue/components/Comment.js b/client/coral-admin/src/containers/ModerationQueue/components/Comment.js index 6a4b8d36b..a31fbd313 100644 --- a/client/coral-admin/src/containers/ModerationQueue/components/Comment.js +++ b/client/coral-admin/src/containers/ModerationQueue/components/Comment.js @@ -20,7 +20,7 @@ const lang = new I18n(translations); const Comment = ({actions = [], comment, ...props}) => { const links = linkify.getMatches(comment.body); const linkText = links ? links.map(link => link.raw) : []; - const actionSummaries = comment.action_summaries; + const actionSummaries = comment.action_summaries.filter(a => a.__typename === 'FlagActionSummary'); const flagActions = comment.actions.filter(a => a.__typename === 'FlagAction'); return ( diff --git a/client/coral-admin/src/containers/ModerationQueue/components/FlagBox.css b/client/coral-admin/src/containers/ModerationQueue/components/FlagBox.css index fa7bb0cca..5b8ea4f91 100644 --- a/client/coral-admin/src/containers/ModerationQueue/components/FlagBox.css +++ b/client/coral-admin/src/containers/ModerationQueue/components/FlagBox.css @@ -53,3 +53,17 @@ font-size: 12px; } } + +.lessDetail { + display: inline-block; + margin-right: 10px; +} + +.subDetail { + font-weight: normal; + color: #888; + + span { + color: black; + } +} diff --git a/client/coral-admin/src/containers/ModerationQueue/components/FlagBox.js b/client/coral-admin/src/containers/ModerationQueue/components/FlagBox.js index 3b1843629..6068f76b5 100644 --- a/client/coral-admin/src/containers/ModerationQueue/components/FlagBox.js +++ b/client/coral-admin/src/containers/ModerationQueue/components/FlagBox.js @@ -4,7 +4,8 @@ import styles from './FlagBox.css'; const shortReasons = { 'This comment is offensive': 'Offensive', - 'This looks like an ad/marketing': 'Spam/Ads' + 'This looks like an ad/marketing': 'Spam/Ads', + 'Other': 'other' }; class FlagBox extends Component { @@ -29,26 +30,42 @@ class FlagBox extends Component { } render() { - const {props} = this; + const {actionSummaries, actions} = this.props; + const {showDetail} = this.state; + return (
    -

    Flags ({props.actionSummaries.length}):

    -
    - {props.actionSummaries.map((action, i) => - {this.reasonMap(action.reason)} ({action.count}) +

    Flags ({actionSummaries.length}):

    +
      + {actionSummaries.map((action, i) => +
    • {this.reasonMap(action.reason)} ({action.count})
    • )} -
    - More detail + + {showDetail ? 'Less' : 'More'} detail
    - {this.state.showDetail && (
    -
      - {props.actionSummaries.map((action, i) => -
    • {this.reasonMap(action.reason)} ({action.count})
    • - )} -
    -
    )} + {showDetail && ( +
    +
      + {actionSummaries.map((summary, i) => { + + const actionList = actions.filter(a => a.reason === summary.reason); + + return ( +
    • + {this.reasonMap(summary.reason)} ({summary.count}) +
        + { + actionList.map((action, j) =>
      • {action.user.username} {action.message}
      • ) + } +
      +
    • + ); + })} +
    +
    + )}
    ); @@ -59,7 +76,7 @@ FlagBox.propTypes = { actionSummaries: PropTypes.arrayOf(PropTypes.shape({ })).isRequired, - flagActions: PropTypes.arrayOf(PropTypes.shape({ + actions: PropTypes.arrayOf(PropTypes.shape({ })).isRequired }; diff --git a/client/coral-admin/src/graphql/fragments/commentView.graphql b/client/coral-admin/src/graphql/fragments/commentView.graphql index 36943602e..8c7310bdf 100644 --- a/client/coral-admin/src/graphql/fragments/commentView.graphql +++ b/client/coral-admin/src/graphql/fragments/commentView.graphql @@ -16,6 +16,9 @@ fragment commentView on Comment { ... on FlagAction { reason message + user { + username + } } } } From 55cdc983031eacfa9410a4e6a62093b3817fd400 Mon Sep 17 00:00:00 2001 From: Riley Davis Date: Fri, 14 Apr 2017 15:36:29 -0600 Subject: [PATCH 04/37] add some proptypes --- .../src/containers/ModerationQueue/components/FlagBox.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/client/coral-admin/src/containers/ModerationQueue/components/FlagBox.js b/client/coral-admin/src/containers/ModerationQueue/components/FlagBox.js index 6068f76b5..85623f62d 100644 --- a/client/coral-admin/src/containers/ModerationQueue/components/FlagBox.js +++ b/client/coral-admin/src/containers/ModerationQueue/components/FlagBox.js @@ -74,10 +74,12 @@ class FlagBox extends Component { FlagBox.propTypes = { actionSummaries: PropTypes.arrayOf(PropTypes.shape({ - + reason: PropTypes.string, + count: PropTypes.number })).isRequired, actions: PropTypes.arrayOf(PropTypes.shape({ - + message: PropTypes.string, + user: PropTypes.shape({username: PropTypes.string}) })).isRequired }; From cc6882168b00624646bddd9d9311c36a2165d2b4 Mon Sep 17 00:00:00 2001 From: Riley Davis Date: Mon, 17 Apr 2017 14:31:45 -0600 Subject: [PATCH 05/37] add translations --- .../ModerationQueue/components/FlagBox.js | 11 ++++++++--- client/coral-admin/src/translations.json | 14 ++++++++++++-- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/client/coral-admin/src/containers/ModerationQueue/components/FlagBox.js b/client/coral-admin/src/containers/ModerationQueue/components/FlagBox.js index 85623f62d..a7a8455b1 100644 --- a/client/coral-admin/src/containers/ModerationQueue/components/FlagBox.js +++ b/client/coral-admin/src/containers/ModerationQueue/components/FlagBox.js @@ -1,11 +1,16 @@ import React, {Component, PropTypes} from 'react'; import {Icon} from 'coral-ui'; import styles from './FlagBox.css'; +import I18n from 'coral-framework/modules/i18n/i18n'; +import translations from 'coral-admin/src/translations.json'; +const lang = new I18n(translations); const shortReasons = { - 'This comment is offensive': 'Offensive', - 'This looks like an ad/marketing': 'Spam/Ads', - 'Other': 'other' + 'This comment is offensive': lang.t('modqueue.offensive'), + 'This looks like an ad/marketing': lang.t('modqueue.spam/ads'), + 'This user is impersonating': lang.t('modqueue.impersonating'), + 'I don\'t like this username': lang.t('modqueue.dont-like-username'), + 'Other': lang.t('modqueue.other') }; class FlagBox extends Component { diff --git a/client/coral-admin/src/translations.json b/client/coral-admin/src/translations.json index 911411523..e062ccedb 100644 --- a/client/coral-admin/src/translations.json +++ b/client/coral-admin/src/translations.json @@ -51,7 +51,12 @@ "singleview": "Toggle single comment edit view", "thismenu": "Open this menu", "emptyqueue": "No more comments to moderate! You're all caught up. Go have some ☕️", - "showshortcuts": "Show Shortcuts" + "showshortcuts": "Show Shortcuts", + "dont-like-username": "Don't like username", + "impersonating": "Impersonating", + "offensive": "Offensive", + "spam/ads": "Spam/Ads", + "other": "Other" }, "comment": { "flagged": "flagged", @@ -221,7 +226,12 @@ "shortcuts": "Atajos de teclado", "close": "Cerrar", "emptyqueue": "No se encontro ningún usuario. Están escondidos.", - "showshortcuts": "Mostrar atajos" + "showshortcuts": "Mostrar atajos", + "dont-like-username": "No me gusta ese nombre de usuario", + "impersonating": "Suplantación", + "offensive": "Ofensivo", + "spam/ads": "Spam/Propaganda", + "other": "Otros" }, "comment": { "flagged": "marcado", From b5210f37270b4744b61abee838dd1c3273fad363 Mon Sep 17 00:00:00 2001 From: Riley Davis Date: Mon, 17 Apr 2017 14:42:18 -0600 Subject: [PATCH 06/37] more translations --- .../src/containers/ModerationQueue/components/FlagBox.js | 2 +- client/coral-admin/src/translations.json | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/client/coral-admin/src/containers/ModerationQueue/components/FlagBox.js b/client/coral-admin/src/containers/ModerationQueue/components/FlagBox.js index a7a8455b1..62b4e554d 100644 --- a/client/coral-admin/src/containers/ModerationQueue/components/FlagBox.js +++ b/client/coral-admin/src/containers/ModerationQueue/components/FlagBox.js @@ -48,7 +48,7 @@ class FlagBox extends Component {
  • {this.reasonMap(action.reason)} ({action.count})
  • )} - {showDetail ? 'Less' : 'More'} detail + {showDetail ? lang.t('modqueue.less-detail') : lang.t('modqueue.more-detail')} {showDetail && (
    diff --git a/client/coral-admin/src/translations.json b/client/coral-admin/src/translations.json index e062ccedb..f317b71a7 100644 --- a/client/coral-admin/src/translations.json +++ b/client/coral-admin/src/translations.json @@ -52,6 +52,8 @@ "thismenu": "Open this menu", "emptyqueue": "No more comments to moderate! You're all caught up. Go have some ☕️", "showshortcuts": "Show Shortcuts", + "more-detail": "More detail", + "less-detail": "Less detail", "dont-like-username": "Don't like username", "impersonating": "Impersonating", "offensive": "Offensive", @@ -227,6 +229,8 @@ "close": "Cerrar", "emptyqueue": "No se encontro ningún usuario. Están escondidos.", "showshortcuts": "Mostrar atajos", + "more-detail": "Mas detalle", + "less-detail": "Menos detalle", "dont-like-username": "No me gusta ese nombre de usuario", "impersonating": "Suplantación", "offensive": "Ofensivo", From 2eda1cb1e4bfe18835c4d2861fd667c1c12567d5 Mon Sep 17 00:00:00 2001 From: Wyatt Johnson Date: Tue, 18 Apr 2017 14:50:57 -0600 Subject: [PATCH 07/37] Added defaultResolveType --- graph/hooks.js | 108 ++++++++++++++++++++---------- graph/resolvers/action_summary.js | 2 +- graph/typeDefs.graphql | 36 ++++++++++ 3 files changed, 108 insertions(+), 38 deletions(-) diff --git a/graph/hooks.js b/graph/hooks.js index c5b7541b3..7f6be7feb 100644 --- a/graph/hooks.js +++ b/graph/hooks.js @@ -53,6 +53,71 @@ const forEachField = (schema, fn) => { }); }; +/** + * Decorates the field with the post resolvers (if available) and attaches a + * default type in the form of `Default${typeName}`. + */ +const decorateResolveFunction = (field, typeName, fieldName, post) => { + + // Cache the original resolverType function. + let resolveType = field.resolveType; + + // defaultResolveType is the default type that is resolved on a resolver + // when the interface being looked up is not defined. + const defaultResolveType = `Default${typeName}`; + + // Return the function to handle the resolveType hooks. + const defaultResolveFn = (obj, context, info) => { + let type = resolveType(obj, context, info); + + // Only if a previous resolver was unable to resolve the field type do we + // progress to the hooks (in order!) to resolve the field name until we + // have resolved it. + if (typeof type !== 'undefined' && type != null) { + return type; + } + + // All else fails, resort to the defaultResolveType. + return defaultResolveType; + }; + + // This only needs to do something if post hooks are defined. + if (post.length === 0) { + + // Set the default on the resolveType function. + field.resolveType = defaultResolveFn; + + return; + } + + // Ensure it matches the format we expect. + Joi.assert(post, Joi.array().items(Joi.func().maxArity(3)), `invalid post hooks were found for ${typeName}.${fieldName}`); + + // Return the function to handle the resolveType hooks. + field.resolveType = (obj, context, info) => { + let type = defaultResolveFn(obj, context, info); + + // Only if a previous resolver was unable to resolve the field type do we + // progress to the hooks (in order!) to resolve the field name until we + // have resolved it. + if (typeof type !== 'undefined' && type != null && type !== defaultResolveType) { + return type; + } + + // We will walk through the post hooks until we find the right one. This + // follows what redux does to combine existing reducers. + for (let i = 0; i < post.length; i++) { + let resolveType = post[i]; + let resolvedType = resolveType(obj, context, info); + if (typeof resolvedType !== 'undefined' && resolvedType != null) { + return resolvedType; + } + } + + return type; + }; +}; + /** * Decorates the schema with pre and post hooks as provided by the Plugin * Manager. @@ -115,11 +180,6 @@ const decorateWithHooks = (schema, hooks) => forEachField(schema, (field, typeNa post: [] }); - // If we have no hooks to add here, don't try to modify anything. - if (pre.length === 0 && post.length === 0) { - return; - } - // If this is a resolve type, we need to do some specific things to handle // this type of field. if (isResolveType) { @@ -129,39 +189,13 @@ const decorateWithHooks = (schema, hooks) => forEachField(schema, (field, typeNa throw new Error(`invalid pre hooks were found for ${typeName}.${fieldName}, only post hooks are supported on the __resolveType hook`); } - // This only needs to do something if post hooks are defined. - if (post.length === 0) { - return; - } - - // Ensure it matches the format we expect. - Joi.assert(post, Joi.array().items(Joi.func().maxArity(3)), `invalid post hooks were found for ${typeName}.${fieldName}`); - - // Cache the original resolverType function. - let resolveType = field.resolveType; - - // Return the function to handle the resolveType hooks. - field.resolveType = (obj, context, info) => { - let type = resolveType(obj, context, info); - - // Only if a previous resolver was unable to resolve the field type do we - // progress to the hooks (in order!) to resolve the field name until we - // have resolved it. - if (typeof type !== 'undefined' && type != null) { - return type; - } - - // We will walk through the post hooks until we find the right one. This - // follows what redux does to combine existing reducers. - for (let i = 0; i < post.length; i++) { - let resolveType = post[i]; - type = resolveType(obj, context, info); - if (typeof type !== 'undefined' && type != null) { - return type; - } - } - }; + // Decorate the resolve function on the field with the new resolveType func. + decorateResolveFunction(field, typeName, fieldName, post); + return; + } + // If we have no hooks to add here, don't try to modify anything. + if (pre.length === 0 && post.length === 0) { return; } diff --git a/graph/resolvers/action_summary.js b/graph/resolvers/action_summary.js index 1986a0648..ac2154de8 100644 --- a/graph/resolvers/action_summary.js +++ b/graph/resolvers/action_summary.js @@ -8,7 +8,7 @@ const ActionSummary = { case 'DONTAGREE': return 'DontAgreeActionSummary'; } - }, + } }; module.exports = ActionSummary; diff --git a/graph/typeDefs.graphql b/graph/typeDefs.graphql index 0a067b49c..96fceb30d 100644 --- a/graph/typeDefs.graphql +++ b/graph/typeDefs.graphql @@ -229,6 +229,22 @@ interface Action { created_at: Date } +# DefaultAction is the Action provided for undefined types. +type DefaultAction implements Action { + + # The ID of the action. + id: ID! + + # The author of the action. + user: User + + # The time when the Action was updated. + updated_at: Date + + # The time when the Action was created. + created_at: Date +} + # A summary of actions based on the specific grouping of the group_id. interface ActionSummary { @@ -239,6 +255,16 @@ interface ActionSummary { current_user: Action } +# DefaultActionSummary is the ActionSummary provided for undefined types. +type DefaultActionSummary implements ActionSummary { + + # The count of actions with this group. + count: Int + + # The current user's action. + current_user: Action +} + # A summary of actions for a specific action type on an Asset. interface AssetActionSummary { @@ -249,6 +275,16 @@ interface AssetActionSummary { actionableItemCount: Int } +# DefaultAssetActionSummary is the AssetActionSummary provided for undefined types. +type DefaultAssetActionSummary implements AssetActionSummary { + + # Number of actions associated with actionable types on this this Asset. + actionCount: Int + + # Number of unique actionable types that are referenced by the actions. + actionableItemCount: Int +} + # A summary of counts related to all the Flags on an Asset. type FlagAssetActionSummary implements AssetActionSummary { From 7698bdf930b80f1806c507a343613a4439f95b20 Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Wed, 19 Apr 2017 16:35:53 +0700 Subject: [PATCH 08/37] Fix load more in premod queue --- client/coral-admin/src/graphql/queries/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/coral-admin/src/graphql/queries/index.js b/client/coral-admin/src/graphql/queries/index.js index f0e8e5b70..7d03b5092 100644 --- a/client/coral-admin/src/graphql/queries/index.js +++ b/client/coral-admin/src/graphql/queries/index.js @@ -55,7 +55,7 @@ export const loadMore = (fetchMore) => ({limit, cursor, sort, tab, asset_id}) => statuses, asset_id }, - updateQuery: (oldData, {fetchMoreResult:{data:{comments}}}) => { + updateQuery: (oldData, {fetchMoreResult:{comments}}) => { return { ...oldData, [tab]: [ From f724353cf0b83f3ce9388ac4c3e83621d8cc221b Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Wed, 19 Apr 2017 16:38:02 +0700 Subject: [PATCH 09/37] Fix collapsing UI --- .../src/containers/ModerationQueue/ModerationContainer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/coral-admin/src/containers/ModerationQueue/ModerationContainer.js b/client/coral-admin/src/containers/ModerationQueue/ModerationContainer.js index 61352b921..3487f9fde 100644 --- a/client/coral-admin/src/containers/ModerationQueue/ModerationContainer.js +++ b/client/coral-admin/src/containers/ModerationQueue/ModerationContainer.js @@ -116,7 +116,7 @@ class ModerationContainer extends Component { let asset; - if (data.loading) { + if (!('premodCount' in data)) { return
    ; } From 9ddc6c35fdae3dae448826ac748adb3ccc9f0d5e Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Wed, 19 Apr 2017 11:59:07 -0300 Subject: [PATCH 10/37] Action labels default.css, temporary fix --- client/coral-embed-stream/style/default.css | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/client/coral-embed-stream/style/default.css b/client/coral-embed-stream/style/default.css index 51028949b..b99b109ac 100644 --- a/client/coral-embed-stream/style/default.css +++ b/client/coral-embed-stream/style/default.css @@ -475,3 +475,19 @@ button.comment__action-button[disabled], .coral-load-more-replies button.coral-load-more, .coral-new-comments button.coral-load-more{ width: initial; } + +@media (min-device-width : 300px) and (max-device-width : 420px) { + .commentActionsLeft.comment__action-container .coral-plugin-likes-button-text, + .commentActionsLeft.comment__action-container > div span { + display: none; + } + + .commentActionsLeft.comment__action-container .coral-plugin-replies-reply-button { + visibility: collapse; + margin-left: -30px; + } + + .commentActionsLeft.comment__action-container .coral-plugin-replies-reply-button .coral-plugin-replies-icon { + visibility: visible; + } +} \ No newline at end of file From 13965e11113a073c25315f16fa47af66dfe4d1b7 Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Wed, 19 Apr 2017 17:04:49 -0300 Subject: [PATCH 11/37] Adding actions, routes and login popup --- client/coral-admin/src/AppRouter.js | 3 +++ client/coral-embed-stream/src/AppRouter.js | 16 +++++++++++++++ client/coral-embed-stream/src/Embed.js | 20 ++++++++++++++----- client/coral-embed-stream/src/index.js | 4 ++-- client/coral-framework/actions/auth.js | 10 ++++++++++ .../containers/SignInContainer.js | 11 +++++----- 6 files changed, 51 insertions(+), 13 deletions(-) create mode 100644 client/coral-embed-stream/src/AppRouter.js diff --git a/client/coral-admin/src/AppRouter.js b/client/coral-admin/src/AppRouter.js index 2bd59b79d..2c0a3b9c5 100644 --- a/client/coral-admin/src/AppRouter.js +++ b/client/coral-admin/src/AppRouter.js @@ -14,6 +14,8 @@ import ModerationContainer from 'containers/ModerationQueue/ModerationContainer' import Dashboard from 'containers/Dashboard/Dashboard'; +import SignInContainer from 'coral-sign-in/containers/SignInContainer'; + const routes = (
    @@ -24,6 +26,7 @@ const routes = ( + {/* Community Routes */} diff --git a/client/coral-embed-stream/src/AppRouter.js b/client/coral-embed-stream/src/AppRouter.js new file mode 100644 index 000000000..133a3790d --- /dev/null +++ b/client/coral-embed-stream/src/AppRouter.js @@ -0,0 +1,16 @@ +import React from 'react'; +import {Router, Route, browserHistory} from 'react-router'; + +import Embed from './Embed'; +import SignInContainer from 'coral-sign-in/containers/SignInContainer'; + +const routes = ( +
    + + +
    +); + +const AppRouter = () => ; + +export default AppRouter; diff --git a/client/coral-embed-stream/src/Embed.js b/client/coral-embed-stream/src/Embed.js index b67e9e1c4..d864025e5 100644 --- a/client/coral-embed-stream/src/Embed.js +++ b/client/coral-embed-stream/src/Embed.js @@ -8,7 +8,7 @@ const lang = new I18n(translations); import {TabBar, Tab, TabContent, Spinner, Button} from 'coral-ui'; -const {logout, showSignInDialog, requestConfirmEmail} = authActions; +const {logout, showSignInDialog, requestConfirmEmail, signInPopUp} = authActions; const {addNotification, clearNotification} = notificationActions; const {fetchAssetSuccess} = assetActions; import {NEW_COMMENT_COUNT_POLL_INTERVAL} from 'coral-framework/constants/comments'; @@ -126,6 +126,16 @@ class Embed extends React.Component { } } + runPopUpLogin = () => { + // const newwindow = window.open( + // 'http://localhost:3000/embed/stream/login','Login','height=420,width=310,top=200,left=500'); + // if (window.focus) { + // newwindow.focus(); + // } + // return false; + this.props.signInPopUp(); + } + render () { const {activeTab} = this.state; const {closedAt, countCache = {}} = this.props.asset; @@ -218,10 +228,9 @@ class Embed extends React.Component {
    :

    {asset.settings.closedMessage}

    } - {!loggedIn && } + + + {loggedIn && user && } {loggedIn && } @@ -324,6 +333,7 @@ const mapDispatchToProps = dispatch => ({ updateCountCache: (id, count) => dispatch(updateCountCache(id, count)), viewAllComments: () => dispatch(viewAllComments()), logout: () => dispatch(logout()), + signInPopUp: () => dispatch(signInPopUp()), dispatch: d => dispatch(d), }); diff --git a/client/coral-embed-stream/src/index.js b/client/coral-embed-stream/src/index.js index 3dc69400c..15bb959fc 100644 --- a/client/coral-embed-stream/src/index.js +++ b/client/coral-embed-stream/src/index.js @@ -5,11 +5,11 @@ import {ApolloProvider} from 'react-apollo'; import {client} from 'coral-framework/services/client'; import store from 'coral-framework/services/store'; -import Embed from './Embed'; +import AppRouter from './AppRouter'; render( - + , document.querySelector('#coralStream') ); diff --git a/client/coral-framework/actions/auth.js b/client/coral-framework/actions/auth.js index 11e7bd996..dd90f6422 100644 --- a/client/coral-framework/actions/auth.js +++ b/client/coral-framework/actions/auth.js @@ -83,6 +83,16 @@ export const fetchSignIn = (formData) => (dispatch) => { }); }; +// Sign In - Standalone PopUp + +export const signInPopUp = () => () => { + window.open( + '/embed/stream/login', + 'Login', + 'menubar=0,resizable=0,width=500,height=500,top=200,left=500' + ); +}; + // Sign In - Facebook const signInFacebookRequest = () => ({type: actions.FETCH_SIGNIN_FACEBOOK_REQUEST}); diff --git a/client/coral-sign-in/containers/SignInContainer.js b/client/coral-sign-in/containers/SignInContainer.js index 0ef2b42b4..01a03e49c 100644 --- a/client/coral-sign-in/containers/SignInContainer.js +++ b/client/coral-sign-in/containers/SignInContainer.js @@ -147,8 +147,7 @@ class SignInContainer extends Component { handleSignIn(e) { e.preventDefault(); - this.props.fetchSignIn(this.state.formData) - .then(this.props.refetch); + this.props.fetchSignIn(this.state.formData); } render() { @@ -157,11 +156,11 @@ class SignInContainer extends Component { return (
    - {!noButton && } + {/*{!noButton && }*/} Date: Wed, 19 Apr 2017 18:10:09 -0300 Subject: [PATCH 12/37] Sign up popup --- client/coral-embed-stream/src/Embed.js | 28 ++++++++-------- client/coral-framework/actions/auth.js | 17 +++++----- .../coral-settings/components/NotLoggedIn.js | 7 ++-- .../containers/ProfileContainer.js | 32 ++++++++++++------- .../containers/SignInContainer.js | 3 -- 5 files changed, 46 insertions(+), 41 deletions(-) diff --git a/client/coral-embed-stream/src/Embed.js b/client/coral-embed-stream/src/Embed.js index d864025e5..62a33982d 100644 --- a/client/coral-embed-stream/src/Embed.js +++ b/client/coral-embed-stream/src/Embed.js @@ -8,7 +8,7 @@ const lang = new I18n(translations); import {TabBar, Tab, TabContent, Spinner, Button} from 'coral-ui'; -const {logout, showSignInDialog, requestConfirmEmail, signInPopUp} = authActions; +const {logout, showSignInDialog, requestConfirmEmail, openSignInPopUp, checkLogin} = authActions; const {addNotification, clearNotification} = notificationActions; const {fetchAssetSuccess} = assetActions; import {NEW_COMMENT_COUNT_POLL_INTERVAL} from 'coral-framework/constants/comments'; @@ -26,7 +26,6 @@ import {ModerationLink} from 'coral-plugin-moderation'; import Count from 'coral-plugin-comment-count/CommentCount'; import CommentBox from 'coral-plugin-commentbox/CommentBox'; import UserBox from 'coral-sign-in/components/UserBox'; -import SignInContainer from 'coral-sign-in/containers/SignInContainer'; import SuspendedAccount from 'coral-framework/components/SuspendedAccount'; import ChangeUsernameContainer from '../../coral-sign-in/containers/ChangeUsernameContainer'; import ProfileContainer from 'coral-settings/containers/ProfileContainer'; @@ -78,6 +77,7 @@ class Embed extends React.Component { componentDidMount () { pym.sendMessage('childReady'); + this.props.checkLogin(); } componentWillUnmount () { @@ -126,14 +126,14 @@ class Embed extends React.Component { } } - runPopUpLogin = () => { - // const newwindow = window.open( - // 'http://localhost:3000/embed/stream/login','Login','height=420,width=310,top=200,left=500'); - // if (window.focus) { - // newwindow.focus(); - // } - // return false; - this.props.signInPopUp(); + signIn = () => { + const {refetch} = this.props.data; + const {openSignInPopUp, checkLogin} = this.props; + + openSignInPopUp(() => { + checkLogin(); + refetch(); + }); } render () { @@ -229,9 +229,9 @@ class Embed extends React.Component { :

    {asset.settings.closedMessage}

    } - + {!loggedIn && } - {loggedIn && user && } + {loggedIn && user && } {loggedIn && } {/* the highlightedComment is isolated after the user followed a permalink */} @@ -299,7 +299,6 @@ class Embed extends React.Component { @@ -333,7 +332,8 @@ const mapDispatchToProps = dispatch => ({ updateCountCache: (id, count) => dispatch(updateCountCache(id, count)), viewAllComments: () => dispatch(viewAllComments()), logout: () => dispatch(logout()), - signInPopUp: () => dispatch(signInPopUp()), + openSignInPopUp: cb => dispatch(openSignInPopUp(cb)), + checkLogin: () => dispatch(checkLogin()), dispatch: d => dispatch(d), }); diff --git a/client/coral-framework/actions/auth.js b/client/coral-framework/actions/auth.js index dd90f6422..7fcbefd36 100644 --- a/client/coral-framework/actions/auth.js +++ b/client/coral-framework/actions/auth.js @@ -64,12 +64,7 @@ const signInFailure = error => ({type: actions.FETCH_SIGNIN_FAILURE, error}); export const fetchSignIn = (formData) => (dispatch) => { dispatch(signInRequest()); return coralApi('/auth/local', {method: 'POST', body: formData}) - .then(({user}) => { - const isAdmin = !!user && !!user.roles.filter(i => i === 'ADMIN').length; - dispatch(signInSuccess(user, isAdmin)); - dispatch(hideSignInDialog()); - fetchMe(); - }) + .then(() => dispatch(closeSignInPopUp())) .catch(error => { if (error.metadata) { @@ -85,12 +80,18 @@ export const fetchSignIn = (formData) => (dispatch) => { // Sign In - Standalone PopUp -export const signInPopUp = () => () => { - window.open( +export const openSignInPopUp = cb => () => { + const signInPopUp = window.open( '/embed/stream/login', 'Login', 'menubar=0,resizable=0,width=500,height=500,top=200,left=500' ); + + signInPopUp.onbeforeunload = cb; +}; + +export const closeSignInPopUp = () => () => { + window.close(); }; // Sign In - Facebook diff --git a/client/coral-settings/components/NotLoggedIn.js b/client/coral-settings/components/NotLoggedIn.js index c76553c50..4dfd49555 100644 --- a/client/coral-settings/components/NotLoggedIn.js +++ b/client/coral-settings/components/NotLoggedIn.js @@ -5,13 +5,10 @@ import translations from '../translations'; import I18n from 'coral-framework/modules/i18n/i18n'; const lang = new I18n(translations); -export default ({showSignInDialog, requireEmailConfirmation}) => ( +export default ({signIn}) => (
    -
    - { - showSignInDialog(); - }}>{lang.t('signIn')} {lang.t('toAccess')} + {lang.t('signIn')} {lang.t('toAccess')}
    {lang.t('fromSettingsPage')} diff --git a/client/coral-settings/containers/ProfileContainer.js b/client/coral-settings/containers/ProfileContainer.js index 2d756077d..7a26ed13e 100644 --- a/client/coral-settings/containers/ProfileContainer.js +++ b/client/coral-settings/containers/ProfileContainer.js @@ -2,6 +2,7 @@ import {connect} from 'react-redux'; import {compose} from 'react-apollo'; import React, {Component} from 'react'; import I18n from 'coral-framework/modules/i18n/i18n'; +import {bindActionCreators} from 'redux'; import {myCommentHistory, myIgnoredUsers} from 'coral-framework/graphql/queries'; import {stopIgnoringUser} from 'coral-framework/graphql/mutations'; @@ -12,6 +13,8 @@ import IgnoredUsers from '../components/IgnoredUsers'; import {Spinner} from 'coral-ui'; import CommentHistory from 'coral-plugin-history/CommentHistory'; +import {openSignInPopUp, checkLogin} from 'coral-framework/actions/auth'; + import translations from '../translations'; const lang = new I18n(translations); @@ -31,18 +34,28 @@ class ProfileContainer extends Component { }); } - render() { - const {loggedIn, asset, showSignInDialog, data, myIgnoredUsersData, stopIgnoringUser} = this.props; - const {me} = this.props.data; + signIn = () => { + const {refetch} = this.props.data; + const {openSignInPopUp, checkLogin} = this.props; - if (!loggedIn || !me) { - return ; - } + openSignInPopUp(() => { + checkLogin(); + refetch(); + }); + } + + render() { + const {loggedIn, asset, data, myIgnoredUsersData, stopIgnoringUser} = this.props; + const {me} = this.props.data; if (data.loading) { return ; } + if (!loggedIn || !me) { + return ; + } + const localProfile = this.props.user.profiles.find(p => p.provider === 'local'); const emailAddress = localProfile && localProfile.id; @@ -81,7 +94,6 @@ class ProfileContainer extends Component { :

    {lang.t('userNoComment')}

    } -
    ); } @@ -93,10 +105,8 @@ const mapStateToProps = state => ({ auth: state.auth.toJS() }); -const mapDispatchToProps = () => ({ - - // saveBio: (user_id, formData) => dispatch(saveBio(user_id, formData)) -}); +const mapDispatchToProps = dispatch => + bindActionCreators({openSignInPopUp, checkLogin}, dispatch); export default compose( connect(mapStateToProps, mapDispatchToProps), diff --git a/client/coral-sign-in/containers/SignInContainer.js b/client/coral-sign-in/containers/SignInContainer.js index 01a03e49c..5d8c828ae 100644 --- a/client/coral-sign-in/containers/SignInContainer.js +++ b/client/coral-sign-in/containers/SignInContainer.js @@ -156,9 +156,6 @@ class SignInContainer extends Component { return (
    - {/*{!noButton && }*/} Date: Wed, 19 Apr 2017 18:10:16 -0600 Subject: [PATCH 13/37] added --force to rebuild native modules --- Dockerfile.onbuild | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile.onbuild b/Dockerfile.onbuild index 34c321448..06d006b42 100644 --- a/Dockerfile.onbuild +++ b/Dockerfile.onbuild @@ -3,12 +3,12 @@ FROM coralproject/talk:latest # Bundle app source ONBUILD COPY . /usr/src/app -# At this stage, we need to install the development dependancies again because +# At this stage, we need to install the development dependancies again because # we need to have webpack available. We then build the new dependancies and # clear out the development dependancies again. After this we of course need to # clear out the yarn cache, this saves quite a lot of size. ONBUILD RUN NODE_ENV=development yarn install --frozen-lockfile && \ NODE_ENV=production cli plugins reconcile && \ NODE_ENV=production yarn build && \ - NODE_ENV=production yarn install --production && \ + NODE_ENV=production yarn install --production --force && \ yarn cache clean \ No newline at end of file From 59fbff3caf03315f0494f6aa66639e949e64b41d Mon Sep 17 00:00:00 2001 From: Riley Davis Date: Wed, 19 Apr 2017 21:15:03 -0600 Subject: [PATCH 14/37] fix how FlagActionSummaries works in the embed --- .../ModerationQueue/components/Comment.js | 11 +++-- client/coral-embed-stream/src/Comment.js | 23 +++++++--- client/coral-framework/utils/index.js | 43 ++++++++++++++++--- client/coral-plugin-flags/FlagButton.js | 10 ++--- client/coral-plugin-likes/LikeButton.js | 2 +- 5 files changed, 67 insertions(+), 22 deletions(-) diff --git a/client/coral-admin/src/containers/ModerationQueue/components/Comment.js b/client/coral-admin/src/containers/ModerationQueue/components/Comment.js index a31fbd313..b18f239e4 100644 --- a/client/coral-admin/src/containers/ModerationQueue/components/Comment.js +++ b/client/coral-admin/src/containers/ModerationQueue/components/Comment.js @@ -10,6 +10,7 @@ import FlagBox from './FlagBox'; import CommentType from './CommentType'; import ActionButton from 'coral-admin/src/components/ActionButton'; import BanUserButton from 'coral-admin/src/components/BanUserButton'; +import {getActionSummary} from 'coral-framework/utils'; const linkify = new Linkify(); @@ -20,8 +21,8 @@ const lang = new I18n(translations); const Comment = ({actions = [], comment, ...props}) => { const links = linkify.getMatches(comment.body); const linkText = links ? links.map(link => link.raw) : []; - const actionSummaries = comment.action_summaries.filter(a => a.__typename === 'FlagActionSummary'); - const flagActions = comment.actions.filter(a => a.__typename === 'FlagAction'); + const flagActionSummaries = getActionSummary('FlagActionSummary', comment); + const flagActions = comment.actions && comment.actions.filter(a => a.__typename === 'FlagAction'); return (
  • @@ -71,7 +72,11 @@ const Comment = ({actions = [], comment, ...props}) => {
  • - {flagActions && } + { + flagActions && flagActions.length + ? + : null + } ); }; diff --git a/client/coral-embed-stream/src/Comment.js b/client/coral-embed-stream/src/Comment.js index 4a75a19cb..01b038a8b 100644 --- a/client/coral-embed-stream/src/Comment.js +++ b/client/coral-embed-stream/src/Comment.js @@ -22,11 +22,10 @@ import LoadMore from 'coral-embed-stream/src/LoadMore'; import {Slot} from 'coral-framework'; import IgnoredCommentTombstone from './IgnoredCommentTombstone'; import {TopRightMenu} from './TopRightMenu'; +import {getActionSummary, getTotalActionCount, iPerformedThisAction} from 'coral-framework/utils'; import styles from './Comment.css'; -const getActionSummary = (type, comment) => comment.action_summaries - .filter((a) => a.__typename === type)[0]; const isStaff = (tags) => !tags.every((t) => t.name !== 'STAFF') ; // hold actions links (e.g. Like, Reply) along the comment footer @@ -124,9 +123,16 @@ class Comment extends React.Component { commentIsIgnored, } = this.props; - const like = getActionSummary('LikeActionSummary', comment); - const flag = getActionSummary('FlagActionSummary', comment); - const dontagree = getActionSummary('DontAgreeActionSummary', comment); + const likeSummary = getActionSummary('LikeActionSummary', comment); + const flagSummary = getActionSummary('FlagActionSummary', comment); + const dontagreeSummary = getActionSummary('DontAgreeActionSummary', comment); + let myFlag = null; + if (iPerformedThisAction('FlagActionSummary', comment)) { + myFlag = flagSummary.find(s => s.current_user); + } else if (iPerformedThisAction('DontAgreeActionSummary', comment)) { + myFlag = dontagreeSummary.find(s => s.current_user); + } + let commentClass = parentId ? `reply ${styles.Reply}` : `comment ${styles.Comment}`; commentClass += comment.id === 'pending' ? ` ${styles.pendingComment}` : ''; @@ -183,8 +189,10 @@ class Comment extends React.Component {
    + {/* TODO implmement iPerformedThisAction for the like */} { + if (!comment.action_summaries) { + return 0; + } -export const getActionSummary = (type, comment) => - comment.action_summaries.filter(a => a.__typename === type)[0]; + return comment.action_summaries.reduce((total, summary) => { + if (summary.__typename === type) { + return total + summary.count; + } else { + return total; + } + }, 0); +}; + +export const iPerformedThisAction = (type, comment) => { + if (!comment.action_summaries) { + return 0; + } + + // if there is a current_user on any of the ActionSummary(s), the user performed this action + return comment.action_summaries + .filter(a => a.__typename === type) + .some(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 + */ + +export const getActionSummary = (type, comment) => { + if (!comment.action_summaries) { + return null; + } + + return comment.action_summaries.filter(a => a.__typename === type); +}; diff --git a/client/coral-plugin-flags/FlagButton.js b/client/coral-plugin-flags/FlagButton.js index 45110f407..054ca2fb1 100644 --- a/client/coral-plugin-flags/FlagButton.js +++ b/client/coral-plugin-flags/FlagButton.js @@ -21,15 +21,15 @@ class FlagButton extends Component { // When the "report" button is clicked expand the menu onReportClick = () => { - const {currentUser, flag, deleteAction} = this.props; + const {currentUser, deleteAction, flaggedByCurrentUser, flag} = this.props; const {localPost, localDelete} = this.state; - const flagged = (flag && flag.current_user && !localDelete) || localPost; + const localFlagged = (flaggedByCurrentUser && !localDelete) || localPost; if (!currentUser) { const offset = document.getElementById(`c_${this.props.id}`).getBoundingClientRect().top - 75; this.props.showSignInDialog(offset); return; } - if (flagged) { + if (localFlagged) { this.setState((prev) => prev.localPost ? {...prev, localPost: null, step: 0} : {...prev, localDelete: true}); deleteAction(localPost || flag.current_user.id); } else if (this.state.showMenu){ @@ -130,9 +130,9 @@ class FlagButton extends Component { } render () { - const {flag, getPopupMenu} = this.props; + const {getPopupMenu, flaggedByCurrentUser} = this.props; const {localPost, localDelete} = this.state; - const flagged = (flag && flag.current_user && !localDelete) || localPost; + const flagged = (flaggedByCurrentUser && !localDelete) || localPost; const popupMenu = getPopupMenu[this.state.step](this.state.itemType); return
    diff --git a/client/coral-plugin-likes/LikeButton.js b/client/coral-plugin-likes/LikeButton.js index 51854c57f..8f6964051 100644 --- a/client/coral-plugin-likes/LikeButton.js +++ b/client/coral-plugin-likes/LikeButton.js @@ -27,9 +27,9 @@ class LikeButton extends Component { render() { const {like, id, postLike, deleteAction, showSignInDialog, currentUser} = this.props; + let {totalLikes: count} = this.props; const {localPost, localDelete} = this.state; const liked = (like && like.current_user && !localDelete) || localPost; - let count = like ? like.count : 0; if (localPost) {count += 1;} if (localDelete) {count -= 1;} From ffdec225c78bd63013f7138fc75d62d751ba2b70 Mon Sep 17 00:00:00 2001 From: Riley Davis Date: Wed, 19 Apr 2017 22:02:57 -0600 Subject: [PATCH 15/37] fix RespectButton component code --- client/coral-framework/utils/index.js | 22 ++++++++++----- .../client/components/RespectButton.js | 27 ++++++++++--------- 2 files changed, 30 insertions(+), 19 deletions(-) diff --git a/client/coral-framework/utils/index.js b/client/coral-framework/utils/index.js index 4ec6f8cab..93dcad027 100644 --- a/client/coral-framework/utils/index.js +++ b/client/coral-framework/utils/index.js @@ -3,18 +3,16 @@ export const getTotalActionCount = (type, comment) => { return 0; } - return comment.action_summaries.reduce((total, summary) => { - if (summary.__typename === type) { + return comment.action_summaries + .filter(s => s.__typename === type) + .reduce((total, summary) => { return total + summary.count; - } else { - return total; - } - }, 0); + }, 0); }; export const iPerformedThisAction = (type, comment) => { if (!comment.action_summaries) { - return 0; + return false; } // if there is a current_user on any of the ActionSummary(s), the user performed this action @@ -23,6 +21,16 @@ export const iPerformedThisAction = (type, comment) => { .some(a => a.current_user); }; +export const getMyActionSummary = (type, comment) => { + if (!comment.action_summaries) { + return null; + } + + return comment.action_summaries + .filter(a => a.__typename === type) + .find(a => a.current_user); +}; + /** * getActionSummary * retrieves the action summaries based on the type and the comment diff --git a/plugins/coral-plugin-respect/client/components/RespectButton.js b/plugins/coral-plugin-respect/client/components/RespectButton.js index 9e851460e..417b978ad 100644 --- a/plugins/coral-plugin-respect/client/components/RespectButton.js +++ b/plugins/coral-plugin-respect/client/components/RespectButton.js @@ -5,6 +5,7 @@ import Icon from './Icon'; import {I18n} from 'coral-framework'; import cn from 'classnames'; import translations from '../translations.json'; +import {getMyActionSummary, getTotalActionCount} from 'coral-framework/utils'; const lang = new I18n(translations); @@ -14,8 +15,7 @@ class RespectButton extends Component { const {postRespect, showSignInDialog, deleteAction, commentId} = this.props; const {me, comment} = this.props.data; - const respect = comment.action_summaries[0]; - const respected = (respect && respect.current_user); + const myRespectActionSummary = getMyActionSummary('RespectActionSummary', comment); // If the current user does not exist, trigger sign in dialog. if (!me) { @@ -29,29 +29,33 @@ class RespectButton extends Component { return; } - if (!respected) { + if (myRespectActionSummary) { + deleteAction(myRespectActionSummary.current_user.id); + } else { postRespect({ item_id: commentId, item_type: 'COMMENTS' }); - } else { - deleteAction(respect.current_user.id); } } render() { const {comment} = this.props.data; - const respect = comment && comment.action_summaries && comment.action_summaries[0]; - const respected = respect && respect.current_user; - let count = respect ? respect.count : 0; + + if (!comment) { + return null; + } + + const myRespect = getMyActionSummary('RespectActionSummary', comment); + let count = getTotalActionCount('RespectActionSummary', comment); return (
    @@ -64,4 +68,3 @@ RespectButton.propTypes = { }; export default RespectButton; - From 3bf218768835e7b9adc425883e43e63726c36450 Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Thu, 20 Apr 2017 18:45:55 +0700 Subject: [PATCH 16/37] Fix crashing admin when using framework --- client/coral-embed-stream/src/Comment.js | 2 +- client/coral-framework/index.js | 4 ---- client/coral-plugin-commentbox/CommentBox.js | 2 +- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/client/coral-embed-stream/src/Comment.js b/client/coral-embed-stream/src/Comment.js index 4a75a19cb..824008b2d 100644 --- a/client/coral-embed-stream/src/Comment.js +++ b/client/coral-embed-stream/src/Comment.js @@ -19,7 +19,7 @@ import FlagComment from 'coral-plugin-flags/FlagComment'; import LikeButton from 'coral-plugin-likes/LikeButton'; import {BestButton, IfUserCanModifyBest, BEST_TAG, commentIsBest, BestIndicator} from 'coral-plugin-best/BestButton'; import LoadMore from 'coral-embed-stream/src/LoadMore'; -import {Slot} from 'coral-framework'; +import Slot from 'coral-framework/components/Slot'; import IgnoredCommentTombstone from './IgnoredCommentTombstone'; import {TopRightMenu} from './TopRightMenu'; diff --git a/client/coral-framework/index.js b/client/coral-framework/index.js index 96750bffd..b85b69bcd 100644 --- a/client/coral-framework/index.js +++ b/client/coral-framework/index.js @@ -1,16 +1,12 @@ -import store from './services/store'; import pym from './services/PymConnection'; import I18n from './modules/i18n/i18n'; import actions from './actions'; -import Slot from './components/Slot'; // TODO (bc): Deprecate old actions. Spreading actions is now needed. export default { pym, - Slot, I18n, - store, actions, ...actions }; diff --git a/client/coral-plugin-commentbox/CommentBox.js b/client/coral-plugin-commentbox/CommentBox.js index f395b56c9..2a988711d 100644 --- a/client/coral-plugin-commentbox/CommentBox.js +++ b/client/coral-plugin-commentbox/CommentBox.js @@ -2,7 +2,7 @@ import React, {Component, PropTypes} from 'react'; import {I18n} from '../coral-framework'; import translations from './translations.json'; import {Button} from 'coral-ui'; -import {Slot} from 'coral-framework'; +import Slot from 'coral-framework/components/Slot'; import {connect} from 'react-redux'; const name = 'coral-plugin-commentbox'; From 1b95fbd8525b3722a8e2eb3aa96a635973c7b3f3 Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Thu, 20 Apr 2017 20:34:36 +0700 Subject: [PATCH 17/37] Remove SignInContainer from admin --- client/coral-admin/src/AppRouter.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/client/coral-admin/src/AppRouter.js b/client/coral-admin/src/AppRouter.js index 2c0a3b9c5..2bd59b79d 100644 --- a/client/coral-admin/src/AppRouter.js +++ b/client/coral-admin/src/AppRouter.js @@ -14,8 +14,6 @@ import ModerationContainer from 'containers/ModerationQueue/ModerationContainer' import Dashboard from 'containers/Dashboard/Dashboard'; -import SignInContainer from 'coral-sign-in/containers/SignInContainer'; - const routes = (
    @@ -26,7 +24,6 @@ const routes = ( - {/* Community Routes */} From 348c01ae80dc1c4ce1c33843de1fe530f10b8096 Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Thu, 20 Apr 2017 20:58:45 +0700 Subject: [PATCH 18/37] Fix linting errors --- client/coral-framework/actions/auth.js | 5 ++++- client/coral-settings/components/NotLoggedIn.js | 1 - client/coral-sign-in/containers/SignInContainer.js | 5 +---- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/client/coral-framework/actions/auth.js b/client/coral-framework/actions/auth.js index 7fcbefd36..0ec40d903 100644 --- a/client/coral-framework/actions/auth.js +++ b/client/coral-framework/actions/auth.js @@ -58,7 +58,10 @@ export const cleanState = () => ({type: actions.CLEAN_STATE}); // Sign In Actions const signInRequest = () => ({type: actions.FETCH_SIGNIN_REQUEST}); -const signInSuccess = (user, isAdmin) => ({type: actions.FETCH_SIGNIN_SUCCESS, user, isAdmin}); + +// TODO: revisit login redux flow. +// const signInSuccess = (user, isAdmin) => ({type: actions.FETCH_SIGNIN_SUCCESS, user, isAdmin}); +// const signInFailure = error => ({type: actions.FETCH_SIGNIN_FAILURE, error}); export const fetchSignIn = (formData) => (dispatch) => { diff --git a/client/coral-settings/components/NotLoggedIn.js b/client/coral-settings/components/NotLoggedIn.js index 4dfd49555..9fc43758e 100644 --- a/client/coral-settings/components/NotLoggedIn.js +++ b/client/coral-settings/components/NotLoggedIn.js @@ -1,6 +1,5 @@ import React from 'react'; import styles from './NotLoggedIn.css'; -import SignInContainer from '../../coral-sign-in/containers/SignInContainer'; import translations from '../translations'; import I18n from 'coral-framework/modules/i18n/i18n'; const lang = new I18n(translations); diff --git a/client/coral-sign-in/containers/SignInContainer.js b/client/coral-sign-in/containers/SignInContainer.js index 5d8c828ae..52a5e7d01 100644 --- a/client/coral-sign-in/containers/SignInContainer.js +++ b/client/coral-sign-in/containers/SignInContainer.js @@ -1,7 +1,6 @@ import React, {Component, PropTypes} from 'react'; import {connect} from 'react-redux'; import SignDialog from '../components/SignDialog'; -import Button from 'coral-ui/components/Button'; import validate from 'coral-framework/helpers/validate'; import errorMsj from 'coral-framework/helpers/error'; import I18n from 'coral-framework/modules/i18n/i18n'; @@ -13,7 +12,6 @@ import { changeView, fetchSignUp, fetchSignIn, - showSignInDialog, hideSignInDialog, fetchSignInFacebook, fetchSignUpFacebook, @@ -151,7 +149,7 @@ class SignInContainer extends Component { } render() { - const {auth, showSignInDialog, noButton, offset, requireEmailConfirmation} = this.props; + const {auth, offset, requireEmailConfirmation} = this.props; const {emailVerificationLoading, emailVerificationSuccess} = auth; return ( @@ -185,7 +183,6 @@ const mapDispatchToProps = dispatch => ({ fetchSignUpFacebook: () => dispatch(fetchSignUpFacebook()), fetchForgotPassword: formData => dispatch(fetchForgotPassword(formData)), requestConfirmEmail: (email, url) => dispatch(requestConfirmEmail(email, url)), - showSignInDialog: () => dispatch(showSignInDialog()), changeView: view => dispatch(changeView(view)), handleClose: () => dispatch(hideSignInDialog()), invalidForm: error => dispatch(invalidForm(error)), From b12d4ef4a21af033ff28de1c7105dabd2694e905 Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Thu, 20 Apr 2017 21:30:24 +0700 Subject: [PATCH 19/37] WIP --- client/coral-embed-stream/src/Embed.js | 12 +----------- client/coral-framework/actions/auth.js | 26 +++++++++++++++++++++++--- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/client/coral-embed-stream/src/Embed.js b/client/coral-embed-stream/src/Embed.js index 62a33982d..8335d38d2 100644 --- a/client/coral-embed-stream/src/Embed.js +++ b/client/coral-embed-stream/src/Embed.js @@ -126,16 +126,6 @@ class Embed extends React.Component { } } - signIn = () => { - const {refetch} = this.props.data; - const {openSignInPopUp, checkLogin} = this.props; - - openSignInPopUp(() => { - checkLogin(); - refetch(); - }); - } - render () { const {activeTab} = this.state; const {closedAt, countCache = {}} = this.props.asset; @@ -229,7 +219,7 @@ class Embed extends React.Component { :

    {asset.settings.closedMessage}

    } - {!loggedIn && } + {!loggedIn && } {loggedIn && user && } {loggedIn && } diff --git a/client/coral-framework/actions/auth.js b/client/coral-framework/actions/auth.js index 0ec40d903..199c98534 100644 --- a/client/coral-framework/actions/auth.js +++ b/client/coral-framework/actions/auth.js @@ -22,8 +22,20 @@ function fetchMe() { } // Dialog Actions -export const showSignInDialog = (offset = 0) => ({type: actions.SHOW_SIGNIN_DIALOG, offset}); -export const hideSignInDialog = () => ({type: actions.HIDE_SIGNIN_DIALOG}); +export const showSignInDialog = () => dispatch => { + const signInPopUp = window.open( + '/embed/stream/login', + 'Login', + 'menubar=0,resizable=0,width=500,height=500,top=200,left=500' + ); + + signInPopUp.onbeforeunload = fetchMe; + // ({type: actions.SHOW_SIGNIN_DIALOG, offset}) +}; +export const hideSignInDialog = () => dispatch => { + window.close(); + // ({type: actions.HIDE_SIGNIN_DIALOG}); +} export const createUsernameRequest = () => ({type: actions.CREATE_USERNAME_REQUEST}); export const showCreateUsernameDialog = () => ({type: actions.SHOW_CREATEUSERNAME_DIALOG}); @@ -47,11 +59,19 @@ export const createUsername = (userId, formData) => dispatch => { }); }; -export const changeView = view => dispatch => +export const changeView = view => dispatch => { + switch(view) { + case 'SIGNUP': + window.resizeTo(500, 700); + break; + default: + window.resizeTo(500, 500); + } dispatch({ type: actions.CHANGE_VIEW, view }); +}; export const cleanState = () => ({type: actions.CLEAN_STATE}); From 50219922d585a4281690c7f4d940a3ea7a4182fe Mon Sep 17 00:00:00 2001 From: Wyatt Johnson Date: Thu, 20 Apr 2017 09:35:32 -0600 Subject: [PATCH 20/37] Switched to lock at node 7.8 --- Dockerfile | 2 +- INSTALL.md | 4 ++-- package.json | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 90c08057f..73885d628 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM node:7.9 +FROM node:7.8 # Create app directory RUN mkdir -p /usr/src/app diff --git a/INSTALL.md b/INSTALL.md index 18244f635..49033acc8 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -174,8 +174,8 @@ and testing purposes. There are some runtime requirements for running Talk from source: -- [Node](https://nodejs.org/) v7.9 or later -- [Yarn](https://yarnpkg.com/) v0.22.0 or later +- [Node](https://nodejs.org/) ~7.8 +- [Yarn](https://yarnpkg.com/) ^0.22.0 _Please be sure to check the versions of these requirements. Incorrect versions of these may lead to unexpected errors!_ diff --git a/package.json b/package.json index 1b09c78c8..6c725a852 100644 --- a/package.json +++ b/package.json @@ -182,6 +182,6 @@ "webpack": "^2.3.1" }, "engines": { - "node": "^7.9.0" + "node": "^7.8.0" } } From eda15538fea12e78670bad25868633e9e325975d Mon Sep 17 00:00:00 2001 From: Riley Davis Date: Thu, 20 Apr 2017 10:02:09 -0600 Subject: [PATCH 21/37] add kiwi's and wyatt's changes --- graph/typeDefs.graphql | 6 +-- .../client/containers/RespectButton.js | 53 +++++++++++++------ services/actions.js | 10 +++- 3 files changed, 49 insertions(+), 20 deletions(-) diff --git a/graph/typeDefs.graphql b/graph/typeDefs.graphql index 0a067b49c..eb376b0de 100644 --- a/graph/typeDefs.graphql +++ b/graph/typeDefs.graphql @@ -31,7 +31,7 @@ type User { username: String! # Action summaries against the user. - action_summaries: [ActionSummary] + action_summaries: [ActionSummary]! # Actions completed on the parent. actions: [Action] @@ -197,7 +197,7 @@ type Comment { actions: [Action] # Action summaries against a comment. - action_summaries: [ActionSummary] + action_summaries: [ActionSummary]! # The asset that a comment was made on. asset: Asset @@ -440,7 +440,7 @@ type Asset { # Summary of all Actions against all entities associated with the Asset. # (likes, flags, etc.). Requires the `ADMIN` role. - action_summaries: [AssetActionSummary] + action_summaries: [AssetActionSummary!] # The date that the asset was created. created_at: Date diff --git a/plugins/coral-plugin-respect/client/containers/RespectButton.js b/plugins/coral-plugin-respect/client/containers/RespectButton.js index 047f7991f..bcf0e342d 100644 --- a/plugins/coral-plugin-respect/client/containers/RespectButton.js +++ b/plugins/coral-plugin-respect/client/containers/RespectButton.js @@ -10,6 +10,8 @@ import RespectButton from '../components/RespectButton'; // See https://dev-blog.apollodata.com/apollo-clients-new-imperative-store-api-6cb69318a1e3 // and https://github.com/apollographql/apollo-client/issues/1224 +const isRespectAction = (a) => a.__typename === 'RespectActionSummary'; + export const RESPECT_QUERY = gql` query RespectQuery($commentId: ID!) { comment(id: $commentId) { @@ -52,18 +54,21 @@ const withDeleteAction = graphql(gql` }, updateQueries: { RespectQuery: (prev) => { - if (get(prev, 'comment.action_summaries.0.current_user.id') !== id) { + const action_summaries = prev.comment.action_summaries; + const idx = action_summaries.findIndex(isRespectAction); + if (idx < 0 || get(action_summaries[idx], 'current_user.id') !== id) { return prev; } const next = { ...prev, comment: { ...prev.comment, - action_summaries: [{ - __typename: 'RespectActionSummary', - count: prev.comment.action_summaries[0].count - 1, - current_user: null, - }], + action_summaries: action_summaries.map( + (a, i) => i !== idx ? a : ({ + ...a, + count: a.count - 1, + current_user: null, + })), } }; return next; @@ -102,21 +107,40 @@ const withPostRespect = graphql(gql` }, updateQueries: { RespectQuery: (prev, {mutationResult, queryVariables}) => { - if (queryVariables.commentId !== respect.item_id || - get(prev, 'comment.action_summaries.0.current_user')) { + if (queryVariables.commentId !== respect.item_id) { return prev; } + + let action_summaries = prev.comment.action_summaries; + let idx = action_summaries.findIndex(isRespectAction); + + // Check whether we already respected this comment. + if (idx >= 0 && action_summaries[idx].current_user) { + return prev; + } + + if (idx < 0) { + + // Add initial action when it doesn't exist. + action_summaries = action_summaries.concat([{ + __typename: 'RespectActionSummary', + count: 0, + current_user: null, + }]); + idx = action_summaries.length - 1; + } + const respectAction = mutationResult.data.createRespect.respect; - const count = prev.comment.action_summaries[0] ? prev.comment.action_summaries[0].count : 0; const next = { ...prev, comment: { ...prev.comment, - action_summaries: [{ - __typename: 'RespectActionSummary', - count: count + 1, - current_user: respectAction, - }], + action_summaries: action_summaries.map( + (a, i) => i !== idx ? a : ({ + ...a, + count: a.count + 1, + current_user: respectAction, + })), } }; return next; @@ -138,4 +162,3 @@ const enhance = compose( ); export default enhance(RespectButton); - diff --git a/services/actions.js b/services/actions.js index 0bcb81af0..40bef65bb 100644 --- a/services/actions.js +++ b/services/actions.js @@ -48,10 +48,16 @@ module.exports = class ActionsService { * Finds actions in an array of ids. * @param {String} ids array of user identifiers (uuid) */ - static findByItemIdArray(item_ids) { - return ActionModel.find({ + static async findByItemIdArray(item_ids) { + let actions = await ActionModel.find({ 'item_id': {$in: item_ids} }); + + if (actions === null) { + return []; + } + + return actions; } /** From 50774f1922260379ca43041b75d2455c6ea21f0e Mon Sep 17 00:00:00 2001 From: Riley Davis Date: Thu, 20 Apr 2017 10:04:28 -0600 Subject: [PATCH 22/37] remove null checks --- client/coral-framework/utils/index.js | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/client/coral-framework/utils/index.js b/client/coral-framework/utils/index.js index 93dcad027..4e9c29db7 100644 --- a/client/coral-framework/utils/index.js +++ b/client/coral-framework/utils/index.js @@ -1,8 +1,4 @@ export const getTotalActionCount = (type, comment) => { - if (!comment.action_summaries) { - return 0; - } - return comment.action_summaries .filter(s => s.__typename === type) .reduce((total, summary) => { @@ -11,9 +7,6 @@ export const getTotalActionCount = (type, comment) => { }; export const iPerformedThisAction = (type, comment) => { - if (!comment.action_summaries) { - return false; - } // if there is a current_user on any of the ActionSummary(s), the user performed this action return comment.action_summaries @@ -22,10 +15,6 @@ export const iPerformedThisAction = (type, comment) => { }; export const getMyActionSummary = (type, comment) => { - if (!comment.action_summaries) { - return null; - } - return comment.action_summaries .filter(a => a.__typename === type) .find(a => a.current_user); @@ -38,9 +27,5 @@ export const getMyActionSummary = (type, comment) => { */ export const getActionSummary = (type, comment) => { - if (!comment.action_summaries) { - return null; - } - return comment.action_summaries.filter(a => a.__typename === type); }; From 5b7750f7a5c645ba4d562e4c37d0ca8b0e3dbd5c Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Thu, 20 Apr 2017 23:48:30 +0700 Subject: [PATCH 23/37] Reuse same store and action flows --- client/coral-embed-stream/src/Embed.js | 2 +- client/coral-embed-stream/src/index.js | 4 ++- client/coral-framework/actions/auth.js | 40 +++++++++--------------- client/coral-framework/reducers/auth.js | 3 +- client/coral-framework/services/store.js | 5 ++- 5 files changed, 24 insertions(+), 30 deletions(-) diff --git a/client/coral-embed-stream/src/Embed.js b/client/coral-embed-stream/src/Embed.js index 8335d38d2..a2bd50980 100644 --- a/client/coral-embed-stream/src/Embed.js +++ b/client/coral-embed-stream/src/Embed.js @@ -219,7 +219,7 @@ class Embed extends React.Component { :

    {asset.settings.closedMessage}

    } - {!loggedIn && } + {!loggedIn && } {loggedIn && user && } {loggedIn && } diff --git a/client/coral-embed-stream/src/index.js b/client/coral-embed-stream/src/index.js index 15bb959fc..d7ee99e73 100644 --- a/client/coral-embed-stream/src/index.js +++ b/client/coral-embed-stream/src/index.js @@ -3,10 +3,12 @@ import {render} from 'react-dom'; import {ApolloProvider} from 'react-apollo'; import {client} from 'coral-framework/services/client'; -import store from 'coral-framework/services/store'; +import localStore from 'coral-framework/services/store'; import AppRouter from './AppRouter'; +const store = (window.opener && window.opener.coralStore) ? window.opener.coralStore : localStore; + render( diff --git a/client/coral-framework/actions/auth.js b/client/coral-framework/actions/auth.js index 199c98534..916f93540 100644 --- a/client/coral-framework/actions/auth.js +++ b/client/coral-framework/actions/auth.js @@ -26,16 +26,19 @@ export const showSignInDialog = () => dispatch => { const signInPopUp = window.open( '/embed/stream/login', 'Login', - 'menubar=0,resizable=0,width=500,height=500,top=200,left=500' + 'menubar=0,resizable=0,width=500,height=550,top=200,left=500' ); - signInPopUp.onbeforeunload = fetchMe; - // ({type: actions.SHOW_SIGNIN_DIALOG, offset}) + signInPopUp.onbeforeunload = () => { + dispatch(checkLogin()); + fetchMe(); + }; + dispatch({type: actions.SHOW_SIGNIN_DIALOG}); }; export const hideSignInDialog = () => dispatch => { + dispatch({type: actions.HIDE_SIGNIN_DIALOG}); window.close(); - // ({type: actions.HIDE_SIGNIN_DIALOG}); -} +}; export const createUsernameRequest = () => ({type: actions.CREATE_USERNAME_REQUEST}); export const showCreateUsernameDialog = () => ({type: actions.SHOW_CREATEUSERNAME_DIALOG}); @@ -62,10 +65,13 @@ export const createUsername = (userId, formData) => dispatch => { export const changeView = view => dispatch => { switch(view) { case 'SIGNUP': - window.resizeTo(500, 700); + window.resizeTo(500, 800); + break; + case 'FORGOT': + window.resizeTo(500, 400); break; default: - window.resizeTo(500, 500); + window.resizeTo(500, 550); } dispatch({ type: actions.CHANGE_VIEW, @@ -87,7 +93,7 @@ const signInFailure = error => ({type: actions.FETCH_SIGNIN_FAILURE, error}); export const fetchSignIn = (formData) => (dispatch) => { dispatch(signInRequest()); return coralApi('/auth/local', {method: 'POST', body: formData}) - .then(() => dispatch(closeSignInPopUp())) + .then(() => dispatch(hideSignInDialog())) .catch(error => { if (error.metadata) { @@ -101,22 +107,6 @@ export const fetchSignIn = (formData) => (dispatch) => { }); }; -// Sign In - Standalone PopUp - -export const openSignInPopUp = cb => () => { - const signInPopUp = window.open( - '/embed/stream/login', - 'Login', - 'menubar=0,resizable=0,width=500,height=500,top=200,left=500' - ); - - signInPopUp.onbeforeunload = cb; -}; - -export const closeSignInPopUp = () => () => { - window.close(); -}; - // Sign In - Facebook const signInFacebookRequest = () => ({type: actions.FETCH_SIGNIN_FACEBOOK_REQUEST}); @@ -155,7 +145,7 @@ export const facebookCallback = (err, data) => dispatch => { dispatch(signInFacebookSuccess(user)); dispatch(hideSignInDialog()); dispatch(showCreateUsernameDialog()); - fetchMe(); + dispatch(hideSignInDialog()); } catch (err) { dispatch(signInFacebookFailure(err)); return; diff --git a/client/coral-framework/reducers/auth.js b/client/coral-framework/reducers/auth.js index f9712c937..6e678cab9 100644 --- a/client/coral-framework/reducers/auth.js +++ b/client/coral-framework/reducers/auth.js @@ -28,8 +28,7 @@ export default function auth (state = initialState, action) { switch (action.type) { case actions.SHOW_SIGNIN_DIALOG : return state - .set('showSignInDialog', true) - .set('signInOffset', action.offset); + .set('showSignInDialog', true); case actions.HIDE_SIGNIN_DIALOG : return state.merge(Map({ isLoading: false, diff --git a/client/coral-framework/services/store.js b/client/coral-framework/services/store.js index fbc444eec..d7090f4b5 100644 --- a/client/coral-framework/services/store.js +++ b/client/coral-framework/services/store.js @@ -24,7 +24,7 @@ if (window.devToolsExtension) { middlewares.push(window.devToolsExtension()); } -export default createStore( +const store = createStore( combineReducers({ ...mainReducer, apollo: client.reducer() @@ -32,3 +32,6 @@ export default createStore( {}, compose(...middlewares) ); + +export default store; +window.coralStore = store; From c47047c3ff9a7bbb602733bdc3a9f3b626030ff6 Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Thu, 20 Apr 2017 14:23:44 -0300 Subject: [PATCH 24/37] Classes --- client/coral-sign-in/components/SignInContent.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/client/coral-sign-in/components/SignInContent.js b/client/coral-sign-in/components/SignInContent.js index a0ed5b5b4..b057e57bd 100644 --- a/client/coral-sign-in/components/SignInContent.js +++ b/client/coral-sign-in/components/SignInContent.js @@ -20,8 +20,8 @@ const SignInContent = ({ }) => { return ( -
    -
    +
    +

    {auth.emailVerificationFailure ? lang.t('signIn.emailVerifyCTA') : lang.t('signIn.signIn')}

    @@ -42,7 +42,7 @@ const SignInContent = ({ {emailVerificationSuccess && } :
    -
    +
    @@ -80,7 +80,7 @@ const SignInContent = ({
    } -
    +
    changeView('FORGOT')}>{lang.t('signIn.forgotYourPass')} {lang.t('signIn.needAnAccount')} From f3f1cc53fe7cf54374836a61bce3add19574d9e2 Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Fri, 21 Apr 2017 00:27:26 +0700 Subject: [PATCH 25/37] Fix safari popup resizing --- client/coral-framework/actions/auth.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/client/coral-framework/actions/auth.js b/client/coral-framework/actions/auth.js index 916f93540..b2080b3b4 100644 --- a/client/coral-framework/actions/auth.js +++ b/client/coral-framework/actions/auth.js @@ -63,6 +63,11 @@ export const createUsername = (userId, formData) => dispatch => { }; export const changeView = view => dispatch => { + dispatch({ + type: actions.CHANGE_VIEW, + view + }); + switch(view) { case 'SIGNUP': window.resizeTo(500, 800); @@ -73,10 +78,6 @@ export const changeView = view => dispatch => { default: window.resizeTo(500, 550); } - dispatch({ - type: actions.CHANGE_VIEW, - view - }); }; export const cleanState = () => ({type: actions.CLEAN_STATE}); From 6df2103da3711bb596a36b72c834f1eaa50e9d26 Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Fri, 21 Apr 2017 00:45:00 +0700 Subject: [PATCH 26/37] Remove obsolete offset and styling --- client/coral-embed-stream/src/Embed.js | 9 ++++----- client/coral-plugin-flags/FlagButton.js | 3 +-- client/coral-plugin-likes/LikeButton.js | 3 +-- client/coral-sign-in/components/CreateUsernameDialog.js | 8 ++------ client/coral-sign-in/components/SignDialog.js | 8 ++------ .../coral-sign-in/containers/ChangeUsernameContainer.js | 3 +-- client/coral-sign-in/containers/SignInContainer.js | 3 +-- .../client/components/RespectButton.js | 3 +-- 8 files changed, 13 insertions(+), 27 deletions(-) diff --git a/client/coral-embed-stream/src/Embed.js b/client/coral-embed-stream/src/Embed.js index a2bd50980..c7c204288 100644 --- a/client/coral-embed-stream/src/Embed.js +++ b/client/coral-embed-stream/src/Embed.js @@ -119,8 +119,7 @@ class Embed extends React.Component { setActiveReplyBox = (reactKey) => { if (!this.props.auth.user) { - const offset = document.getElementById(`c_${reactKey}`).getBoundingClientRect().top - 75; - this.props.showSignInDialog(offset); + this.props.showSignInDialog(); } else { this.setState({activeReplyBox: reactKey}); } @@ -130,7 +129,7 @@ class Embed extends React.Component { const {activeTab} = this.state; const {closedAt, countCache = {}} = this.props.asset; const {asset, refetch, comment} = this.props.data; - const {loggedIn, isAdmin, user, showSignInDialog, signInOffset} = this.props.auth; + const {loggedIn, isAdmin, user, showSignInDialog} = this.props.auth; // even though the permalinked comment is the highlighted one, we're displaying its parent + replies const highlightedComment = comment && comment.parent ? comment.parent : comment; @@ -221,7 +220,7 @@ class Embed extends React.Component { {!loggedIn && } - {loggedIn && user && } + {loggedIn && user && } {loggedIn && } {/* the highlightedComment is isolated after the user followed a permalink */} @@ -318,7 +317,7 @@ const mapDispatchToProps = dispatch => ({ addNotification: (type, text) => addNotification(type, text), clearNotification: () => dispatch(clearNotification()), editName: (username) => dispatch(editName(username)), - showSignInDialog: (offset) => dispatch(showSignInDialog(offset)), + showSignInDialog: () => dispatch(showSignInDialog()), updateCountCache: (id, count) => dispatch(updateCountCache(id, count)), viewAllComments: () => dispatch(viewAllComments()), logout: () => dispatch(logout()), diff --git a/client/coral-plugin-flags/FlagButton.js b/client/coral-plugin-flags/FlagButton.js index 45110f407..859b2b1ca 100644 --- a/client/coral-plugin-flags/FlagButton.js +++ b/client/coral-plugin-flags/FlagButton.js @@ -25,8 +25,7 @@ class FlagButton extends Component { const {localPost, localDelete} = this.state; const flagged = (flag && flag.current_user && !localDelete) || localPost; if (!currentUser) { - const offset = document.getElementById(`c_${this.props.id}`).getBoundingClientRect().top - 75; - this.props.showSignInDialog(offset); + this.props.showSignInDialog(); return; } if (flagged) { diff --git a/client/coral-plugin-likes/LikeButton.js b/client/coral-plugin-likes/LikeButton.js index 51854c57f..c95a683a4 100644 --- a/client/coral-plugin-likes/LikeButton.js +++ b/client/coral-plugin-likes/LikeButton.js @@ -35,8 +35,7 @@ class LikeButton extends Component { const onLikeClick = () => { if (!currentUser) { - const offset = document.getElementById(`c_${id}`).getBoundingClientRect().top - 75; - showSignInDialog(offset); + showSignInDialog(); return; } if (currentUser.banned) { diff --git a/client/coral-sign-in/components/CreateUsernameDialog.js b/client/coral-sign-in/components/CreateUsernameDialog.js index 4a7a99b81..38fe9dd83 100644 --- a/client/coral-sign-in/components/CreateUsernameDialog.js +++ b/client/coral-sign-in/components/CreateUsernameDialog.js @@ -10,16 +10,12 @@ import I18n from 'coral-framework/modules/i18n/i18n'; import translations from '../translations'; const lang = new I18n(translations); -const CreateUsernameDialog = ({open, handleClose, offset, formData, handleSubmitUsername, handleChange, ...props}) => { +const CreateUsernameDialog = ({open, handleClose, formData, handleSubmitUsername, handleChange, ...props}) => { return ( + open={open}> ×
    diff --git a/client/coral-sign-in/components/SignDialog.js b/client/coral-sign-in/components/SignDialog.js index 6243472b4..ff2464f7c 100644 --- a/client/coral-sign-in/components/SignDialog.js +++ b/client/coral-sign-in/components/SignDialog.js @@ -6,15 +6,11 @@ import SignInContent from './SignInContent'; import SignUpContent from './SignUpContent'; import ForgotContent from './ForgotContent'; -const SignDialog = ({open, view, handleClose, offset, ...props}) => ( +const SignDialog = ({open, view, handleClose, ...props}) => ( + open={open}> × {view === 'SIGNIN' && } {view === 'SIGNUP' && } diff --git a/client/coral-sign-in/containers/ChangeUsernameContainer.js b/client/coral-sign-in/containers/ChangeUsernameContainer.js index c4450aa56..a3b4b969d 100644 --- a/client/coral-sign-in/containers/ChangeUsernameContainer.js +++ b/client/coral-sign-in/containers/ChangeUsernameContainer.js @@ -100,12 +100,11 @@ class ChangeUsernameContainer extends Component { } render() { - const {loggedIn, auth, offset} = this.props; + const {loggedIn, auth} = this.props; return (
    Date: Fri, 21 Apr 2017 00:52:45 +0700 Subject: [PATCH 27/37] Restore login flow in ProfileContainer --- .../coral-settings/components/NotLoggedIn.js | 4 ++-- .../containers/ProfileContainer.js | 18 ++++-------------- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/client/coral-settings/components/NotLoggedIn.js b/client/coral-settings/components/NotLoggedIn.js index 9fc43758e..a5d8b0693 100644 --- a/client/coral-settings/components/NotLoggedIn.js +++ b/client/coral-settings/components/NotLoggedIn.js @@ -4,10 +4,10 @@ import translations from '../translations'; import I18n from 'coral-framework/modules/i18n/i18n'; const lang = new I18n(translations); -export default ({signIn}) => ( +export default ({showSignInDialog}) => (
    - {lang.t('signIn')} {lang.t('toAccess')} + {lang.t('signIn')} {lang.t('toAccess')}
    {lang.t('fromSettingsPage')} diff --git a/client/coral-settings/containers/ProfileContainer.js b/client/coral-settings/containers/ProfileContainer.js index 7a26ed13e..553504462 100644 --- a/client/coral-settings/containers/ProfileContainer.js +++ b/client/coral-settings/containers/ProfileContainer.js @@ -13,7 +13,7 @@ import IgnoredUsers from '../components/IgnoredUsers'; import {Spinner} from 'coral-ui'; import CommentHistory from 'coral-plugin-history/CommentHistory'; -import {openSignInPopUp, checkLogin} from 'coral-framework/actions/auth'; +import {showSignInDialog, checkLogin} from 'coral-framework/actions/auth'; import translations from '../translations'; const lang = new I18n(translations); @@ -34,18 +34,8 @@ class ProfileContainer extends Component { }); } - signIn = () => { - const {refetch} = this.props.data; - const {openSignInPopUp, checkLogin} = this.props; - - openSignInPopUp(() => { - checkLogin(); - refetch(); - }); - } - render() { - const {loggedIn, asset, data, myIgnoredUsersData, stopIgnoringUser} = this.props; + const {loggedIn, asset, data, showSignInDialog, myIgnoredUsersData, stopIgnoringUser} = this.props; const {me} = this.props.data; if (data.loading) { @@ -53,7 +43,7 @@ class ProfileContainer extends Component { } if (!loggedIn || !me) { - return ; + return ; } const localProfile = this.props.user.profiles.find(p => p.provider === 'local'); @@ -106,7 +96,7 @@ const mapStateToProps = state => ({ }); const mapDispatchToProps = dispatch => - bindActionCreators({openSignInPopUp, checkLogin}, dispatch); + bindActionCreators({showSignInDialog, checkLogin}, dispatch); export default compose( connect(mapStateToProps, mapDispatchToProps), From 3ff9313b03e901fa1e772779afd1e6d69ec87e48 Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Fri, 21 Apr 2017 01:18:51 +0700 Subject: [PATCH 28/37] Fix ignored users when not logged in --- graph/resolvers/root_query.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/graph/resolvers/root_query.js b/graph/resolvers/root_query.js index b26ecabca..4dcb7ea11 100644 --- a/graph/resolvers/root_query.js +++ b/graph/resolvers/root_query.js @@ -84,6 +84,9 @@ const RootQuery = { }, myIgnoredUsers: async (_, args, {user, loaders: {Users}}) => { + if (!user) { + return null; + } // get currentUser again since context.user was out of date when running test/graph/mutations/ignoreUser const currentUser = (await Users.getByQuery({ids: [user.id], limit: 1}))[0]; From d1729e51155c2796c7c1c6f746f89fe10d1db221 Mon Sep 17 00:00:00 2001 From: Riley Davis Date: Thu, 20 Apr 2017 12:44:25 -0600 Subject: [PATCH 29/37] camel_case --- client/coral-embed-stream/src/Comment.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/coral-embed-stream/src/Comment.js b/client/coral-embed-stream/src/Comment.js index 01b038a8b..51402e490 100644 --- a/client/coral-embed-stream/src/Comment.js +++ b/client/coral-embed-stream/src/Comment.js @@ -125,12 +125,12 @@ class Comment extends React.Component { const likeSummary = getActionSummary('LikeActionSummary', comment); const flagSummary = getActionSummary('FlagActionSummary', comment); - const dontagreeSummary = getActionSummary('DontAgreeActionSummary', comment); + const dontAgreeSummary = getActionSummary('DontAgreeActionSummary', comment); let myFlag = null; if (iPerformedThisAction('FlagActionSummary', comment)) { myFlag = flagSummary.find(s => s.current_user); } else if (iPerformedThisAction('DontAgreeActionSummary', comment)) { - myFlag = dontagreeSummary.find(s => s.current_user); + myFlag = dontAgreeSummary.find(s => s.current_user); } let commentClass = parentId ? `reply ${styles.Reply}` : `comment ${styles.Comment}`; From 4519a550a20fd5e03e1326a014dbbe3b8d655d09 Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Fri, 21 Apr 2017 02:27:26 +0700 Subject: [PATCH 30/37] Fix fresh login on profile --- client/coral-framework/actions/auth.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/client/coral-framework/actions/auth.js b/client/coral-framework/actions/auth.js index b2080b3b4..e112b2b6c 100644 --- a/client/coral-framework/actions/auth.js +++ b/client/coral-framework/actions/auth.js @@ -11,6 +11,16 @@ const ME_QUERY = gql` query Me { me { status + comments { + id + body + asset { + id + title + url + } + created_at + } } } `; From 3dc2674f47e961eb8eb6df46fcc1c5daf98465c9 Mon Sep 17 00:00:00 2001 From: Riley Davis Date: Thu, 20 Apr 2017 14:33:49 -0600 Subject: [PATCH 31/37] the pre-mod tab does not request action_summaries since there wouldn't be any --- .../src/containers/ModerationQueue/components/Comment.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/client/coral-admin/src/containers/ModerationQueue/components/Comment.js b/client/coral-admin/src/containers/ModerationQueue/components/Comment.js index b18f239e4..217697a4a 100644 --- a/client/coral-admin/src/containers/ModerationQueue/components/Comment.js +++ b/client/coral-admin/src/containers/ModerationQueue/components/Comment.js @@ -21,8 +21,13 @@ const lang = new I18n(translations); const Comment = ({actions = [], comment, ...props}) => { const links = linkify.getMatches(comment.body); const linkText = links ? links.map(link => link.raw) : []; - const flagActionSummaries = getActionSummary('FlagActionSummary', comment); - const flagActions = comment.actions && comment.actions.filter(a => a.__typename === 'FlagAction'); + + let flagActionSummaries; + let flagActions; + if (comment.action_summaries) { // this might be missing if we're on the pre-mod tab + flagActionSummaries = getActionSummary('FlagActionSummary', comment); + flagActions = comment.actions && comment.actions.filter(a => a.__typename === 'FlagAction'); + } return (
  • From 8708fcf2cd7e29bd9865368534a98d5d302dfed2 Mon Sep 17 00:00:00 2001 From: Riley Davis Date: Thu, 20 Apr 2017 14:37:48 -0600 Subject: [PATCH 32/37] actually, we want to have the action_summaries on all requests, since a plugin could potentially pre-flag a pre-mod comment --- .../src/containers/ModerationQueue/components/Comment.js | 9 ++------- .../src/graphql/fragments/commentView.graphql | 6 ++++++ .../src/graphql/queries/modQueueQuery.graphql | 6 ------ 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/client/coral-admin/src/containers/ModerationQueue/components/Comment.js b/client/coral-admin/src/containers/ModerationQueue/components/Comment.js index 217697a4a..b18f239e4 100644 --- a/client/coral-admin/src/containers/ModerationQueue/components/Comment.js +++ b/client/coral-admin/src/containers/ModerationQueue/components/Comment.js @@ -21,13 +21,8 @@ const lang = new I18n(translations); const Comment = ({actions = [], comment, ...props}) => { const links = linkify.getMatches(comment.body); const linkText = links ? links.map(link => link.raw) : []; - - let flagActionSummaries; - let flagActions; - if (comment.action_summaries) { // this might be missing if we're on the pre-mod tab - flagActionSummaries = getActionSummary('FlagActionSummary', comment); - flagActions = comment.actions && comment.actions.filter(a => a.__typename === 'FlagAction'); - } + const flagActionSummaries = getActionSummary('FlagActionSummary', comment); + const flagActions = comment.actions && comment.actions.filter(a => a.__typename === 'FlagAction'); return (
  • diff --git a/client/coral-admin/src/graphql/fragments/commentView.graphql b/client/coral-admin/src/graphql/fragments/commentView.graphql index 8c7310bdf..51b0a3f44 100644 --- a/client/coral-admin/src/graphql/fragments/commentView.graphql +++ b/client/coral-admin/src/graphql/fragments/commentView.graphql @@ -12,6 +12,12 @@ fragment commentView on Comment { id title } + action_summaries { + count + ... on FlagActionSummary { + reason + } + } actions { ... on FlagAction { reason diff --git a/client/coral-admin/src/graphql/queries/modQueueQuery.graphql b/client/coral-admin/src/graphql/queries/modQueueQuery.graphql index b4f2a20a0..da8760be9 100644 --- a/client/coral-admin/src/graphql/queries/modQueueQuery.graphql +++ b/client/coral-admin/src/graphql/queries/modQueueQuery.graphql @@ -15,12 +15,6 @@ query ModQueue ($asset_id: ID, $sort: SORT_ORDER) { sort: $sort }) { ...commentView - action_summaries { - count - ... on FlagActionSummary { - reason - } - } } rejected: comments(query: { statuses: [REJECTED], From 4ae68b4bd3dbdae66c2ad418418e5892520fe7c9 Mon Sep 17 00:00:00 2001 From: Riley Davis Date: Thu, 20 Apr 2017 15:07:55 -0600 Subject: [PATCH 33/37] make the login pop-up scale on mobile --- views/embed/stream.ejs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/views/embed/stream.ejs b/views/embed/stream.ejs index 498090e32..d99d4bce1 100644 --- a/views/embed/stream.ejs +++ b/views/embed/stream.ejs @@ -1,6 +1,8 @@ + + From a2131c205aa7576a0ccbc6a4b99b83ae45b8c3fa Mon Sep 17 00:00:00 2001 From: Riley Davis Date: Thu, 20 Apr 2017 15:14:15 -0600 Subject: [PATCH 34/37] make the viewport non-scalable on mobile. make input font-size bigger to prevent mobile zoom effect --- client/coral-sign-in/components/CreateUsernameDialog.js | 1 + client/coral-sign-in/components/ForgotContent.js | 1 + client/coral-sign-in/components/SignInContent.js | 2 ++ client/coral-sign-in/components/SignUpContent.js | 4 ++++ 4 files changed, 8 insertions(+) diff --git a/client/coral-sign-in/components/CreateUsernameDialog.js b/client/coral-sign-in/components/CreateUsernameDialog.js index 38fe9dd83..b94b47c42 100644 --- a/client/coral-sign-in/components/CreateUsernameDialog.js +++ b/client/coral-sign-in/components/CreateUsernameDialog.js @@ -38,6 +38,7 @@ const CreateUsernameDialog = ({open, handleClose, formData, handleSubmitUsername
    this.emailInput = input} type="text" + style={{fontSize: 16}} id="email" name="email" />
    diff --git a/client/coral-sign-in/components/SignInContent.js b/client/coral-sign-in/components/SignInContent.js index b057e57bd..7460efb97 100644 --- a/client/coral-sign-in/components/SignInContent.js +++ b/client/coral-sign-in/components/SignInContent.js @@ -58,6 +58,7 @@ const SignInContent = ({ type="email" label={lang.t('signIn.email')} value={formData.email} + style={{fontSize: 16}} onChange={handleChange} />
    diff --git a/client/coral-sign-in/components/SignUpContent.js b/client/coral-sign-in/components/SignUpContent.js index d127cc2c7..921f045be 100644 --- a/client/coral-sign-in/components/SignUpContent.js +++ b/client/coral-sign-in/components/SignUpContent.js @@ -83,6 +83,7 @@ class SignUpContent extends React.Component { type="email" label={lang.t('signIn.email')} value={formData.email} + style={{fontSize: 16}} showErrors={showErrors} errorMsg={errors.email} onChange={handleChange} @@ -93,6 +94,7 @@ class SignUpContent extends React.Component { label={lang.t('signIn.username')} value={formData.username} showErrors={showErrors} + style={{fontSize: 16}} errorMsg={errors.username} onChange={handleChange} /> @@ -102,6 +104,7 @@ class SignUpContent extends React.Component { label={lang.t('signIn.password')} value={formData.password} showErrors={showErrors} + style={{fontSize: 16}} errorMsg={errors.password} onChange={handleChange} minLength="8" @@ -112,6 +115,7 @@ class SignUpContent extends React.Component { type="password" label={lang.t('signIn.confirmPassword')} value={formData.confirmPassword} + style={{fontSize: 16}} showErrors={showErrors} errorMsg={errors.confirmPassword} onChange={handleChange} From bcf31e5fa98411b23225858e8074892d88484eda Mon Sep 17 00:00:00 2001 From: Riley Davis Date: Thu, 20 Apr 2017 15:19:19 -0600 Subject: [PATCH 35/37] reporting a comment zooms the window --- client/coral-embed-stream/style/default.css | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/client/coral-embed-stream/style/default.css b/client/coral-embed-stream/style/default.css index b99b109ac..13a200690 100644 --- a/client/coral-embed-stream/style/default.css +++ b/client/coral-embed-stream/style/default.css @@ -396,6 +396,7 @@ button.comment__action-button[disabled], margin-left: 20px; margin-top: 5px; width: 75%; + font-size: 16px; } /* Close comments */ @@ -490,4 +491,4 @@ button.comment__action-button[disabled], .commentActionsLeft.comment__action-container .coral-plugin-replies-reply-button .coral-plugin-replies-icon { visibility: visible; } -} \ No newline at end of file +} From a58e15c4c8a079c29e49307af44c992343db0565 Mon Sep 17 00:00:00 2001 From: Riley Davis Date: Thu, 20 Apr 2017 18:00:06 -0600 Subject: [PATCH 36/37] let ApolloClient know which types are interfaces --- client/coral-admin/src/services/client.js | 2 ++ .../src/services/fragmentMatcher.js | 33 +++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 client/coral-admin/src/services/fragmentMatcher.js diff --git a/client/coral-admin/src/services/client.js b/client/coral-admin/src/services/client.js index 7f6a0567d..7d65f3f92 100644 --- a/client/coral-admin/src/services/client.js +++ b/client/coral-admin/src/services/client.js @@ -1,7 +1,9 @@ import ApolloClient, {addTypename} from 'apollo-client'; import getNetworkInterface from './transport'; +import fragmentMatcher from './fragmentMatcher'; export const client = new ApolloClient({ + fragmentMatcher, addTypename: true, queryTransformer: addTypename, dataIdFromObject: (result) => { diff --git a/client/coral-admin/src/services/fragmentMatcher.js b/client/coral-admin/src/services/fragmentMatcher.js new file mode 100644 index 000000000..daa01a538 --- /dev/null +++ b/client/coral-admin/src/services/fragmentMatcher.js @@ -0,0 +1,33 @@ +import {IntrospectionFragmentMatcher} from 'apollo-client'; + +// TODO this is a short-term fix +// we need to set up something to query the server for the schema before ApolloClient initialization +// https://github.com/apollographql/apollo-client/issues/1555#issuecomment-295834774 +const fm = new IntrospectionFragmentMatcher({ + introspectionQueryResultData: { + __schema: { + types: [ + { + kind: 'INTERFACE', + name: 'Action', + possibleTypes: [ + {name: 'FlagAction'}, + {name: 'LikeAction'}, + {name: 'DontAgreeAction'} + ], + }, + { + kind: 'INTERFACE', + name: 'ActionSummary', + possibleTypes: [ + {name: 'FlagActionSummary'}, + {name: 'LikeActionSummary'}, + {name: 'DontAgreeActionSummary'} + ], + } + ], + }, + } +}); + +export default fm; From 5048fbb7f0edd179decdb238328a3a87f31ba2e6 Mon Sep 17 00:00:00 2001 From: Wyatt Johnson Date: Fri, 21 Apr 2017 12:47:21 -0600 Subject: [PATCH 37/37] Added fix for flag actions --- graph/resolvers/flag_action.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/graph/resolvers/flag_action.js b/graph/resolvers/flag_action.js index 80d1583ad..e4b30c408 100644 --- a/graph/resolvers/flag_action.js +++ b/graph/resolvers/flag_action.js @@ -8,7 +8,9 @@ const FlagAction = { return group_id; }, user({user_id}, _, {loaders: {Users}}) { - return Users.getByID.load(user_id); + if (user_id) { + return Users.getByID.load(user_id); + } }, };