From 219399a23153cc7f5e85b6c2b933478f530b8ec0 Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Wed, 27 Sep 2017 22:50:45 +0700 Subject: [PATCH 01/39] Refactor ComemntDetail and implement ToxicDetail --- .../src/components/CommentDetail.css | 34 +++++++ .../src/components/CommentDetail.js | 32 +++++++ client/coral-admin/src/components/FlagBox.css | 93 +++++++------------ client/coral-admin/src/components/FlagBox.js | 65 +++++++------ .../routes/Moderation/components/Comment.js | 10 +- .../client/components/ToxicDetail.css | 11 +++ .../client/components/ToxicDetail.js | 46 +++++++++ .../client/containers/ToxicDetail.js | 21 +++++ .../client/containers/ToxicLabel.js | 7 +- .../client/index.js | 2 + .../client/utils.js | 4 + plugins/talk-plugin-toxic-comments/index.js | 2 + .../server/resolvers.js | 7 ++ .../server/typeDefs.graphql | 3 + 14 files changed, 235 insertions(+), 102 deletions(-) create mode 100644 client/coral-admin/src/components/CommentDetail.css create mode 100644 client/coral-admin/src/components/CommentDetail.js create mode 100644 plugins/talk-plugin-toxic-comments/client/components/ToxicDetail.css create mode 100644 plugins/talk-plugin-toxic-comments/client/components/ToxicDetail.js create mode 100644 plugins/talk-plugin-toxic-comments/client/containers/ToxicDetail.js create mode 100644 plugins/talk-plugin-toxic-comments/client/utils.js create mode 100644 plugins/talk-plugin-toxic-comments/server/resolvers.js diff --git a/client/coral-admin/src/components/CommentDetail.css b/client/coral-admin/src/components/CommentDetail.css new file mode 100644 index 000000000..259d4e1c5 --- /dev/null +++ b/client/coral-admin/src/components/CommentDetail.css @@ -0,0 +1,34 @@ +.root { + margin-left: 16px; +} + +.headerContainer { + display: flex; + justify-content: flex-start; + align-items: center; +} + +.header { + vertical-align: middle; + margin: 0; + font-weight: 500; + display: inline-block; + font-size: 12px; + line-height: 12px; + margin-right: 7px; +} + +.info { + font-size: 12px; +} + +.details { + padding: 0 20px 16px; + font-size: 12px; +} + +.icon { + vertical-align: middle; + font-size: 12px; + margin-right: 7px; +} diff --git a/client/coral-admin/src/components/CommentDetail.js b/client/coral-admin/src/components/CommentDetail.js new file mode 100644 index 000000000..2e1a89089 --- /dev/null +++ b/client/coral-admin/src/components/CommentDetail.js @@ -0,0 +1,32 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +import cn from 'classnames'; +import styles from './CommentDetail.css'; +import {Icon} from 'coral-ui'; + +const CommentDetail = ({icon, header, info, children, className}) => { + return ( +
+
+ {icon && } +

{header}:

+
{info}
+
+ {children && +
+ {children} +
+ } +
+ ); +}; + +CommentDetail.propTypes = { + className: PropTypes.string, + header: PropTypes.node, + icon: PropTypes.string, + info: PropTypes.node, + children: PropTypes.node, +}; + +export default CommentDetail; diff --git a/client/coral-admin/src/components/FlagBox.css b/client/coral-admin/src/components/FlagBox.css index 232803203..b88f904b9 100644 --- a/client/coral-admin/src/components/FlagBox.css +++ b/client/coral-admin/src/components/FlagBox.css @@ -1,56 +1,42 @@ .flagBox { border-top: 1px solid rgba(66, 66, 66, 0.12); margin-top: 10px; - .container { - padding: 0 14px; - } + padding-top: 10px; +} - .detail { - padding: 0 20px 16px; - ul { - padding: 0; - list-style: none; - font-size: 12px; - font-weight: 500; - } - } +.info { + vertical-align: middle; + list-style: none; + display: inline-block; + padding: 0; + font-size: 12px; +} - .header { - position: relative; - .moreDetail { - float: right; - font-size: 12px; - font-weight: 500; - margin-right: 10px; - margin-top: 8px; - color: black; +.detail { + padding: 0; + list-style: none; + font-size: 12px; + font-weight: 500; +} - &:hover { - opacity: 0.9; - cursor: pointer; - } - } - i { - vertical-align: middle; - font-size: 12px; - } - ul { - vertical-align: middle; - list-style: none; - display: inline-block; - padding: 0; - margin-left: 10px; - font-size: 12px; - } - } +.subDetail { + padding: 0; + list-style: none; + font-size: 12px; + font-weight: normal; + color: #888; +} - h3 { - vertical-align: middle; - margin: 0; - font-weight: 500; - display: inline-block; - margin-left: 7px; - font-size: 12px; +.moreDetail { + position: absolute; + font-size: 12px; + font-weight: 500; + color: black; + right: 16px; + + &:hover { + opacity: 0.9; + cursor: pointer; } } @@ -59,15 +45,6 @@ margin-right: 10px; } -.subDetail { - font-weight: normal; - color: #888; - - span { - color: black; - } -} - .username { color: #393B44; text-decoration: none; @@ -77,7 +54,7 @@ border-radius: 2px; margin-left: -5px; transition: background-color 200ms ease; -&:hover { - background-color: #E0E0E0; - } + &:hover { + background-color: #E0E0E0; + } } diff --git a/client/coral-admin/src/components/FlagBox.js b/client/coral-admin/src/components/FlagBox.js index 05fd14128..44a302e52 100644 --- a/client/coral-admin/src/components/FlagBox.js +++ b/client/coral-admin/src/components/FlagBox.js @@ -1,8 +1,8 @@ import React, {Component} from 'react'; import PropTypes from 'prop-types'; -import {Icon} from 'coral-ui'; import styles from './FlagBox.css'; import t from 'coral-framework/services/i18n'; +import CommentDetail from './CommentDetail'; const shortReasons = { 'This comment is offensive': t('modqueue.offensive'), @@ -39,45 +39,42 @@ class FlagBox extends Component { return (
-
-
-

{t('community.flags')} ({actionSummaries.length}):

- - {showDetail ? t('modqueue.less_detail') : t('modqueue.more_detail')} -
+ }> {showDetail && ( -
-
    - {actionSummaries.map((summary, i) => { - - const actionList = actions.filter((a) => a.reason === summary.reason); - - return ( -
  • - {this.reasonMap(summary.reason)} ({summary.count}) - -
  • - ); - })} -
-
+
    + {actionSummaries.map((summary, i) => { + const actionList = actions.filter((a) => a.reason === summary.reason); + return ( +
  • + {this.reasonMap(summary.reason)} ({summary.count}) + +
  • + ); + })} +
)} -
+
); } diff --git a/client/coral-admin/src/routes/Moderation/components/Comment.js b/client/coral-admin/src/routes/Moderation/components/Comment.js index f72b0ef12..e19f34229 100644 --- a/client/coral-admin/src/routes/Moderation/components/Comment.js +++ b/client/coral-admin/src/routes/Moderation/components/Comment.js @@ -185,11 +185,6 @@ class Comment extends React.Component { - {flagActions && flagActions.length ? : null} + ); } diff --git a/plugins/talk-plugin-toxic-comments/client/components/ToxicDetail.css b/plugins/talk-plugin-toxic-comments/client/components/ToxicDetail.css new file mode 100644 index 000000000..cbf7ce8de --- /dev/null +++ b/plugins/talk-plugin-toxic-comments/client/components/ToxicDetail.css @@ -0,0 +1,11 @@ +.info { + background-color: rgba(44, 44, 44, 0.89); + color: white; + padding: 2px 4px; + font-size: 0.8em; + margin-left: 6px; +} + +.toxic { + background-color: #d03235; +} diff --git a/plugins/talk-plugin-toxic-comments/client/components/ToxicDetail.js b/plugins/talk-plugin-toxic-comments/client/components/ToxicDetail.js new file mode 100644 index 000000000..de8a0337c --- /dev/null +++ b/plugins/talk-plugin-toxic-comments/client/components/ToxicDetail.js @@ -0,0 +1,46 @@ +import React from 'react'; +import CommentDetail from 'coral-admin/src/components/CommentDetail'; +import {isToxic} from '../utils'; +import styles from './ToxicDetail.css'; +import cn from 'classnames'; +import PropTypes from 'prop-types'; + +const getInfo = (toxicity, actions) => { + const toxic = isToxic(actions); + let text = 'Unlikely'; + if (toxicity > 0.8) { + text = 'Highly Likely'; + } + else if (toxicity >= 0.5) { + text = 'Possibly'; + } + else if (toxicity >= 0.7) { + text = 'Likely'; + } + + return ( +
+ {text} + + {Math.round(toxicity * 100)}% + +
+ ); +}; + +const ToxicLabel = ({comment: {actions, toxicity}}) => ( + +); + +ToxicLabel.propTypes = { + comment: PropTypes.shape({ + actions: PropTypes.array, + toxicity: PropTypes.toxicity, + }), +}; + +export default ToxicLabel; diff --git a/plugins/talk-plugin-toxic-comments/client/containers/ToxicDetail.js b/plugins/talk-plugin-toxic-comments/client/containers/ToxicDetail.js new file mode 100644 index 000000000..32b83fbb3 --- /dev/null +++ b/plugins/talk-plugin-toxic-comments/client/containers/ToxicDetail.js @@ -0,0 +1,21 @@ +import {compose, gql} from 'react-apollo'; +import {withFragments, excludeIf} from 'plugin-api/beta/client/hocs'; +import ToxicDetail from '../components/ToxicDetail'; + +const enhance = compose( + withFragments({ + comment: gql` + fragment TalkToxicComments_ToxicDetail_Comment on Comment { + toxicity + actions { + __typename + ... on FlagAction { + reason + } + } + }`, + }), + excludeIf(({comment: {toxicity}}) => toxicity === null), +); + +export default enhance(ToxicDetail); diff --git a/plugins/talk-plugin-toxic-comments/client/containers/ToxicLabel.js b/plugins/talk-plugin-toxic-comments/client/containers/ToxicLabel.js index 0d2e9e14b..ee43f4a7e 100644 --- a/plugins/talk-plugin-toxic-comments/client/containers/ToxicLabel.js +++ b/plugins/talk-plugin-toxic-comments/client/containers/ToxicLabel.js @@ -1,15 +1,12 @@ import {compose, gql} from 'react-apollo'; import {withFragments, excludeIf} from 'plugin-api/beta/client/hocs'; import ToxicLabel from '../components/ToxicLabel'; - -function isToxic(actions) { - return actions.some((action) => action.__typename === 'FlagAction' && action.reason === 'TOXIC_COMMENT'); -} +import {isToxic} from '../utils'; const enhance = compose( withFragments({ comment: gql` - fragment TalkToxicComments_Comment on Comment { + fragment TalkToxicComments_ToxicLabel_Comment on Comment { actions { __typename ... on FlagAction { diff --git a/plugins/talk-plugin-toxic-comments/client/index.js b/plugins/talk-plugin-toxic-comments/client/index.js index 8a16b8dea..1db520891 100644 --- a/plugins/talk-plugin-toxic-comments/client/index.js +++ b/plugins/talk-plugin-toxic-comments/client/index.js @@ -1,11 +1,13 @@ import translations from './translations.yml'; import CheckToxicityHook from './containers/CheckToxicityHook'; import ToxicLabel from './containers/ToxicLabel'; +import ToxicDetail from './containers/ToxicDetail'; export default { translations, slots: { commentInputDetailArea: [CheckToxicityHook], adminCommentLabels: [ToxicLabel], + adminCommentDetailArea: [ToxicDetail], }, }; diff --git a/plugins/talk-plugin-toxic-comments/client/utils.js b/plugins/talk-plugin-toxic-comments/client/utils.js new file mode 100644 index 000000000..57bfd9633 --- /dev/null +++ b/plugins/talk-plugin-toxic-comments/client/utils.js @@ -0,0 +1,4 @@ +export function isToxic(actions) { + return actions.some((action) => action.__typename === 'FlagAction' && action.reason === 'TOXIC_COMMENT'); +} + diff --git a/plugins/talk-plugin-toxic-comments/index.js b/plugins/talk-plugin-toxic-comments/index.js index 0802a6c11..444cb94f5 100644 --- a/plugins/talk-plugin-toxic-comments/index.js +++ b/plugins/talk-plugin-toxic-comments/index.js @@ -1,8 +1,10 @@ const {readFileSync} = require('fs'); const path = require('path'); const hooks = require('./server/hooks'); +const resolvers = require('./server/resolvers'); module.exports = { typeDefs: readFileSync(path.join(__dirname, 'server/typeDefs.graphql'), 'utf8'), hooks, + resolvers, }; diff --git a/plugins/talk-plugin-toxic-comments/server/resolvers.js b/plugins/talk-plugin-toxic-comments/server/resolvers.js new file mode 100644 index 000000000..5af584b44 --- /dev/null +++ b/plugins/talk-plugin-toxic-comments/server/resolvers.js @@ -0,0 +1,7 @@ +const get = require('lodash/get'); + +module.exports = { + Comment: { + toxicity: (comment) => get(comment, 'metadata.perspective.SEVERE_TOXICITY.summaryScore'), + } +}; diff --git a/plugins/talk-plugin-toxic-comments/server/typeDefs.graphql b/plugins/talk-plugin-toxic-comments/server/typeDefs.graphql index b4dfc8345..c9e28fb9c 100644 --- a/plugins/talk-plugin-toxic-comments/server/typeDefs.graphql +++ b/plugins/talk-plugin-toxic-comments/server/typeDefs.graphql @@ -5,3 +5,6 @@ input CreateCommentInput { checkToxicity: Boolean } +type Comment { + toxicity: Float +} From 5d718f6dd4ce4a3b704512f9b1cbda002a51004e Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Thu, 28 Sep 2017 22:02:06 +0700 Subject: [PATCH 02/39] Only shw user flags in detail --- .../src/components/CommentDetails.css | 18 ++++ .../src/components/CommentDetails.js | 50 ++++++++++ client/coral-admin/src/components/FlagBox.js | 94 ------------------- .../{FlagBox.css => FlagDetails.css} | 19 +--- .../coral-admin/src/components/FlagDetails.js | 75 +++++++++++++++ .../src/components/UserDetailComment.js | 8 +- .../src/containers/UserDetailComment.js | 6 -- .../routes/Moderation/components/Comment.js | 4 +- 8 files changed, 148 insertions(+), 126 deletions(-) create mode 100644 client/coral-admin/src/components/CommentDetails.css create mode 100644 client/coral-admin/src/components/CommentDetails.js delete mode 100644 client/coral-admin/src/components/FlagBox.js rename client/coral-admin/src/components/{FlagBox.css => FlagDetails.css} (70%) create mode 100644 client/coral-admin/src/components/FlagDetails.js diff --git a/client/coral-admin/src/components/CommentDetails.css b/client/coral-admin/src/components/CommentDetails.css new file mode 100644 index 000000000..ff3679cc7 --- /dev/null +++ b/client/coral-admin/src/components/CommentDetails.css @@ -0,0 +1,18 @@ +.root { + margin-top: 10px; + padding-top: 10px; +} + +.moreDetail { + position: absolute; + font-size: 12px; + font-weight: 500; + color: black; + right: 16px; + + &:hover { + opacity: 0.9; + cursor: pointer; + } +} + diff --git a/client/coral-admin/src/components/CommentDetails.js b/client/coral-admin/src/components/CommentDetails.js new file mode 100644 index 000000000..9d9c26813 --- /dev/null +++ b/client/coral-admin/src/components/CommentDetails.js @@ -0,0 +1,50 @@ +import React, {Component} from 'react'; +import PropTypes from 'prop-types'; +import styles from './CommentDetails.css'; +import t from 'coral-framework/services/i18n'; +import FlagDetails from './FlagDetails'; + +class CommentDetails extends Component { + state = { + showDetail: false + }; + + constructor () { + super(); + this.state = { + showDetail: false + }; + } + + toggleDetail = () => { + this.setState((state) => ({ + showDetail: !state.showDetail + })); + } + + render() { + const {actions, viewUserDetail} = this.props; + const {showDetail} = this.state; + + return ( + + ); + } +} + +CommentDetails.propTypes = { + actions: PropTypes.arrayOf(PropTypes.shape({ + message: PropTypes.string, + user: PropTypes.shape({username: PropTypes.string}) + })).isRequired, + viewUserDetail: PropTypes.func.isRequired, +}; + +export default CommentDetails; diff --git a/client/coral-admin/src/components/FlagBox.js b/client/coral-admin/src/components/FlagBox.js deleted file mode 100644 index 44a302e52..000000000 --- a/client/coral-admin/src/components/FlagBox.js +++ /dev/null @@ -1,94 +0,0 @@ -import React, {Component} from 'react'; -import PropTypes from 'prop-types'; -import styles from './FlagBox.css'; -import t from 'coral-framework/services/i18n'; -import CommentDetail from './CommentDetail'; - -const shortReasons = { - 'This comment is offensive': t('modqueue.offensive'), - 'This looks like an ad/marketing': t('modqueue.spam_ads'), - 'This user is impersonating': t('modqueue.impersonating'), - 'I don\'t like this username': t('modqueue.dont_like_username'), - 'Other': t('modqueue.other') -}; - -class FlagBox extends Component { - constructor () { - super(); - this.state = { - showDetail: false - }; - } - - toggleDetail = () => { - this.setState((state) => ({ - showDetail: !state.showDetail - })); - } - - reasonMap = (reason) => { - const shortReason = shortReasons[reason]; - - // if the short reason isn't found, just return the long one. - return shortReason ? shortReason : reason; - } - - render() { - const {actionSummaries, actions, viewUserDetail} = this.props; - const {showDetail} = this.state; - - return ( -
- {showDetail ? t('modqueue.less_detail') : t('modqueue.more_detail')} - - {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}) - -
    • - ); - })} -
    - )} -
    -
    - ); - } -} - -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 -}; - -export default FlagBox; diff --git a/client/coral-admin/src/components/FlagBox.css b/client/coral-admin/src/components/FlagDetails.css similarity index 70% rename from client/coral-admin/src/components/FlagBox.css rename to client/coral-admin/src/components/FlagDetails.css index b88f904b9..302e24858 100644 --- a/client/coral-admin/src/components/FlagBox.css +++ b/client/coral-admin/src/components/FlagDetails.css @@ -1,8 +1,3 @@ -.flagBox { - border-top: 1px solid rgba(66, 66, 66, 0.12); - margin-top: 10px; - padding-top: 10px; -} .info { vertical-align: middle; @@ -20,6 +15,7 @@ } .subDetail { + margin-left:10px; padding: 0; list-style: none; font-size: 12px; @@ -27,19 +23,6 @@ color: #888; } -.moreDetail { - position: absolute; - font-size: 12px; - font-weight: 500; - color: black; - right: 16px; - - &:hover { - opacity: 0.9; - cursor: pointer; - } -} - .lessDetail { display: inline-block; margin-right: 10px; diff --git a/client/coral-admin/src/components/FlagDetails.js b/client/coral-admin/src/components/FlagDetails.js new file mode 100644 index 000000000..74bff8f24 --- /dev/null +++ b/client/coral-admin/src/components/FlagDetails.js @@ -0,0 +1,75 @@ +import React, {Component} from 'react'; +import PropTypes from 'prop-types'; +import styles from './FlagDetails.css'; +import t from 'coral-framework/services/i18n'; +import CommentDetail from './CommentDetail'; + +class FlagDetails extends Component { + + render() { + const {actions, viewUserDetail, more} = this.props; + const summaries = actions.reduce((sum, action) => { + if (!(action.reason in sum)) { + sum[action.reason] = {count: 0, userFlagged: false, actions: []}; + } + sum[action.reason].count++; + if (action.user) { + sum[action.reason].userFlagged = true; + } + sum[action.reason].actions.push(action); + return sum; + }, {}); + + const userFlagReasons = Object.keys(summaries).filter((reason) => summaries[reason].userFlagged); + + return ( + + {Object.keys(summaries).map((reason) => +
  • + {reason} {summaries[reason].userFlagged && `(${summaries[reason].count})`} +
  • + )} + + }> + {more && userFlagReasons.length > 0 && ( + + )} +
    + ); + } +} + +FlagDetails.propTypes = { + more: PropTypes.bool, + actions: PropTypes.arrayOf(PropTypes.shape({ + message: PropTypes.string, + user: PropTypes.shape({username: PropTypes.string}) + })).isRequired, + viewUserDetail: PropTypes.func.isRequired, +}; + +export default FlagDetails; diff --git a/client/coral-admin/src/components/UserDetailComment.js b/client/coral-admin/src/components/UserDetailComment.js index 2aec28ab9..4ef557173 100644 --- a/client/coral-admin/src/components/UserDetailComment.js +++ b/client/coral-admin/src/components/UserDetailComment.js @@ -3,9 +3,8 @@ import PropTypes from 'prop-types'; import {Link} from 'react-router'; import {Icon} from 'coral-ui'; -import FlagBox from './FlagBox'; +import CommentDetails from './CommentDetails'; import styles from './UserDetailComment.css'; -import {getActionSummary} from 'coral-framework/utils'; import ActionButton from 'coral-admin/src/components/ActionButton'; import CommentBodyHighlighter from 'coral-admin/src/components/CommentBodyHighlighter'; import IfHasLink from 'coral-admin/src/components/IfHasLink'; @@ -31,7 +30,6 @@ class UserDetailComment extends React.Component { ...props } = this.props; - const flagActionSummaries = getActionSummary('FlagActionSummary', comment); const flagActions = comment.actions && comment.actions.filter((a) => a.__typename === 'FlagAction'); return ( @@ -117,9 +115,8 @@ class UserDetailComment extends React.Component { {flagActions && flagActions.length - ? : null} @@ -139,7 +136,6 @@ UserDetailComment.propTypes = { toggleSelect: PropTypes.func, comment: PropTypes.shape({ body: PropTypes.string.isRequired, - action_summaries: PropTypes.array, actions: PropTypes.array, created_at: PropTypes.string.isRequired, asset: PropTypes.shape({ diff --git a/client/coral-admin/src/containers/UserDetailComment.js b/client/coral-admin/src/containers/UserDetailComment.js index 9f0199bce..6b3572434 100644 --- a/client/coral-admin/src/containers/UserDetailComment.js +++ b/client/coral-admin/src/containers/UserDetailComment.js @@ -17,12 +17,6 @@ export default withFragments({ title url } - action_summaries { - count - ... on FlagActionSummary { - reason - } - } actions { ... on FlagAction { id diff --git a/client/coral-admin/src/routes/Moderation/components/Comment.js b/client/coral-admin/src/routes/Moderation/components/Comment.js index e19f34229..c761ff591 100644 --- a/client/coral-admin/src/routes/Moderation/components/Comment.js +++ b/client/coral-admin/src/routes/Moderation/components/Comment.js @@ -3,7 +3,7 @@ import PropTypes from 'prop-types'; import {Link} from 'react-router'; import {Icon} from 'coral-ui'; -import FlagBox from 'coral-admin/src/components/FlagBox'; +import CommentDetails from 'coral-admin/src/components/CommentDetails'; import styles from './Comment.css'; import CommentLabels from 'coral-admin/src/components/CommentLabels'; import CommentAnimatedEdit from 'coral-admin/src/components/CommentAnimatedEdit'; @@ -186,7 +186,7 @@ class Comment extends React.Component { {flagActions && flagActions.length - ? Date: Fri, 29 Sep 2017 19:42:44 +0700 Subject: [PATCH 03/39] Refactor and pluginize comment details --- .eslintignore | 1 + .gitignore | 1 + .../src/components/ActionButton.css | 24 ------ .../src/components/ActionButton.js | 38 --------- .../src/components/ApproveButton.css | 44 +++++++++++ .../src/components/ApproveButton.js | 30 +++++++ .../src/components/CommentDetails.js | 23 +++--- .../src/components/RejectButton.css | 44 +++++++++++ .../src/components/RejectButton.js | 30 +++++++ .../coral-admin/src/components/UserDetail.js | 6 +- .../src/components/UserDetailComment.js | 66 +++++++--------- .../src/containers/CommentDetails.js | 23 ++++++ .../src/containers/CommentLabels.js | 6 ++ .../coral-admin/src/containers/UserDetail.js | 2 + .../src/containers/UserDetailComment.js | 25 +++--- .../Community/components/ActionButton.css | 4 - .../Community/components/ActionButton.js | 22 ------ .../Community/components/FlaggedAccounts.js | 1 - .../Community/components/FlaggedUser.js | 25 +++--- .../components/RejectUsernameDialog.js | 2 +- .../routes/Community/containers/Community.js | 6 +- .../routes/Moderation/components/Comment.js | 68 ++++++---------- .../Moderation/components/ModerationQueue.js | 5 -- .../routes/Moderation/containers/Comment.js | 29 ++----- .../Moderation/containers/Moderation.js | 2 + .../src/utils/moderationQueueActionsMap.js | 14 ---- client/coral-ui/components/Button.css | 53 ------------- .../talk-plugin-flag-details/.eslintrc.json | 3 + .../talk-plugin-flag-details/client/.babelrc | 14 ++++ .../client/.eslintrc.json | 3 + .../client/components/FlagDetails.css | 43 ++++++++++ .../client/components/FlagDetails.js | 79 +++++++++++++++++++ .../client/containers/FlagDetails.js | 37 +++++++++ .../talk-plugin-flag-details/client/index.js | 9 +++ .../client/translations.yml | 3 + plugins/talk-plugin-flag-details/index.js | 1 + .../client/containers/ToxicDetail.js | 2 +- 37 files changed, 486 insertions(+), 302 deletions(-) delete mode 100644 client/coral-admin/src/components/ActionButton.css delete mode 100644 client/coral-admin/src/components/ActionButton.js create mode 100644 client/coral-admin/src/components/ApproveButton.css create mode 100644 client/coral-admin/src/components/ApproveButton.js create mode 100644 client/coral-admin/src/components/RejectButton.css create mode 100644 client/coral-admin/src/components/RejectButton.js create mode 100644 client/coral-admin/src/containers/CommentDetails.js delete mode 100644 client/coral-admin/src/routes/Community/components/ActionButton.css delete mode 100644 client/coral-admin/src/routes/Community/components/ActionButton.js delete mode 100644 client/coral-admin/src/utils/moderationQueueActionsMap.js create mode 100644 plugins/talk-plugin-flag-details/.eslintrc.json create mode 100644 plugins/talk-plugin-flag-details/client/.babelrc create mode 100644 plugins/talk-plugin-flag-details/client/.eslintrc.json create mode 100644 plugins/talk-plugin-flag-details/client/components/FlagDetails.css create mode 100644 plugins/talk-plugin-flag-details/client/components/FlagDetails.js create mode 100644 plugins/talk-plugin-flag-details/client/containers/FlagDetails.js create mode 100644 plugins/talk-plugin-flag-details/client/index.js create mode 100644 plugins/talk-plugin-flag-details/client/translations.yml create mode 100644 plugins/talk-plugin-flag-details/index.js diff --git a/.eslintignore b/.eslintignore index fc0214dd2..22cf3d4b8 100644 --- a/.eslintignore +++ b/.eslintignore @@ -26,5 +26,6 @@ plugins/* !plugins/talk-plugin-toxic-comments !plugins/talk-plugin-remember-sort !plugins/talk-plugin-deep-reply-count +!plugins/talk-plugin-flag-details node_modules diff --git a/.gitignore b/.gitignore index bcc7c89b1..e253c5904 100644 --- a/.gitignore +++ b/.gitignore @@ -43,5 +43,6 @@ plugins/* !plugins/talk-plugin-toxic-comments !plugins/talk-plugin-remember-sort !plugins/talk-plugin-deep-reply-count +!plugins/talk-plugin-flag-details **/node_modules/* diff --git a/client/coral-admin/src/components/ActionButton.css b/client/coral-admin/src/components/ActionButton.css deleted file mode 100644 index 226006c6b..000000000 --- a/client/coral-admin/src/components/ActionButton.css +++ /dev/null @@ -1,24 +0,0 @@ -.actionButton { - transform: scale(.8); - margin: 0; -} - -.minimal { - width: 45px; - min-width: 0; -} - -.approve__active { - box-shadow: none; - color: white; - background-color: #519954; - cursor: not-allowed; -} - -.reject__active, .rejected__active { - color: white; - background-color: #D03235; - box-shadow: none; - cursor: not-allowed; -} - diff --git a/client/coral-admin/src/components/ActionButton.js b/client/coral-admin/src/components/ActionButton.js deleted file mode 100644 index 77456b939..000000000 --- a/client/coral-admin/src/components/ActionButton.js +++ /dev/null @@ -1,38 +0,0 @@ -import React from 'react'; -import PropTypes from 'prop-types'; - -import styles from './ActionButton.css'; -import {Button} from 'coral-ui'; -import {menuActionsMap} from '../utils/moderationQueueActionsMap'; - -import t from 'coral-framework/services/i18n'; - -const ActionButton = ({type = '', active, ...props}) => { - const typeName = type.toLowerCase(); - let text = menuActionsMap[type].text; - - if (text === 'approve' && active) { - text = 'approved'; - } else if (text === 'reject' && active) { - text = 'rejected'; - } - - return ( - - ); -}; - -ActionButton.propTypes = { - active: PropTypes.bool, - type: PropTypes.oneOf(['APPROVE', 'REJECT']), - minimal: PropTypes.bool, - acceptComment: PropTypes.func, - rejectComment: PropTypes.func, -}; - -export default ActionButton; diff --git a/client/coral-admin/src/components/ApproveButton.css b/client/coral-admin/src/components/ApproveButton.css new file mode 100644 index 000000000..4c42cc233 --- /dev/null +++ b/client/coral-admin/src/components/ApproveButton.css @@ -0,0 +1,44 @@ +.root { + display: block; + color: #519954; + border: solid 2px rgba(81, 153, 84, 0.75); + background: white; + padding: 10px 12px; + box-sizing: border-box; + vertical-align: middle; + line-height: 24px; + font-size: 17px; + height: 47px; + border-radius: 3px; + text-transform: capitalize; + box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.03), 0 3px 1px -2px rgba(0,0,0,.2), 0 1px 5px 0 rgba(0,0,0,.09); + width: 129px; + transform: scale(.8); + margin: 0; + + &:hover { + box-shadow: none; + color: white; + background-color: #519954; + cursor: pointer; + } +} + +.active { + box-shadow: none; + color: white; + background-color: #519954; + + &:hover { + cursor: not-allowed; + } +} + +.minimal { + width: 45px; + min-width: 0; +} + +.icon { + margin-right: 5px; +} diff --git a/client/coral-admin/src/components/ApproveButton.js b/client/coral-admin/src/components/ApproveButton.js new file mode 100644 index 000000000..151a5ca29 --- /dev/null +++ b/client/coral-admin/src/components/ApproveButton.js @@ -0,0 +1,30 @@ +import React from 'react'; +import PropTypes from 'prop-types'; + +import cn from 'classnames'; +import styles from './ApproveButton.css'; +import {Icon} from 'coral-ui'; + +import t from 'coral-framework/services/i18n'; + +const ApproveButton = ({active, minimal, onClick}) => { + const text = active ? t('modqueue.approved') : t('modqueue.approve'); + return ( + + ); +}; + +ApproveButton.propTypes = { + active: PropTypes.bool, + minimal: PropTypes.bool, + onClick: PropTypes.func, +}; + +export default ApproveButton; + diff --git a/client/coral-admin/src/components/CommentDetails.js b/client/coral-admin/src/components/CommentDetails.js index 9d9c26813..d984ce0c1 100644 --- a/client/coral-admin/src/components/CommentDetails.js +++ b/client/coral-admin/src/components/CommentDetails.js @@ -2,7 +2,7 @@ import React, {Component} from 'react'; import PropTypes from 'prop-types'; import styles from './CommentDetails.css'; import t from 'coral-framework/services/i18n'; -import FlagDetails from './FlagDetails'; +import Slot from 'coral-framework/components/Slot'; class CommentDetails extends Component { state = { @@ -23,15 +23,20 @@ class CommentDetails extends Component { } render() { - const {actions, viewUserDetail} = this.props; + const {data, root, comment} = this.props; const {showDetail} = this.state; + const queryData = { + root, + comment, + }; return ( @@ -40,11 +45,9 @@ class CommentDetails extends Component { } CommentDetails.propTypes = { - actions: PropTypes.arrayOf(PropTypes.shape({ - message: PropTypes.string, - user: PropTypes.shape({username: PropTypes.string}) - })).isRequired, - viewUserDetail: PropTypes.func.isRequired, + data: PropTypes.object.isRequired, + root: PropTypes.object.isRequired, + comment: PropTypes.object.isRequired, }; export default CommentDetails; diff --git a/client/coral-admin/src/components/RejectButton.css b/client/coral-admin/src/components/RejectButton.css new file mode 100644 index 000000000..a06cf5f43 --- /dev/null +++ b/client/coral-admin/src/components/RejectButton.css @@ -0,0 +1,44 @@ +.root { + display: block; + color: #D03235; + border: solid 1px #D03235; + background: white; + padding: 10px 11px; + box-sizing: border-box; + vertical-align: middle; + line-height: 24px; + font-size: 17px; + height: 47px; + border-radius: 3px; + text-transform: capitalize; + box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.03), 0 3px 1px -2px rgba(0,0,0,.2), 0 1px 5px 0 rgba(0,0,0,.09); + width: 129px; + transform: scale(.8); + margin: 0; + + &:hover { + color: white; + background-color: #D03235; + box-shadow: none; + cursor: pointer; + } +} + +.active { + color: white; + background-color: #D03235; + box-shadow: none; + + &:hover { + cursor: not-allowed; + } +} + +.minimal { + width: 45px; + min-width: 0; +} + +.icon { + margin-right: 5px; +} diff --git a/client/coral-admin/src/components/RejectButton.js b/client/coral-admin/src/components/RejectButton.js new file mode 100644 index 000000000..e01102dc3 --- /dev/null +++ b/client/coral-admin/src/components/RejectButton.js @@ -0,0 +1,30 @@ +import React from 'react'; +import PropTypes from 'prop-types'; + +import cn from 'classnames'; +import styles from './RejectButton.css'; +import {Icon} from 'coral-ui'; + +import t from 'coral-framework/services/i18n'; + +const RejectButton = ({active, minimal, onClick}) => { + const text = active ? t('modqueue.rejected') : t('modqueue.reject'); + return ( + + ); +}; + +RejectButton.propTypes = { + active: PropTypes.bool, + minimal: PropTypes.bool, + onClick: PropTypes.func, +}; + +export default RejectButton; + diff --git a/client/coral-admin/src/components/UserDetail.js b/client/coral-admin/src/components/UserDetail.js index b6b239057..a5955af45 100644 --- a/client/coral-admin/src/components/UserDetail.js +++ b/client/coral-admin/src/components/UserDetail.js @@ -5,7 +5,6 @@ import styles from './UserDetail.css'; import {Icon, Button, Drawer, Spinner} from 'coral-ui'; import {Slot} from 'coral-framework/components'; import ButtonCopyToClipboard from './ButtonCopyToClipboard'; -import {actionsMap} from '../utils/moderationQueueActionsMap'; import ClickOutside from 'coral-framework/components/ClickOutside'; import LoadMore from '../components/LoadMore'; import cn from 'classnames'; @@ -70,6 +69,7 @@ export default class UserDetail extends React.Component { renderLoaded() { const { + data, root, root: { user, @@ -177,15 +177,15 @@ export default class UserDetail extends React.Component {
    { nodes.map((comment) => { - const status = comment.action_summaries ? 'FLAGGED' : comment.status; const selected = selectedCommentIds.indexOf(comment.id) !== -1; return (this.props.comment.status === 'ACCEPTED' + ? null + : this.props.acceptComment({commentId: this.props.comment.id}) + ); + + reject = () => (this.props.comment.status === 'REJECTED' + ? null + : this.props.rejectComment({commentId: this.props.comment.id}) + ); + render() { const { - actions = [], comment, - viewUserDetail, suspectWords, bannedWords, selected, toggleSelect, className, - user, - ...props + data, } = this.props; - const flagActions = comment.actions && comment.actions.filter((a) => a.__typename === 'FlagAction'); - return (
  • - {actions.map((action, i) => { - const active = - (action === 'REJECT' && comment.status === 'REJECTED') || - (action === 'APPROVE' && comment.status === 'ACCEPTED'); - return ( - - (comment.status === 'ACCEPTED' - ? null - : props.acceptComment({commentId: comment.id}))} - rejectComment={() => - (comment.status === 'REJECTED' - ? null - : props.rejectComment({commentId: comment.id}))} - /> - ); - })} + +
  • - {flagActions && flagActions.length - ? - : null} + ); } @@ -135,6 +127,8 @@ UserDetailComment.propTypes = { bannedWords: PropTypes.arrayOf(PropTypes.string).isRequired, toggleSelect: PropTypes.func, comment: PropTypes.shape({ + id: PropTypes.string.isRequired, + status: PropTypes.string.isRequired, body: PropTypes.string.isRequired, actions: PropTypes.array, created_at: PropTypes.string.isRequired, diff --git a/client/coral-admin/src/containers/CommentDetails.js b/client/coral-admin/src/containers/CommentDetails.js new file mode 100644 index 000000000..a72a8eee4 --- /dev/null +++ b/client/coral-admin/src/containers/CommentDetails.js @@ -0,0 +1,23 @@ +import {gql} from 'react-apollo'; +import CommentDetails from '../components/CommentDetails'; +import {getSlotFragmentSpreads} from 'coral-framework/utils'; +import withFragments from 'coral-framework/hocs/withFragments'; + +const slots = [ + 'adminCommentDetailArea', +]; + +export default withFragments({ + root: gql` + fragment CoralAdmin_CommentDetails_root on RootQuery { + __typename + ${getSlotFragmentSpreads(slots, 'root')} + } + `, + comment: gql` + fragment CoralAdmin_CommentDetails_comment on Comment { + __typename + ${getSlotFragmentSpreads(slots, 'comment')} + } + ` +})(CommentDetails); diff --git a/client/coral-admin/src/containers/CommentLabels.js b/client/coral-admin/src/containers/CommentLabels.js index af6a0d963..1942d1ad0 100644 --- a/client/coral-admin/src/containers/CommentLabels.js +++ b/client/coral-admin/src/containers/CommentLabels.js @@ -8,6 +8,12 @@ const slots = [ ]; export default withFragments({ + root: gql` + fragment CoralAdmin_CommentLabels_root on RootQuery { + __typename + ${getSlotFragmentSpreads(slots, 'root')} + } + `, comment: gql` fragment CoralAdmin_CommentLabels_comment on Comment { hasParent diff --git a/client/coral-admin/src/containers/UserDetail.js b/client/coral-admin/src/containers/UserDetail.js index 5effb2b84..2ae842b1d 100644 --- a/client/coral-admin/src/containers/UserDetail.js +++ b/client/coral-admin/src/containers/UserDetail.js @@ -160,8 +160,10 @@ export const withUserDetailQuery = withQuery(gql` }) { ...CoralAdmin_Moderation_CommentConnection } + ...${getDefinitionName(UserDetailComment.fragments.root)} ${getSlotFragmentSpreads(slots, 'root')} } + ${UserDetailComment.fragments.root} ${commentConnectionFragment} `, { options: ({userId, statuses}) => { diff --git a/client/coral-admin/src/containers/UserDetailComment.js b/client/coral-admin/src/containers/UserDetailComment.js index 6b3572434..9eef5934f 100644 --- a/client/coral-admin/src/containers/UserDetailComment.js +++ b/client/coral-admin/src/containers/UserDetailComment.js @@ -3,10 +3,20 @@ import UserDetailComment from '../components/UserDetailComment'; import withFragments from 'coral-framework/hocs/withFragments'; import {getDefinitionName} from 'coral-framework/utils'; import CommentLabels from './CommentLabels'; +import CommentDetails from './CommentDetails'; export default withFragments({ + root: gql` + fragment CoralAdmin_UserDetailComment_root on RootQuery { + __typename + ...${getDefinitionName(CommentLabels.fragments.root)} + ...${getDefinitionName(CommentDetails.fragments.root)} + } + ${CommentLabels.fragments.root} + ${CommentDetails.fragments.root} + `, comment: gql` - fragment CoralAdmin_UserDetail_comment on Comment { + fragment CoralAdmin_UserDetailComment_comment on Comment { id body created_at @@ -17,22 +27,13 @@ export default withFragments({ title url } - actions { - ... on FlagAction { - id - reason - message - user { - id - username - } - } - } editing { edited } ...${getDefinitionName(CommentLabels.fragments.comment)} + ...${getDefinitionName(CommentDetails.fragments.comment)} } ${CommentLabels.fragments.comment} + ${CommentDetails.fragments.comment} ` })(UserDetailComment); diff --git a/client/coral-admin/src/routes/Community/components/ActionButton.css b/client/coral-admin/src/routes/Community/components/ActionButton.css deleted file mode 100644 index 8f328e8b8..000000000 --- a/client/coral-admin/src/routes/Community/components/ActionButton.css +++ /dev/null @@ -1,4 +0,0 @@ -.actionButton { - transform: scale(.8); - margin: 0; -} diff --git a/client/coral-admin/src/routes/Community/components/ActionButton.js b/client/coral-admin/src/routes/Community/components/ActionButton.js deleted file mode 100644 index 0ef9b8a39..000000000 --- a/client/coral-admin/src/routes/Community/components/ActionButton.js +++ /dev/null @@ -1,22 +0,0 @@ -import React from 'react'; -import styles from './ActionButton.css'; -import {Button} from 'coral-ui'; -import {menuActionsMap} from '../../../utils/moderationQueueActionsMap'; - -import t from 'coral-framework/services/i18n'; - -// TODO: Needs refactoring. -const ActionButton = ({type = '', user, ...props}) => { - return ( - - ); -}; - -export default ActionButton; diff --git a/client/coral-admin/src/routes/Community/components/FlaggedAccounts.js b/client/coral-admin/src/routes/Community/components/FlaggedAccounts.js index 1d78c015a..e617def53 100644 --- a/client/coral-admin/src/routes/Community/components/FlaggedAccounts.js +++ b/client/coral-admin/src/routes/Community/components/FlaggedAccounts.js @@ -47,7 +47,6 @@ class FlaggedAccounts extends React.Component { this.props.viewUserDetail(this.props.user.id); + showRejectUsernameDialog = () => this.props.showRejectUsernameDialog({id: this.props.user.id}); + approveUser = () => this.props.approveUser({ + userId: this.props.user.id, + }); render() { const { user, - modActionButtons, viewUserDetail, selected, - approveUser, - showRejectUsernameDialog, me, className, } = this.props; @@ -125,14 +126,12 @@ class User extends React.Component {
    - {modActionButtons.map((action, i) => - - )} + +
    diff --git a/client/coral-admin/src/routes/Community/components/RejectUsernameDialog.js b/client/coral-admin/src/routes/Community/components/RejectUsernameDialog.js index a9877368a..20c411e52 100644 --- a/client/coral-admin/src/routes/Community/components/RejectUsernameDialog.js +++ b/client/coral-admin/src/routes/Community/components/RejectUsernameDialog.js @@ -51,7 +51,7 @@ class RejectUsernameDialog extends Component { const next = () => this.setState({stage: stage + 1}); const suspend = async () => { try { - await rejectUsername({id: user.user.id, message: this.state.email}); + await rejectUsername({id: user.id, message: this.state.email}); this.props.handleClose(); } catch (err) { diff --git a/client/coral-admin/src/routes/Community/containers/Community.js b/client/coral-admin/src/routes/Community/containers/Community.js index 4e60c64d7..6e20a3167 100644 --- a/client/coral-admin/src/routes/Community/containers/Community.js +++ b/client/coral-admin/src/routes/Community/containers/Community.js @@ -78,7 +78,11 @@ const withData = withQuery(gql` ${FlaggedAccounts.fragments.root} ${FlaggedUser.fragments.root} ${FlaggedUser.fragments.me} -`); +`, { + options: { + fetchPolicy: 'network-only', + }, +}); export default compose( connect(mapStateToProps, mapDispatchToProps), diff --git a/client/coral-admin/src/routes/Moderation/components/Comment.js b/client/coral-admin/src/routes/Moderation/components/Comment.js index c761ff591..42c9c2d13 100644 --- a/client/coral-admin/src/routes/Moderation/components/Comment.js +++ b/client/coral-admin/src/routes/Moderation/components/Comment.js @@ -8,13 +8,13 @@ import styles from './Comment.css'; import CommentLabels from 'coral-admin/src/components/CommentLabels'; import CommentAnimatedEdit from 'coral-admin/src/components/CommentAnimatedEdit'; import Slot from 'coral-framework/components/Slot'; -import {getActionSummary} from 'coral-framework/utils'; -import ActionButton from 'coral-admin/src/components/ActionButton'; import ActionsMenu from 'coral-admin/src/components/ActionsMenu'; import ActionsMenuItem from 'coral-admin/src/components/ActionsMenuItem'; import CommentBodyHighlighter from 'coral-admin/src/components/CommentBodyHighlighter'; import IfHasLink from 'coral-admin/src/components/IfHasLink'; import cn from 'classnames'; +import ApproveButton from 'coral-admin/src/components/ApproveButton'; +import RejectButton from 'coral-admin/src/components/RejectButton'; import t, {timeago} from 'coral-framework/services/i18n'; @@ -45,11 +45,19 @@ class Comment extends React.Component { return viewUserDetail(comment.user.id); }; + approve = () => (this.props.comment.status === 'ACCEPTED' + ? null + : this.props.acceptComment({commentId: this.props.comment.id}) + ); + + reject = () => (this.props.comment.status === 'REJECTED' + ? null + : this.props.rejectComment({commentId: this.props.comment.id}) + ); + render() { const { - actions = [], comment, - viewUserDetail, suspectWords, bannedWords, selected, @@ -58,15 +66,9 @@ class Comment extends React.Component { root, currentUserId, currentAsset, - acceptComment, - rejectComment, } = this.props; - const flagActionSummaries = getActionSummary('FlagActionSummary', comment); - const flagActions = comment.actions && comment.actions.filter((a) => a.__typename === 'FlagAction'); - const selectionStateCSS = selected ? 'mdl-shadow--16dp' : 'mdl-shadow--2dp'; - const queryData = {root, comment, asset: comment.asset}; return ( @@ -153,28 +155,14 @@ class Comment extends React.Component {
    - {actions.map((action, i) => { - const active = - (action === 'REJECT' && comment.status === 'REJECTED') || - (action === 'APPROVE' && comment.status === 'ACCEPTED'); - return ( - - (comment.status === 'ACCEPTED' - ? null - : acceptComment({commentId: comment.id}))} - rejectComment={() => - (comment.status === 'REJECTED' - ? null - : rejectComment({commentId: comment.id}))} - /> - ); - })} + +
    - {flagActions && flagActions.length - ? - : null} - ); @@ -214,6 +195,8 @@ Comment.propTypes = { showSuspendUserDialog: PropTypes.func.isRequired, currentUserId: PropTypes.string.isRequired, comment: PropTypes.shape({ + id: PropTypes.string.isRequired, + status: PropTypes.string.isRequired, body: PropTypes.string.isRequired, action_summaries: PropTypes.array, actions: PropTypes.array, @@ -230,7 +213,6 @@ Comment.propTypes = { }), data: PropTypes.object.isRequired, root: PropTypes.object.isRequired, - actions: PropTypes.array.isRequired, selected: PropTypes.bool, }; diff --git a/client/coral-admin/src/routes/Moderation/components/ModerationQueue.js b/client/coral-admin/src/routes/Moderation/components/ModerationQueue.js index 517892a77..47ed56925 100644 --- a/client/coral-admin/src/routes/Moderation/components/ModerationQueue.js +++ b/client/coral-admin/src/routes/Moderation/components/ModerationQueue.js @@ -4,7 +4,6 @@ import PropTypes from 'prop-types'; import Comment from '../containers/Comment'; import styles from './ModerationQueue.css'; import EmptyCard from '../../../components/EmptyCard'; -import {actionsMap} from '../../../utils/moderationQueueActionsMap'; import LoadMore from '../../../components/LoadMore'; import ViewMore from './ViewMore'; import t from 'coral-framework/services/i18n'; @@ -140,7 +139,6 @@ class ModerationQueue extends React.Component { if (singleView) { const index = comments.findIndex((comment) => comment.id === selectedCommentId); const comment = comments[index]; - const status = comment.action_summaries ? 'FLAGGED' : comment.status; return (
    { - const status = comment.action_summaries ? 'FLAGGED' : comment.status; return gql` organizationName moderation } + ...${getDefinitionName(Comment.fragments.root)} } + ${Comment.fragments.root} ${commentConnectionFragment} `, { options: (props) => { diff --git a/client/coral-admin/src/utils/moderationQueueActionsMap.js b/client/coral-admin/src/utils/moderationQueueActionsMap.js deleted file mode 100644 index 95b0ecb55..000000000 --- a/client/coral-admin/src/utils/moderationQueueActionsMap.js +++ /dev/null @@ -1,14 +0,0 @@ -export const actionsMap = { - PREMOD: ['APPROVE', 'REJECT'], - FLAGGED: ['APPROVE', 'REJECT'], - REJECTED: ['APPROVE', 'REJECTED'] -}; - -export const menuActionsMap = { - 'REJECT': {status: 'REJECTED', text: 'reject', icon: 'close', key: 'f'}, - 'REJECTED': {status: 'REJECTED', text: 'rejected', icon: 'close'}, - 'APPROVE': {status: 'ACCEPTED', text: 'approve', icon: 'done', key: 'd'}, - 'FLAGGED': {status: 'FLAGGED', text: 'flag', icon: 'flag', filter: 'Untouched'}, - 'BAN': {status: 'BANNED', text: 'ban_user', icon: 'not interested'}, - '': {icon: 'done'} -}; diff --git a/client/coral-ui/components/Button.css b/client/coral-ui/components/Button.css index 1b7efb205..ce2cff350 100644 --- a/client/coral-ui/components/Button.css +++ b/client/coral-ui/components/Button.css @@ -130,59 +130,6 @@ background: #00a291; } -.type--approve { - display: block; - color: #519954; - border: solid 2px rgba(81, 153, 84, 0.75); - background: white; - padding: 10px 12px; - box-sizing: border-box; - vertical-align: middle; - line-height: 24px; - font-size: 17px; - height: 47px; - border-radius: 3px; - text-transform: capitalize; - box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.03), 0 3px 1px -2px rgba(0,0,0,.2), 0 1px 5px 0 rgba(0,0,0,.09); - width: 129px; - - &:hover { - box-shadow: none; - color: white; - background-color: #519954; - } -} - -.type--reject, .type--rejected { - display: block; - color: #D03235; - border: solid 1px #D03235; - background: white; - padding: 10px 11px; - box-sizing: border-box; - vertical-align: middle; - line-height: 24px; - font-size: 17px; - height: 47px; - border-radius: 3px; - text-transform: capitalize; - box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.03), 0 3px 1px -2px rgba(0,0,0,.2), 0 1px 5px 0 rgba(0,0,0,.09); - width: 129px; - - &:hover { - color: white; - background-color: #D03235; - box-shadow: none; - } -} - -.type--rejected { - color: white; - background-color: #D03235; - box-shadow: none; - cursor: not-allowed; -} - .type--ban, .type--actions { display: block; color: #616161; diff --git a/plugins/talk-plugin-flag-details/.eslintrc.json b/plugins/talk-plugin-flag-details/.eslintrc.json new file mode 100644 index 000000000..78f7c2397 --- /dev/null +++ b/plugins/talk-plugin-flag-details/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "@coralproject/eslint-config-talk" +} diff --git a/plugins/talk-plugin-flag-details/client/.babelrc b/plugins/talk-plugin-flag-details/client/.babelrc new file mode 100644 index 000000000..60be246eb --- /dev/null +++ b/plugins/talk-plugin-flag-details/client/.babelrc @@ -0,0 +1,14 @@ +{ + "presets": [ + "es2015" + ], + "plugins": [ + "add-module-exports", + "transform-class-properties", + "transform-decorators-legacy", + "transform-object-assign", + "transform-object-rest-spread", + "transform-async-to-generator", + "transform-react-jsx" + ] +} \ No newline at end of file diff --git a/plugins/talk-plugin-flag-details/client/.eslintrc.json b/plugins/talk-plugin-flag-details/client/.eslintrc.json new file mode 100644 index 000000000..c8a6db18a --- /dev/null +++ b/plugins/talk-plugin-flag-details/client/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "@coralproject/eslint-config-talk/client" +} diff --git a/plugins/talk-plugin-flag-details/client/components/FlagDetails.css b/plugins/talk-plugin-flag-details/client/components/FlagDetails.css new file mode 100644 index 000000000..302e24858 --- /dev/null +++ b/plugins/talk-plugin-flag-details/client/components/FlagDetails.css @@ -0,0 +1,43 @@ + +.info { + vertical-align: middle; + list-style: none; + display: inline-block; + padding: 0; + font-size: 12px; +} + +.detail { + padding: 0; + list-style: none; + font-size: 12px; + font-weight: 500; +} + +.subDetail { + margin-left:10px; + padding: 0; + list-style: none; + font-size: 12px; + font-weight: normal; + color: #888; +} + +.lessDetail { + display: inline-block; + margin-right: 10px; +} + +.username { + color: #393B44; + text-decoration: none; + cursor: pointer; + font-weight: 600; + padding: 2px 5px; + border-radius: 2px; + margin-left: -5px; + transition: background-color 200ms ease; + &:hover { + background-color: #E0E0E0; + } +} diff --git a/plugins/talk-plugin-flag-details/client/components/FlagDetails.js b/plugins/talk-plugin-flag-details/client/components/FlagDetails.js new file mode 100644 index 000000000..0d415217d --- /dev/null +++ b/plugins/talk-plugin-flag-details/client/components/FlagDetails.js @@ -0,0 +1,79 @@ +import React, {Component} from 'react'; +import PropTypes from 'prop-types'; +import styles from './FlagDetails.css'; +import {t} from 'plugin-api/beta/client/services'; +import CommentDetail from 'coral-admin/src/components/CommentDetail'; + +class FlagDetails extends Component { + + render() { + const {comment: {actions}, viewUserDetail, more} = this.props; + + const flagActions = actions && actions.filter((a) => a.__typename === 'FlagAction'); + const summaries = flagActions.reduce((sum, action) => { + if (!(action.reason in sum)) { + sum[action.reason] = {count: 0, userFlagged: false, actions: []}; + } + sum[action.reason].count++; + if (action.user) { + sum[action.reason].userFlagged = true; + } + sum[action.reason].actions.push(action); + return sum; + }, {}); + + const userFlagReasons = Object.keys(summaries).filter((reason) => summaries[reason].userFlagged); + + return ( + + {Object.keys(summaries).map((reason) => +
  • + {reason} {summaries[reason].userFlagged && `(${summaries[reason].count})`} +
  • + )} + + }> + {more && userFlagReasons.length > 0 && ( + + )} +
    + ); + } +} + +FlagDetails.propTypes = { + more: PropTypes.bool, + comment: PropTypes.shape({ + actions: PropTypes.arrayOf(PropTypes.shape({ + message: PropTypes.string, + user: PropTypes.shape({username: PropTypes.string}) + })).isRequired, + }).isRequired, + viewUserDetail: PropTypes.func.isRequired, +}; + +export default FlagDetails; diff --git a/plugins/talk-plugin-flag-details/client/containers/FlagDetails.js b/plugins/talk-plugin-flag-details/client/containers/FlagDetails.js new file mode 100644 index 000000000..2ee88d2dd --- /dev/null +++ b/plugins/talk-plugin-flag-details/client/containers/FlagDetails.js @@ -0,0 +1,37 @@ +import {compose, gql} from 'react-apollo'; +import FlagDetails from '../components/FlagDetails'; +import {bindActionCreators} from 'redux'; +import {withFragments, excludeIf} from 'plugin-api/beta/client/hocs'; +import {viewUserDetail} from 'coral-admin/src/actions/userDetail'; +import {connect} from 'react-redux'; + +const mapDispatchToProps = (dispatch) => ({ + ...bindActionCreators({ + viewUserDetail, + }, dispatch) +}); + +const enhance = compose( + connect(null, mapDispatchToProps), + withFragments({ + comment: gql` + fragment CoralAdmin_FlagDetails_comment on Comment { + actions { + __typename + ... on FlagAction { + id + reason + message + user { + id + username + } + } + } + } + ` + }), + excludeIf(({comment: {actions}}) => !actions.some((action) => action.__typename === 'FlagAction')), +); + +export default enhance(FlagDetails); diff --git a/plugins/talk-plugin-flag-details/client/index.js b/plugins/talk-plugin-flag-details/client/index.js new file mode 100644 index 000000000..045194872 --- /dev/null +++ b/plugins/talk-plugin-flag-details/client/index.js @@ -0,0 +1,9 @@ +import FlagDetails from './containers/FlagDetails'; +import translations from './translations.yml'; + +export default { + translations, + slots: { + adminCommentDetailArea: [FlagDetails], + } +}; diff --git a/plugins/talk-plugin-flag-details/client/translations.yml b/plugins/talk-plugin-flag-details/client/translations.yml new file mode 100644 index 000000000..3b2511025 --- /dev/null +++ b/plugins/talk-plugin-flag-details/client/translations.yml @@ -0,0 +1,3 @@ +en: + talk-plugin-fag-details: + diff --git a/plugins/talk-plugin-flag-details/index.js b/plugins/talk-plugin-flag-details/index.js new file mode 100644 index 000000000..f053ebf79 --- /dev/null +++ b/plugins/talk-plugin-flag-details/index.js @@ -0,0 +1 @@ +module.exports = {}; diff --git a/plugins/talk-plugin-toxic-comments/client/containers/ToxicDetail.js b/plugins/talk-plugin-toxic-comments/client/containers/ToxicDetail.js index 32b83fbb3..28f75de37 100644 --- a/plugins/talk-plugin-toxic-comments/client/containers/ToxicDetail.js +++ b/plugins/talk-plugin-toxic-comments/client/containers/ToxicDetail.js @@ -15,7 +15,7 @@ const enhance = compose( } }`, }), - excludeIf(({comment: {toxicity}}) => toxicity === null), + excludeIf(({comment: {toxicity}, more}) => !more || toxicity === null), ); export default enhance(ToxicDetail); From 90470b8331292fd235f9ecd77aea71d6f4533442 Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Fri, 29 Sep 2017 23:33:12 +0700 Subject: [PATCH 04/39] Make IfSlotIsEmpty and IfSloIsNotEmpty accept an array of slot names --- client/coral-framework/components/IfSlotIsEmpty.js | 7 ++++--- client/coral-framework/components/IfSlotIsNotEmpty.js | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/client/coral-framework/components/IfSlotIsEmpty.js b/client/coral-framework/components/IfSlotIsEmpty.js index 72dc8c988..51a849448 100644 --- a/client/coral-framework/components/IfSlotIsEmpty.js +++ b/client/coral-framework/components/IfSlotIsEmpty.js @@ -23,8 +23,9 @@ class IfSlotIsEmpty extends React.Component { } isSlotEmpty(props = this.props) { - const {slot, className: _a, reduxState, component: _b = 'div', children: _c, ...rest} = props; - return this.context.plugins.isSlotEmpty(slot, reduxState, rest); + const {slot, className: _a, reduxState, component: _b = 'div', children: _c, queryData, ...rest} = props; + const slots = Array.isArray(slot) ? slot : [slot]; + return slots.every((slot) => this.context.plugins.isSlotEmpty(slot, reduxState, rest, queryData)); } render() { @@ -34,7 +35,7 @@ class IfSlotIsEmpty extends React.Component { } IfSlotIsEmpty.propTypes = { - slot: PropTypes.string, + slot: PropTypes.oneOfType([PropTypes.string, PropTypes.array]), }; const mapStateToProps = (state) => ({ diff --git a/client/coral-framework/components/IfSlotIsNotEmpty.js b/client/coral-framework/components/IfSlotIsNotEmpty.js index 46e68fe60..6186e2166 100644 --- a/client/coral-framework/components/IfSlotIsNotEmpty.js +++ b/client/coral-framework/components/IfSlotIsNotEmpty.js @@ -23,8 +23,9 @@ class IfSlotIsNotEmpty extends React.Component { } isSlotEmpty(props = this.props) { - const {slot, className: _a, reduxState, component: _b = 'div', children: _c, ...rest} = props; - return this.context.plugins.isSlotEmpty(slot, reduxState, rest); + const {slot, className: _a, reduxState, component: _b = 'div', children: _c, queryData, ...rest} = props; + const slots = Array.isArray(slot) ? slot : [slot]; + return slots.every((slot) => this.context.plugins.isSlotEmpty(slot, reduxState, rest, queryData)); } render() { @@ -34,7 +35,7 @@ class IfSlotIsNotEmpty extends React.Component { } IfSlotIsNotEmpty.propTypes = { - slot: PropTypes.string, + slot: PropTypes.oneOfType([PropTypes.string, PropTypes.array]), }; const mapStateToProps = (state) => ({ From 9bd55b267e3d6b10400709efdb2616c0063b3a9b Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Fri, 29 Sep 2017 23:33:37 +0700 Subject: [PATCH 05/39] excludeIf now returns a new component --- client/coral-framework/hocs/excludeIf.js | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/client/coral-framework/hocs/excludeIf.js b/client/coral-framework/hocs/excludeIf.js index ec2f0f27a..524c97eb3 100644 --- a/client/coral-framework/hocs/excludeIf.js +++ b/client/coral-framework/hocs/excludeIf.js @@ -1,4 +1,19 @@ -export default (condition) => (BaseComponent) => { - BaseComponent.isExcluded = condition; - return BaseComponent; -}; +import React from 'react'; +import hoistStatics from 'recompose/hoistStatics'; + +/** + * ExcludeIf provides a property `emit: (eventName, value)` + * to the wrapped component. + */ +export default (condition) => hoistStatics((WrappedComponent) => { + class ExcludeIf extends React.Component { + render() { + return ; + } + } + + WrappedComponent.isExcluded = condition; + return ExcludeIf; +}); From 7d41421526eb7e826f042ca5781a34efd7019185 Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Fri, 29 Sep 2017 23:34:40 +0700 Subject: [PATCH 06/39] adminCommentMoreFlagDetails slot and more --- .../src/components/CommentDetail.css | 5 +- .../src/components/CommentDetails.css | 4 +- .../src/components/CommentDetails.js | 15 +++- .../src/components/FlagDetails.css | 43 ----------- .../coral-admin/src/components/FlagDetails.js | 75 ------------------- .../src/components/UserDetailComment.css | 1 + .../src/components/UserDetailComment.js | 4 +- .../src/containers/CommentDetails.js | 1 + .../routes/Moderation/components/Comment.css | 1 + .../client/components/FlagDetails.css | 2 + .../client/components/FlagDetails.js | 20 ++++- .../client/containers/FlagDetails.js | 12 +++ .../client/containers/ToxicCommentDetail.js | 10 +++ .../containers/ToxicCommentFlagDetail.js | 10 +++ .../client/containers/ToxicDetail.js | 3 +- .../client/index.js | 6 +- 16 files changed, 83 insertions(+), 129 deletions(-) delete mode 100644 client/coral-admin/src/components/FlagDetails.css delete mode 100644 client/coral-admin/src/components/FlagDetails.js create mode 100644 plugins/talk-plugin-toxic-comments/client/containers/ToxicCommentDetail.js create mode 100644 plugins/talk-plugin-toxic-comments/client/containers/ToxicCommentFlagDetail.js diff --git a/client/coral-admin/src/components/CommentDetail.css b/client/coral-admin/src/components/CommentDetail.css index 259d4e1c5..4806b9522 100644 --- a/client/coral-admin/src/components/CommentDetail.css +++ b/client/coral-admin/src/components/CommentDetail.css @@ -1,5 +1,4 @@ .root { - margin-left: 16px; } .headerContainer { @@ -25,6 +24,10 @@ .details { padding: 0 20px 16px; font-size: 12px; + + &:empty { + display: none; + } } .icon { diff --git a/client/coral-admin/src/components/CommentDetails.css b/client/coral-admin/src/components/CommentDetails.css index ff3679cc7..c34a32cb3 100644 --- a/client/coral-admin/src/components/CommentDetails.css +++ b/client/coral-admin/src/components/CommentDetails.css @@ -1,6 +1,6 @@ .root { - margin-top: 10px; - padding-top: 10px; + min-height: 24px; + padding: 0 16px; } .moreDetail { diff --git a/client/coral-admin/src/components/CommentDetails.js b/client/coral-admin/src/components/CommentDetails.js index d984ce0c1..cd504a40f 100644 --- a/client/coral-admin/src/components/CommentDetails.js +++ b/client/coral-admin/src/components/CommentDetails.js @@ -3,6 +3,7 @@ import PropTypes from 'prop-types'; import styles from './CommentDetails.css'; import t from 'coral-framework/services/i18n'; import Slot from 'coral-framework/components/Slot'; +import IfSlotIsNotEmpty from 'coral-framework/components/IfSlotIsNotEmpty'; class CommentDetails extends Component { state = { @@ -32,13 +33,25 @@ class CommentDetails extends Component { return ( ); } diff --git a/client/coral-admin/src/components/FlagDetails.css b/client/coral-admin/src/components/FlagDetails.css deleted file mode 100644 index 302e24858..000000000 --- a/client/coral-admin/src/components/FlagDetails.css +++ /dev/null @@ -1,43 +0,0 @@ - -.info { - vertical-align: middle; - list-style: none; - display: inline-block; - padding: 0; - font-size: 12px; -} - -.detail { - padding: 0; - list-style: none; - font-size: 12px; - font-weight: 500; -} - -.subDetail { - margin-left:10px; - padding: 0; - list-style: none; - font-size: 12px; - font-weight: normal; - color: #888; -} - -.lessDetail { - display: inline-block; - margin-right: 10px; -} - -.username { - color: #393B44; - text-decoration: none; - cursor: pointer; - font-weight: 600; - padding: 2px 5px; - border-radius: 2px; - margin-left: -5px; - transition: background-color 200ms ease; - &:hover { - background-color: #E0E0E0; - } -} diff --git a/client/coral-admin/src/components/FlagDetails.js b/client/coral-admin/src/components/FlagDetails.js deleted file mode 100644 index 74bff8f24..000000000 --- a/client/coral-admin/src/components/FlagDetails.js +++ /dev/null @@ -1,75 +0,0 @@ -import React, {Component} from 'react'; -import PropTypes from 'prop-types'; -import styles from './FlagDetails.css'; -import t from 'coral-framework/services/i18n'; -import CommentDetail from './CommentDetail'; - -class FlagDetails extends Component { - - render() { - const {actions, viewUserDetail, more} = this.props; - const summaries = actions.reduce((sum, action) => { - if (!(action.reason in sum)) { - sum[action.reason] = {count: 0, userFlagged: false, actions: []}; - } - sum[action.reason].count++; - if (action.user) { - sum[action.reason].userFlagged = true; - } - sum[action.reason].actions.push(action); - return sum; - }, {}); - - const userFlagReasons = Object.keys(summaries).filter((reason) => summaries[reason].userFlagged); - - return ( - - {Object.keys(summaries).map((reason) => -
  • - {reason} {summaries[reason].userFlagged && `(${summaries[reason].count})`} -
  • - )} - - }> - {more && userFlagReasons.length > 0 && ( - - )} -
    - ); - } -} - -FlagDetails.propTypes = { - more: PropTypes.bool, - actions: PropTypes.arrayOf(PropTypes.shape({ - message: PropTypes.string, - user: PropTypes.shape({username: PropTypes.string}) - })).isRequired, - viewUserDetail: PropTypes.func.isRequired, -}; - -export default FlagDetails; diff --git a/client/coral-admin/src/components/UserDetailComment.css b/client/coral-admin/src/components/UserDetailComment.css index d1e2b007a..50e37e28e 100644 --- a/client/coral-admin/src/components/UserDetailComment.css +++ b/client/coral-admin/src/components/UserDetailComment.css @@ -1,4 +1,5 @@ .root { + position: relative; display: block; margin: 0; border-bottom: 1px solid #e0e0e0; diff --git a/client/coral-admin/src/components/UserDetailComment.js b/client/coral-admin/src/components/UserDetailComment.js index 29f3242a1..f8d81ce8b 100644 --- a/client/coral-admin/src/components/UserDetailComment.js +++ b/client/coral-admin/src/components/UserDetailComment.js @@ -70,7 +70,7 @@ class UserDetailComment extends React.Component {
    -

    +

    {t('comment.view_context')} -

    +
    diff --git a/client/coral-admin/src/containers/CommentDetails.js b/client/coral-admin/src/containers/CommentDetails.js index a72a8eee4..cf8c2c307 100644 --- a/client/coral-admin/src/containers/CommentDetails.js +++ b/client/coral-admin/src/containers/CommentDetails.js @@ -5,6 +5,7 @@ import withFragments from 'coral-framework/hocs/withFragments'; const slots = [ 'adminCommentDetailArea', + 'adminCommentMoreDetails', ]; export default withFragments({ diff --git a/client/coral-admin/src/routes/Moderation/components/Comment.css b/client/coral-admin/src/routes/Moderation/components/Comment.css index a1862640f..10cc707fb 100644 --- a/client/coral-admin/src/routes/Moderation/components/Comment.css +++ b/client/coral-admin/src/routes/Moderation/components/Comment.css @@ -58,6 +58,7 @@ font-size: 14px; line-height: 1.5; font-weight: 300; + margin-bottom: 8px; } .body { diff --git a/plugins/talk-plugin-flag-details/client/components/FlagDetails.css b/plugins/talk-plugin-flag-details/client/components/FlagDetails.css index 302e24858..3b59653c2 100644 --- a/plugins/talk-plugin-flag-details/client/components/FlagDetails.css +++ b/plugins/talk-plugin-flag-details/client/components/FlagDetails.css @@ -5,9 +5,11 @@ display: inline-block; padding: 0; font-size: 12px; + margin: 0; } .detail { + margin: 0; padding: 0; list-style: none; font-size: 12px; diff --git a/plugins/talk-plugin-flag-details/client/components/FlagDetails.js b/plugins/talk-plugin-flag-details/client/components/FlagDetails.js index 0d415217d..eadd779d9 100644 --- a/plugins/talk-plugin-flag-details/client/components/FlagDetails.js +++ b/plugins/talk-plugin-flag-details/client/components/FlagDetails.js @@ -3,11 +3,12 @@ import PropTypes from 'prop-types'; import styles from './FlagDetails.css'; import {t} from 'plugin-api/beta/client/services'; import CommentDetail from 'coral-admin/src/components/CommentDetail'; +import {Slot, IfSlotIsNotEmpty} from 'plugin-api/beta/client/components'; class FlagDetails extends Component { render() { - const {comment: {actions}, viewUserDetail, more} = this.props; + const {comment: {actions}, viewUserDetail, more, data, root, comment} = this.props; const flagActions = actions && actions.filter((a) => a.__typename === 'FlagAction'); const summaries = flagActions.reduce((sum, action) => { @@ -24,6 +25,11 @@ class FlagDetails extends Component { const userFlagReasons = Object.keys(summaries).filter((reason) => summaries[reason].userFlagged); + const queryData = { + root, + comment, + }; + return ( )} + {more && ( + + + + )} ); } diff --git a/plugins/talk-plugin-flag-details/client/containers/FlagDetails.js b/plugins/talk-plugin-flag-details/client/containers/FlagDetails.js index 2ee88d2dd..5c22e66d5 100644 --- a/plugins/talk-plugin-flag-details/client/containers/FlagDetails.js +++ b/plugins/talk-plugin-flag-details/client/containers/FlagDetails.js @@ -4,6 +4,11 @@ import {bindActionCreators} from 'redux'; import {withFragments, excludeIf} from 'plugin-api/beta/client/hocs'; import {viewUserDetail} from 'coral-admin/src/actions/userDetail'; import {connect} from 'react-redux'; +import {getSlotFragmentSpreads} from 'plugin-api/beta/client/utils'; + +const slots = [ + 'adminCommentMoreFlagDetails', +]; const mapDispatchToProps = (dispatch) => ({ ...bindActionCreators({ @@ -14,6 +19,12 @@ const mapDispatchToProps = (dispatch) => ({ const enhance = compose( connect(null, mapDispatchToProps), withFragments({ + root: gql` + fragment CoralAdmin_FlagDetails_root on RootQuery { + __typename + ${getSlotFragmentSpreads(slots, 'root')} + } + `, comment: gql` fragment CoralAdmin_FlagDetails_comment on Comment { actions { @@ -28,6 +39,7 @@ const enhance = compose( } } } + ${getSlotFragmentSpreads(slots, 'comment')} } ` }), diff --git a/plugins/talk-plugin-toxic-comments/client/containers/ToxicCommentDetail.js b/plugins/talk-plugin-toxic-comments/client/containers/ToxicCommentDetail.js new file mode 100644 index 000000000..5c98fc29d --- /dev/null +++ b/plugins/talk-plugin-toxic-comments/client/containers/ToxicCommentDetail.js @@ -0,0 +1,10 @@ +import {compose} from 'react-apollo'; +import {excludeIf} from 'plugin-api/beta/client/hocs'; +import ToxicDetail from './ToxicDetail'; +import {isToxic} from '../utils'; + +const enhance = compose( + excludeIf(({comment: {toxicity, actions}}) => toxicity === null || isToxic(actions)), +); + +export default enhance(ToxicDetail); diff --git a/plugins/talk-plugin-toxic-comments/client/containers/ToxicCommentFlagDetail.js b/plugins/talk-plugin-toxic-comments/client/containers/ToxicCommentFlagDetail.js new file mode 100644 index 000000000..a43501ea4 --- /dev/null +++ b/plugins/talk-plugin-toxic-comments/client/containers/ToxicCommentFlagDetail.js @@ -0,0 +1,10 @@ +import {compose} from 'react-apollo'; +import {excludeIf} from 'plugin-api/beta/client/hocs'; +import ToxicDetail from './ToxicDetail'; +import {isToxic} from '../utils'; + +const enhance = compose( + excludeIf(({comment: {toxicity, actions}}) => toxicity === null || !isToxic(actions)), +); + +export default enhance(ToxicDetail); diff --git a/plugins/talk-plugin-toxic-comments/client/containers/ToxicDetail.js b/plugins/talk-plugin-toxic-comments/client/containers/ToxicDetail.js index 28f75de37..78681261a 100644 --- a/plugins/talk-plugin-toxic-comments/client/containers/ToxicDetail.js +++ b/plugins/talk-plugin-toxic-comments/client/containers/ToxicDetail.js @@ -1,5 +1,5 @@ import {compose, gql} from 'react-apollo'; -import {withFragments, excludeIf} from 'plugin-api/beta/client/hocs'; +import {withFragments} from 'plugin-api/beta/client/hocs'; import ToxicDetail from '../components/ToxicDetail'; const enhance = compose( @@ -15,7 +15,6 @@ const enhance = compose( } }`, }), - excludeIf(({comment: {toxicity}, more}) => !more || toxicity === null), ); export default enhance(ToxicDetail); diff --git a/plugins/talk-plugin-toxic-comments/client/index.js b/plugins/talk-plugin-toxic-comments/client/index.js index 1db520891..742e002d1 100644 --- a/plugins/talk-plugin-toxic-comments/client/index.js +++ b/plugins/talk-plugin-toxic-comments/client/index.js @@ -1,13 +1,15 @@ import translations from './translations.yml'; import CheckToxicityHook from './containers/CheckToxicityHook'; import ToxicLabel from './containers/ToxicLabel'; -import ToxicDetail from './containers/ToxicDetail'; +import ToxicCommentDetail from './containers/ToxicCommentDetail'; +import ToxicCommentFlagDetail from './containers/ToxicCommentFlagDetail'; export default { translations, slots: { commentInputDetailArea: [CheckToxicityHook], adminCommentLabels: [ToxicLabel], - adminCommentDetailArea: [ToxicDetail], + adminCommentMoreDetails: [ToxicCommentDetail], + adminCommentMoreFlagDetails: [ToxicCommentFlagDetail], }, }; From 43cb0efe7e31bbd30f317115067e57813de19784 Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Mon, 2 Oct 2017 01:03:20 -0300 Subject: [PATCH 07/39] bug: usertags --- .../coral-embed-stream/src/graphql/index.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/client/coral-embed-stream/src/graphql/index.js b/client/coral-embed-stream/src/graphql/index.js index 20ed8a1d6..228efb25b 100644 --- a/client/coral-embed-stream/src/graphql/index.js +++ b/client/coral-embed-stream/src/graphql/index.js @@ -96,6 +96,11 @@ export default { user { id username + tags { + tag { + name + } + } } action_summaries { count @@ -129,7 +134,19 @@ export default { user: { __typename: 'User', id: auth.user.id, - username: auth.user.username + username: auth.user.username, + tags: tags.map((tag) => ({ + tag: { + name: tag, + created_at: new Date().toISOString(), + __typename: 'Tag' + }, + assigned_by: { + id: auth.user.id, + __typename: 'User' + }, + __typename: 'TagLink' + })), }, created_at: new Date().toISOString(), body, From 7aaad6ccd9078443fed94312ddedecc8a32b4e3f Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Mon, 2 Oct 2017 01:06:08 -0300 Subject: [PATCH 08/39] Adds subscriber plugin --- .eslintignore | 1 + .gitignore | 1 + .../talk-plugin-subscriber/client/.babelrc | 14 +++++++++++ .../client/.eslintrc.json | 23 ++++++++++++++++++ .../client/components/SubscriberBadge.css | 12 ++++++++++ .../client/components/SubscriberBadge.js | 9 +++++++ .../client/containers/SubscriberBadge.js | 24 +++++++++++++++++++ .../talk-plugin-subscriber/client/index.js | 10 ++++++++ .../client/translations.yml | 6 +++++ plugins/talk-plugin-subscriber/index.js | 14 +++++++++++ plugins/talk-plugin-subscriber/package.json | 11 +++++++++ plugins/talk-plugin-subscriber/yarn.lock | 11 +++++++++ 12 files changed, 136 insertions(+) create mode 100644 plugins/talk-plugin-subscriber/client/.babelrc create mode 100644 plugins/talk-plugin-subscriber/client/.eslintrc.json create mode 100644 plugins/talk-plugin-subscriber/client/components/SubscriberBadge.css create mode 100644 plugins/talk-plugin-subscriber/client/components/SubscriberBadge.js create mode 100644 plugins/talk-plugin-subscriber/client/containers/SubscriberBadge.js create mode 100644 plugins/talk-plugin-subscriber/client/index.js create mode 100644 plugins/talk-plugin-subscriber/client/translations.yml create mode 100644 plugins/talk-plugin-subscriber/index.js create mode 100644 plugins/talk-plugin-subscriber/package.json create mode 100644 plugins/talk-plugin-subscriber/yarn.lock diff --git a/.eslintignore b/.eslintignore index fc0214dd2..a5f6aa1a2 100644 --- a/.eslintignore +++ b/.eslintignore @@ -26,5 +26,6 @@ plugins/* !plugins/talk-plugin-toxic-comments !plugins/talk-plugin-remember-sort !plugins/talk-plugin-deep-reply-count +!plugins/talk-plugin-subscriber node_modules diff --git a/.gitignore b/.gitignore index bcc7c89b1..7ccad87c4 100644 --- a/.gitignore +++ b/.gitignore @@ -43,5 +43,6 @@ plugins/* !plugins/talk-plugin-toxic-comments !plugins/talk-plugin-remember-sort !plugins/talk-plugin-deep-reply-count +!plugins/talk-plugin-subscriber **/node_modules/* diff --git a/plugins/talk-plugin-subscriber/client/.babelrc b/plugins/talk-plugin-subscriber/client/.babelrc new file mode 100644 index 000000000..60be246eb --- /dev/null +++ b/plugins/talk-plugin-subscriber/client/.babelrc @@ -0,0 +1,14 @@ +{ + "presets": [ + "es2015" + ], + "plugins": [ + "add-module-exports", + "transform-class-properties", + "transform-decorators-legacy", + "transform-object-assign", + "transform-object-rest-spread", + "transform-async-to-generator", + "transform-react-jsx" + ] +} \ No newline at end of file diff --git a/plugins/talk-plugin-subscriber/client/.eslintrc.json b/plugins/talk-plugin-subscriber/client/.eslintrc.json new file mode 100644 index 000000000..9fe56bd14 --- /dev/null +++ b/plugins/talk-plugin-subscriber/client/.eslintrc.json @@ -0,0 +1,23 @@ +{ + "env": { + "browser": true, + "es6": true, + "mocha": true + }, + "parserOptions": { + "sourceType": "module", + "ecmaFeatures": { + "experimentalObjectRestSpread": true, + "jsx": true + } + }, + "parser": "babel-eslint", + "plugins": [ + "react" + ], + "rules": { + "react/jsx-uses-react": "error", + "react/jsx-uses-vars": "error", + "no-console": ["warn", { "allow": ["warn", "error"] }] + } +} diff --git a/plugins/talk-plugin-subscriber/client/components/SubscriberBadge.css b/plugins/talk-plugin-subscriber/client/components/SubscriberBadge.css new file mode 100644 index 000000000..42edfd8ff --- /dev/null +++ b/plugins/talk-plugin-subscriber/client/components/SubscriberBadge.css @@ -0,0 +1,12 @@ +.badge { + background-color: #616161; + color: white; + display: inline-block; + margin: 0px 5px; + padding: 5px 5px; + border-radius: 2px; + font-size: 12px; + text-transform: uppercase; + letter-spacing: 0.6px; + font-weight: bold; +} \ No newline at end of file diff --git a/plugins/talk-plugin-subscriber/client/components/SubscriberBadge.js b/plugins/talk-plugin-subscriber/client/components/SubscriberBadge.js new file mode 100644 index 000000000..60fe19dc9 --- /dev/null +++ b/plugins/talk-plugin-subscriber/client/components/SubscriberBadge.js @@ -0,0 +1,9 @@ +import React from 'react'; +import styles from './SubscriberBadge.css'; +import {t} from 'plugin-api/beta/client/services'; + +export default () =>( + + {t('talk-plugin-subscriber.subscriber')} + +); diff --git a/plugins/talk-plugin-subscriber/client/containers/SubscriberBadge.js b/plugins/talk-plugin-subscriber/client/containers/SubscriberBadge.js new file mode 100644 index 000000000..a0789cf04 --- /dev/null +++ b/plugins/talk-plugin-subscriber/client/containers/SubscriberBadge.js @@ -0,0 +1,24 @@ +import React from 'react'; +import SubscriberBadge from '../components/SubscriberBadge'; +import {compose, gql} from 'react-apollo'; +import {withFragments, excludeIf} from 'plugin-api/beta/client/hocs'; + +const isSubscriber = (tags = []) => tags.some((t) => t.tag.name === 'SUBSCRIBER'); + +const enhance = compose( + withFragments({ + comment: gql` + fragment TalkSubscriberBadge_SubscriberBadge_comment on Comment { + user { + tags { + tag { + name + } + } + } + }` + }), + excludeIf(({comment}) => !isSubscriber(comment.user.tags)) +); + +export default enhance(SubscriberBadge); diff --git a/plugins/talk-plugin-subscriber/client/index.js b/plugins/talk-plugin-subscriber/client/index.js new file mode 100644 index 000000000..c01d84620 --- /dev/null +++ b/plugins/talk-plugin-subscriber/client/index.js @@ -0,0 +1,10 @@ +import SubscriberBadge from './containers/SubscriberBadge'; +import translations from './translations.yml'; +import {gql} from 'react-apollo'; + +export default { + translations, + slots: { + commentAuthorTags: [SubscriberBadge] + } +}; \ No newline at end of file diff --git a/plugins/talk-plugin-subscriber/client/translations.yml b/plugins/talk-plugin-subscriber/client/translations.yml new file mode 100644 index 000000000..851f818b7 --- /dev/null +++ b/plugins/talk-plugin-subscriber/client/translations.yml @@ -0,0 +1,6 @@ +en: + talk-plugin-subscriber: + subscriber: "Subscriber" +es: + talk-plugin-subscriber: + subscriber: "Subscriptor" diff --git a/plugins/talk-plugin-subscriber/index.js b/plugins/talk-plugin-subscriber/index.js new file mode 100644 index 000000000..ad47ef264 --- /dev/null +++ b/plugins/talk-plugin-subscriber/index.js @@ -0,0 +1,14 @@ +module.exports = { + tags: [ + { + name: 'SUBSCRIBER', + permissions: { + public: true, + self: false, + roles: [] + }, + models: ['USERS'], + created_at: new Date() + } + ] +}; diff --git a/plugins/talk-plugin-subscriber/package.json b/plugins/talk-plugin-subscriber/package.json new file mode 100644 index 000000000..4725abb9e --- /dev/null +++ b/plugins/talk-plugin-subscriber/package.json @@ -0,0 +1,11 @@ +{ + "name": "@coralproject/talk-plugin-subscriber", + "version": "0.1.0", + "description": "A Recipe to display a user badge", + "main": "index.js", + "author": "The Coral Project Team ", + "license": "Apache-2.0", + "dependencies": { + "moment": "^2.18.1" + } +} \ No newline at end of file diff --git a/plugins/talk-plugin-subscriber/yarn.lock b/plugins/talk-plugin-subscriber/yarn.lock new file mode 100644 index 000000000..60fdd97df --- /dev/null +++ b/plugins/talk-plugin-subscriber/yarn.lock @@ -0,0 +1,11 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +moment@^2.18.1: + version "2.18.1" + resolved "https://registry.yarnpkg.com/moment/-/moment-2.18.1.tgz#c36193dd3ce1c2eed2adb7c802dbbc77a81b1c0f" + +momentjs@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/momentjs/-/momentjs-2.0.0.tgz#73df904b4fa418f6e3c605e831cef6ed5518ebd4" From 02dff0c7263701811529f321685f4669fe888059 Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Mon, 2 Oct 2017 01:32:36 -0300 Subject: [PATCH 09/39] linting --- .../client/containers/SubscriberBadge.js | 1 - plugins/talk-plugin-subscriber/client/index.js | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/plugins/talk-plugin-subscriber/client/containers/SubscriberBadge.js b/plugins/talk-plugin-subscriber/client/containers/SubscriberBadge.js index a0789cf04..d00e5fc05 100644 --- a/plugins/talk-plugin-subscriber/client/containers/SubscriberBadge.js +++ b/plugins/talk-plugin-subscriber/client/containers/SubscriberBadge.js @@ -1,4 +1,3 @@ -import React from 'react'; import SubscriberBadge from '../components/SubscriberBadge'; import {compose, gql} from 'react-apollo'; import {withFragments, excludeIf} from 'plugin-api/beta/client/hocs'; diff --git a/plugins/talk-plugin-subscriber/client/index.js b/plugins/talk-plugin-subscriber/client/index.js index c01d84620..937191d41 100644 --- a/plugins/talk-plugin-subscriber/client/index.js +++ b/plugins/talk-plugin-subscriber/client/index.js @@ -1,10 +1,9 @@ import SubscriberBadge from './containers/SubscriberBadge'; import translations from './translations.yml'; -import {gql} from 'react-apollo'; export default { translations, slots: { commentAuthorTags: [SubscriberBadge] } -}; \ No newline at end of file +}; From 075d62a32a56356d5514f6ef59b7bc83a44c9652 Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Mon, 2 Oct 2017 20:50:43 +0700 Subject: [PATCH 10/39] Move CommentDetails to plugin-api --- .../src => coral-framework}/components/CommentDetail.css | 0 .../src => coral-framework}/components/CommentDetail.js | 0 plugin-api/beta/client/components/index.js | 1 + .../talk-plugin-flag-details/client/components/FlagDetails.js | 3 +-- .../client/components/ToxicDetail.js | 2 +- 5 files changed, 3 insertions(+), 3 deletions(-) rename client/{coral-admin/src => coral-framework}/components/CommentDetail.css (100%) rename client/{coral-admin/src => coral-framework}/components/CommentDetail.js (100%) diff --git a/client/coral-admin/src/components/CommentDetail.css b/client/coral-framework/components/CommentDetail.css similarity index 100% rename from client/coral-admin/src/components/CommentDetail.css rename to client/coral-framework/components/CommentDetail.css diff --git a/client/coral-admin/src/components/CommentDetail.js b/client/coral-framework/components/CommentDetail.js similarity index 100% rename from client/coral-admin/src/components/CommentDetail.js rename to client/coral-framework/components/CommentDetail.js diff --git a/plugin-api/beta/client/components/index.js b/plugin-api/beta/client/components/index.js index a0ae0f3da..b87dec73b 100644 --- a/plugin-api/beta/client/components/index.js +++ b/plugin-api/beta/client/components/index.js @@ -4,3 +4,4 @@ export {default as IfSlotIsEmpty} from 'coral-framework/components/IfSlotIsEmpty export {default as IfSlotIsNotEmpty} from 'coral-framework/components/IfSlotIsNotEmpty'; export {default as CommentAuthorName} from 'coral-framework/components/CommentAuthorName'; export {default as CommentTimestamp} from 'coral-framework/components/CommentTimestamp'; +export {default as CommentDetail} from 'coral-framework/components/CommentDetail'; diff --git a/plugins/talk-plugin-flag-details/client/components/FlagDetails.js b/plugins/talk-plugin-flag-details/client/components/FlagDetails.js index eadd779d9..3b1f222da 100644 --- a/plugins/talk-plugin-flag-details/client/components/FlagDetails.js +++ b/plugins/talk-plugin-flag-details/client/components/FlagDetails.js @@ -2,8 +2,7 @@ import React, {Component} from 'react'; import PropTypes from 'prop-types'; import styles from './FlagDetails.css'; import {t} from 'plugin-api/beta/client/services'; -import CommentDetail from 'coral-admin/src/components/CommentDetail'; -import {Slot, IfSlotIsNotEmpty} from 'plugin-api/beta/client/components'; +import {Slot, IfSlotIsNotEmpty, CommentDetail} from 'plugin-api/beta/client/components'; class FlagDetails extends Component { diff --git a/plugins/talk-plugin-toxic-comments/client/components/ToxicDetail.js b/plugins/talk-plugin-toxic-comments/client/components/ToxicDetail.js index de8a0337c..3726d2b77 100644 --- a/plugins/talk-plugin-toxic-comments/client/components/ToxicDetail.js +++ b/plugins/talk-plugin-toxic-comments/client/components/ToxicDetail.js @@ -1,5 +1,5 @@ import React from 'react'; -import CommentDetail from 'coral-admin/src/components/CommentDetail'; +import {CommentDetail} from 'plugin-api/beta/client/components'; import {isToxic} from '../utils'; import styles from './ToxicDetail.css'; import cn from 'classnames'; From 9b39017f25b2d6671036ec64e275a12e7eb54737 Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Mon, 2 Oct 2017 20:54:49 +0700 Subject: [PATCH 11/39] Export viewUserDetail in plugin-api --- plugin-api/beta/client/actions/admin.js | 1 + .../talk-plugin-flag-details/client/containers/FlagDetails.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 plugin-api/beta/client/actions/admin.js diff --git a/plugin-api/beta/client/actions/admin.js b/plugin-api/beta/client/actions/admin.js new file mode 100644 index 000000000..2a32e57bf --- /dev/null +++ b/plugin-api/beta/client/actions/admin.js @@ -0,0 +1 @@ +export {viewUserDetail} from 'coral-admin/src/actions/userDetail'; diff --git a/plugins/talk-plugin-flag-details/client/containers/FlagDetails.js b/plugins/talk-plugin-flag-details/client/containers/FlagDetails.js index 5c22e66d5..5a9bb3cae 100644 --- a/plugins/talk-plugin-flag-details/client/containers/FlagDetails.js +++ b/plugins/talk-plugin-flag-details/client/containers/FlagDetails.js @@ -2,7 +2,7 @@ import {compose, gql} from 'react-apollo'; import FlagDetails from '../components/FlagDetails'; import {bindActionCreators} from 'redux'; import {withFragments, excludeIf} from 'plugin-api/beta/client/hocs'; -import {viewUserDetail} from 'coral-admin/src/actions/userDetail'; +import {viewUserDetail} from 'plugin-api/beta/client/actions/admin'; import {connect} from 'react-redux'; import {getSlotFragmentSpreads} from 'plugin-api/beta/client/utils'; From c2f22bbf98a5abc284f7e1ecdfe669fafb1bb851 Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Mon, 2 Oct 2017 21:37:47 +0700 Subject: [PATCH 12/39] Implement user flag details as slot component --- .../client/components/FlagDetails.js | 36 ++--------- .../client/components/UserFlagDetails.css | 45 ++++++++++++++ .../client/components/UserFlagDetails.js | 59 +++++++++++++++++++ .../client/containers/FlagDetails.js | 10 ---- .../client/containers/UserFlagDetails.js | 39 ++++++++++++ .../talk-plugin-flag-details/client/index.js | 2 + 6 files changed, 151 insertions(+), 40 deletions(-) create mode 100644 plugins/talk-plugin-flag-details/client/components/UserFlagDetails.css create mode 100644 plugins/talk-plugin-flag-details/client/components/UserFlagDetails.js create mode 100644 plugins/talk-plugin-flag-details/client/containers/UserFlagDetails.js diff --git a/plugins/talk-plugin-flag-details/client/components/FlagDetails.js b/plugins/talk-plugin-flag-details/client/components/FlagDetails.js index 3b1f222da..026aebd95 100644 --- a/plugins/talk-plugin-flag-details/client/components/FlagDetails.js +++ b/plugins/talk-plugin-flag-details/client/components/FlagDetails.js @@ -7,23 +7,21 @@ import {Slot, IfSlotIsNotEmpty, CommentDetail} from 'plugin-api/beta/client/comp class FlagDetails extends Component { render() { - const {comment: {actions}, viewUserDetail, more, data, root, comment} = this.props; + const {comment: {actions}, more, data, root, comment} = this.props; const flagActions = actions && actions.filter((a) => a.__typename === 'FlagAction'); const summaries = flagActions.reduce((sum, action) => { if (!(action.reason in sum)) { - sum[action.reason] = {count: 0, userFlagged: false, actions: []}; + sum[action.reason] = {count: 0, actions: []}; } sum[action.reason].count++; if (action.user) { sum[action.reason].userFlagged = true; } - sum[action.reason].actions.push(action); return sum; }, {}); - const userFlagReasons = Object.keys(summaries).filter((reason) => summaries[reason].userFlagged); - + const reasons = Object.keys(summaries); const queryData = { root, comment, @@ -35,36 +33,13 @@ class FlagDetails extends Component { header={`${t('community.flags')} (${Object.keys(summaries).length})`} info={
      - {Object.keys(summaries).map((reason) => + {reasons.map((reason) =>
    • {reason} {summaries[reason].userFlagged && `(${summaries[reason].count})`}
    • )}
    }> - {more && userFlagReasons.length > 0 && ( - - )} {more && ( a.__typename === 'FlagAction'); + const summaries = flagActions.reduce((sum, action) => { + if (!action.user) { + return sum; + } + if (!(action.reason in sum)) { + sum[action.reason] = {count: 0, actions: []}; + } + sum[action.reason].count++; + sum[action.reason].actions.push(action); + return sum; + }, {}); + + return ( + + ); + } +} + +UserFlagDetails.propTypes = { + comment: PropTypes.shape({ + actions: PropTypes.arrayOf(PropTypes.shape({ + message: PropTypes.string, + user: PropTypes.shape({username: PropTypes.string}) + })).isRequired, + }).isRequired, + viewUserDetail: PropTypes.func.isRequired, +}; + +export default UserFlagDetails; diff --git a/plugins/talk-plugin-flag-details/client/containers/FlagDetails.js b/plugins/talk-plugin-flag-details/client/containers/FlagDetails.js index 5a9bb3cae..da04dd65f 100644 --- a/plugins/talk-plugin-flag-details/client/containers/FlagDetails.js +++ b/plugins/talk-plugin-flag-details/client/containers/FlagDetails.js @@ -1,23 +1,13 @@ import {compose, gql} from 'react-apollo'; import FlagDetails from '../components/FlagDetails'; -import {bindActionCreators} from 'redux'; import {withFragments, excludeIf} from 'plugin-api/beta/client/hocs'; -import {viewUserDetail} from 'plugin-api/beta/client/actions/admin'; -import {connect} from 'react-redux'; import {getSlotFragmentSpreads} from 'plugin-api/beta/client/utils'; const slots = [ 'adminCommentMoreFlagDetails', ]; -const mapDispatchToProps = (dispatch) => ({ - ...bindActionCreators({ - viewUserDetail, - }, dispatch) -}); - const enhance = compose( - connect(null, mapDispatchToProps), withFragments({ root: gql` fragment CoralAdmin_FlagDetails_root on RootQuery { diff --git a/plugins/talk-plugin-flag-details/client/containers/UserFlagDetails.js b/plugins/talk-plugin-flag-details/client/containers/UserFlagDetails.js new file mode 100644 index 000000000..aedbb1de5 --- /dev/null +++ b/plugins/talk-plugin-flag-details/client/containers/UserFlagDetails.js @@ -0,0 +1,39 @@ +import {compose, gql} from 'react-apollo'; +import UserFlagDetails from '../components/UserFlagDetails'; +import {bindActionCreators} from 'redux'; +import {withFragments, excludeIf} from 'plugin-api/beta/client/hocs'; +import {viewUserDetail} from 'plugin-api/beta/client/actions/admin'; +import {connect} from 'react-redux'; + +const mapDispatchToProps = (dispatch) => ({ + ...bindActionCreators({ + viewUserDetail, + }, dispatch) +}); + +const enhance = compose( + connect(null, mapDispatchToProps), + withFragments({ + comment: gql` + fragment CoralAdmin_UserFlagDetails_comment on Comment { + actions { + __typename + ... on FlagAction { + id + reason + message + user { + id + username + } + } + } + } + ` + }), + excludeIf(({comment: {actions}}) => + !actions.some((action) => action.__typename === 'FlagAction' && action.user + )), +); + +export default enhance(UserFlagDetails); diff --git a/plugins/talk-plugin-flag-details/client/index.js b/plugins/talk-plugin-flag-details/client/index.js index 045194872..95f579da5 100644 --- a/plugins/talk-plugin-flag-details/client/index.js +++ b/plugins/talk-plugin-flag-details/client/index.js @@ -1,9 +1,11 @@ import FlagDetails from './containers/FlagDetails'; +import UserFlagDetails from './containers/UserFlagDetails'; import translations from './translations.yml'; export default { translations, slots: { adminCommentDetailArea: [FlagDetails], + adminCommentMoreFlagDetails: [UserFlagDetails], } }; From d3d7f909d85c94bc6556729c2df3e41f97953167 Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Mon, 2 Oct 2017 22:22:00 +0700 Subject: [PATCH 13/39] Translations --- locales/en.yml | 5 ----- locales/es.yml | 5 ----- locales/fr.yml | 5 ----- locales/pt_BR.yml | 4 ---- .../client/components/FlagDetails.js | 2 +- .../talk-plugin-flag-details/client/translations.yml | 7 +++++-- .../client/components/ToxicDetail.js | 11 ++++++----- .../client/translations.yml | 5 +++++ 8 files changed, 17 insertions(+), 27 deletions(-) diff --git a/locales/en.yml b/locales/en.yml index 13ca8eb14..0c13fe1cc 100644 --- a/locales/en.yml +++ b/locales/en.yml @@ -262,11 +262,9 @@ en: ban_user: "Ban" billion: B close: Close - dont_like_username: "Don't like username" empty_queue: "No more comments to moderate! You're all caught up. Go have some ☕️" flagged: flagged reported: reported - impersonating: Impersonating less_detail: "Less detail" likes: likes million: M @@ -277,9 +275,7 @@ en: newest_first: "Newest First" navigation: Navigation next_comment: "Go to the next comment" - offensive: Offensive oldest_first: "Oldest First" - other: Other premod: pre-mod prev_comment: "Go to the previous comment" reject: "Reject" @@ -290,7 +286,6 @@ en: shortcuts: "Shortcuts" show_shortcuts: "Show Shortcuts" singleview: "Toggle single comment edit view" - spam_ads: Spam/Ads thismenu: "Open this menu" thousand: k try_these: "Try these" diff --git a/locales/es.yml b/locales/es.yml index 4cb630273..e9844667d 100644 --- a/locales/es.yml +++ b/locales/es.yml @@ -255,10 +255,8 @@ es: approved: "Aprobado" billion: B close: Cerrar - dont_like_username: "No me gusta el nombre de usuario" empty_queue: "¡No hay más comentarios para moderar! Tiempo para un ☕️" flagged: Reportado - impersonating: Impersonando less_detail: "Menos detalles" likes: likes million: M @@ -269,9 +267,7 @@ es: newest_first: "Primero el más nuevo" navigation: Navegación next_comment: "Ir al siguiente comentario" - offensive: Ofensivo oldest_first: "Primero el más antiguo" - other: Otro premod: pre-mod prev_comment: "Ir al comentario anterior" reject: "Rechazar" @@ -282,7 +278,6 @@ es: shortcuts: Atajos show_shortcuts: "Mostrar Atajos" singleview: "Colocar vista de edición de comentario único" - spam_ads: Spam/Publicidad thismenu: "Abrir este menu" thousand: k try_these: "Intentar estos" diff --git a/locales/fr.yml b/locales/fr.yml index 1370d47c6..11a46d38f 100644 --- a/locales/fr.yml +++ b/locales/fr.yml @@ -41,22 +41,17 @@ fr: banned: Banni banned_user: "Utilisateur banni" cancel: Signalé - dont_like_username: "Je n'aime pas ce nom d'utilisateur" flaggedaccounts: "Noms d'utilisateurs signalés" flags: Signalements - impersonating: "Cet utilisateur se fait passer pour quelqu'un d'autre" loading: "Chargement des résultats" moderator: Modérateur newsroom_role: "Rôle de la salle de presse" no_flagged_accounts: "La liste des comptes signalés est vide." no_results: "Aucun utilisateur n'a été trouvé avec ce nom d'utilisateur ou cette adresse de messagerie. Ils se cachent !" note: "Remarque: bannir cet utilisateur ne lui permettra pas de modifier les commentaires ou de supprimer quoi que ce soit." - offensive: "Ce commentaire est offensant" - other: Autre people: Gens role: "Sélectionnez le rôle ..." select_status: "Sélectionnez l'état ..." - spam_ads: "Spam / Annonces" staff: "Équipe" status: Statut username_and_email: "Nom d'utilisateur et e-mail" diff --git a/locales/pt_BR.yml b/locales/pt_BR.yml index 99c39fe41..82f160525 100644 --- a/locales/pt_BR.yml +++ b/locales/pt_BR.yml @@ -51,7 +51,6 @@ pt_BR: banned: Proibida banned_user: "Usuário proibido" cancel: Cancelar - dont_like_username: "Não gostei do nome de usuário" flaggedaccounts: "Nomes de usuários marcados" flags: Marcadas impersonating: "Representação" @@ -60,12 +59,9 @@ pt_BR: newsroom_role: "Papel de empresa" no_flagged_accounts: "A fila de nomes de usuários marcados está atualmente vazia." no_results: "Nenhum usuário encontrado com esse nome de usuário ou e-mail. Eles estão se escondendo!" - offensive: "Ofensiva" - other: Outra people: Pessoas role: "Selecione um papel..." select_status: "Selecione um status..." - spam_ads: "Spam/anúncios" staff: "Funcionários" status: Status username_and_email: "Nome de usuário e email" diff --git a/plugins/talk-plugin-flag-details/client/components/FlagDetails.js b/plugins/talk-plugin-flag-details/client/components/FlagDetails.js index 026aebd95..9e1d03c72 100644 --- a/plugins/talk-plugin-flag-details/client/components/FlagDetails.js +++ b/plugins/talk-plugin-flag-details/client/components/FlagDetails.js @@ -30,7 +30,7 @@ class FlagDetails extends Component { return ( {reasons.map((reason) => diff --git a/plugins/talk-plugin-flag-details/client/translations.yml b/plugins/talk-plugin-flag-details/client/translations.yml index 3b2511025..7f4e8d1b7 100644 --- a/plugins/talk-plugin-flag-details/client/translations.yml +++ b/plugins/talk-plugin-flag-details/client/translations.yml @@ -1,3 +1,6 @@ en: - talk-plugin-fag-details: - + talk-plugin-flag-details: + flags: Flags +es: + talk-plugin-flag-details: + flags: Reportes diff --git a/plugins/talk-plugin-toxic-comments/client/components/ToxicDetail.js b/plugins/talk-plugin-toxic-comments/client/components/ToxicDetail.js index 3726d2b77..1c06c7dfa 100644 --- a/plugins/talk-plugin-toxic-comments/client/components/ToxicDetail.js +++ b/plugins/talk-plugin-toxic-comments/client/components/ToxicDetail.js @@ -4,18 +4,19 @@ import {isToxic} from '../utils'; import styles from './ToxicDetail.css'; import cn from 'classnames'; import PropTypes from 'prop-types'; +import {t} from 'plugin-api/beta/client/services'; const getInfo = (toxicity, actions) => { const toxic = isToxic(actions); - let text = 'Unlikely'; + let text = t('talk-plugin-toxic-comments.unlikely'); if (toxicity > 0.8) { - text = 'Highly Likely'; + text = t('talk-plugin-toxic-comments.highly_likely'); } else if (toxicity >= 0.5) { - text = 'Possibly'; + text = t('talk-plugin-toxic-comments.possibly'); } else if (toxicity >= 0.7) { - text = 'Likely'; + text = t('talk-plugin-toxic-comments.likely'); } return ( @@ -31,7 +32,7 @@ const getInfo = (toxicity, actions) => { const ToxicLabel = ({comment: {actions, toxicity}}) => ( ); diff --git a/plugins/talk-plugin-toxic-comments/client/translations.yml b/plugins/talk-plugin-toxic-comments/client/translations.yml index 787095046..95e546e50 100644 --- a/plugins/talk-plugin-toxic-comments/client/translations.yml +++ b/plugins/talk-plugin-toxic-comments/client/translations.yml @@ -4,6 +4,11 @@ en: Are you sure? The language in this comment might violate our community guidelines. You can edit the comment or submit it for moderator review. talk-plugin-toxic-comments: + unlikely: Unlikely + highly_likely: Highly Likely + possibly: Possibly + likely: Likely + toxic_comment: Toxic Comment still_toxic: | This edited comment might still violate our community guidelines. Our moderation team will review your comment shortly. From 8724cfe325baab1d5850f71cb872ae7956f8b853 Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Mon, 2 Oct 2017 22:22:55 +0700 Subject: [PATCH 14/39] Add talk-plugin-flag-details as default plugins --- plugins.default.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins.default.json b/plugins.default.json index 6ce126983..a26a38c8e 100644 --- a/plugins.default.json +++ b/plugins.default.json @@ -21,6 +21,7 @@ "talk-plugin-author-menu", "talk-plugin-member-since", "talk-plugin-ignore-user", - "talk-plugin-moderation-actions" + "talk-plugin-moderation-actions", + "talk-plugin-flag-details" ] } From b1bc97c8d5701def07daa647ac2862b53b1c1b9c Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Mon, 2 Oct 2017 22:34:12 +0700 Subject: [PATCH 15/39] Improve styling --- client/coral-admin/src/components/CommentDetails.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/coral-admin/src/components/CommentDetails.css b/client/coral-admin/src/components/CommentDetails.css index c34a32cb3..1ee1c46dd 100644 --- a/client/coral-admin/src/components/CommentDetails.css +++ b/client/coral-admin/src/components/CommentDetails.css @@ -1,5 +1,5 @@ .root { - min-height: 24px; + min-height: 25px; padding: 0 16px; } From 343d4418b073ce2876799a8a841e0d306441c42e Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Mon, 2 Oct 2017 16:23:56 -0300 Subject: [PATCH 16/39] eslint updated --- plugins/talk-plugin-subscriber/.eslintrc.json | 4 ++++ .../client/.eslintrc.json | 22 +------------------ 2 files changed, 5 insertions(+), 21 deletions(-) create mode 100644 plugins/talk-plugin-subscriber/.eslintrc.json diff --git a/plugins/talk-plugin-subscriber/.eslintrc.json b/plugins/talk-plugin-subscriber/.eslintrc.json new file mode 100644 index 000000000..d7d291614 --- /dev/null +++ b/plugins/talk-plugin-subscriber/.eslintrc.json @@ -0,0 +1,4 @@ +{ + "extends": "@coralproject/eslint-config-talk" + } + \ No newline at end of file diff --git a/plugins/talk-plugin-subscriber/client/.eslintrc.json b/plugins/talk-plugin-subscriber/client/.eslintrc.json index 9fe56bd14..c8a6db18a 100644 --- a/plugins/talk-plugin-subscriber/client/.eslintrc.json +++ b/plugins/talk-plugin-subscriber/client/.eslintrc.json @@ -1,23 +1,3 @@ { - "env": { - "browser": true, - "es6": true, - "mocha": true - }, - "parserOptions": { - "sourceType": "module", - "ecmaFeatures": { - "experimentalObjectRestSpread": true, - "jsx": true - } - }, - "parser": "babel-eslint", - "plugins": [ - "react" - ], - "rules": { - "react/jsx-uses-react": "error", - "react/jsx-uses-vars": "error", - "no-console": ["warn", { "allow": ["warn", "error"] }] - } + "extends": "@coralproject/eslint-config-talk/client" } From dde1f7b5be42bc548e762113c4eca9a98dd33248 Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Mon, 2 Oct 2017 16:26:21 -0300 Subject: [PATCH 17/39] Assigned by removed --- client/coral-embed-stream/src/graphql/index.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/client/coral-embed-stream/src/graphql/index.js b/client/coral-embed-stream/src/graphql/index.js index 228efb25b..3f6fd4832 100644 --- a/client/coral-embed-stream/src/graphql/index.js +++ b/client/coral-embed-stream/src/graphql/index.js @@ -157,10 +157,6 @@ export default { created_at: new Date().toISOString(), __typename: 'Tag' }, - assigned_by: { - id: auth.user.id, - __typename: 'User' - }, __typename: 'TagLink' })), status: 'NONE', From 7ea05e699e926ed2a26b1ee1591e625f604701a9 Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Tue, 3 Oct 2017 19:16:32 +0700 Subject: [PATCH 18/39] Remove deprecated commonjs imports and exports --- client/.babelrc => .babelrc | 5 +- .../components/QuestionBoxBuilder.js | 14 +- client/coral-embed/src/index.js | 187 +++++++++--------- client/coral-framework/services/client.js | 3 +- client/talk-plugin-commentbox/index.js | 6 +- .../talk-plugin-flags/helpers/flagReasons.js | 27 ++- plugins/talk-plugin-auth/client/.babelrc | 14 -- .../talk-plugin-author-menu/client/.babelrc | 14 -- .../client/.babelrc | 14 -- .../client/.babelrc | 14 -- .../client/components/.babelrc | 14 -- .../client/components/ModTag.js | 6 +- .../client/components/TabPane.js | 4 +- .../client/containers/ModTag.js | 17 +- .../client/containers/TabPane.js | 4 +- .../talk-plugin-ignore-user/client/.babelrc | 14 -- plugins/talk-plugin-like/client/.babelrc | 14 -- plugins/talk-plugin-love/client/.babelrc | 14 -- .../talk-plugin-member-since/client/.babelrc | 14 -- .../client/.babelrc | 14 -- plugins/talk-plugin-offtopic/client/.babelrc | 14 -- plugins/talk-plugin-permalink/client/.babelrc | 14 -- .../talk-plugin-remember-sort/client/.babelrc | 14 -- plugins/talk-plugin-respect/client/.babelrc | 14 -- .../client/.babelrc | 14 -- .../client/.babelrc | 14 -- .../client/.babelrc | 14 -- .../client/.babelrc | 14 -- .../talk-plugin-sort-newest/client/.babelrc | 14 -- .../talk-plugin-sort-oldest/client/.babelrc | 14 -- .../client/.babelrc | 14 -- .../client/.babelrc | 14 -- 32 files changed, 137 insertions(+), 444 deletions(-) rename client/.babelrc => .babelrc (87%) delete mode 100644 plugins/talk-plugin-auth/client/.babelrc delete mode 100644 plugins/talk-plugin-author-menu/client/.babelrc delete mode 100644 plugins/talk-plugin-comment-content/client/.babelrc delete mode 100644 plugins/talk-plugin-featured-comments/client/.babelrc delete mode 100644 plugins/talk-plugin-featured-comments/client/components/.babelrc delete mode 100644 plugins/talk-plugin-ignore-user/client/.babelrc delete mode 100644 plugins/talk-plugin-like/client/.babelrc delete mode 100644 plugins/talk-plugin-love/client/.babelrc delete mode 100644 plugins/talk-plugin-member-since/client/.babelrc delete mode 100644 plugins/talk-plugin-moderation-actions/client/.babelrc delete mode 100644 plugins/talk-plugin-offtopic/client/.babelrc delete mode 100644 plugins/talk-plugin-permalink/client/.babelrc delete mode 100644 plugins/talk-plugin-remember-sort/client/.babelrc delete mode 100644 plugins/talk-plugin-respect/client/.babelrc delete mode 100644 plugins/talk-plugin-sort-most-liked/client/.babelrc delete mode 100644 plugins/talk-plugin-sort-most-loved/client/.babelrc delete mode 100644 plugins/talk-plugin-sort-most-replied/client/.babelrc delete mode 100644 plugins/talk-plugin-sort-most-respected/client/.babelrc delete mode 100644 plugins/talk-plugin-sort-newest/client/.babelrc delete mode 100644 plugins/talk-plugin-sort-oldest/client/.babelrc delete mode 100644 plugins/talk-plugin-toxic-comments/client/.babelrc delete mode 100644 plugins/talk-plugin-viewing-options/client/.babelrc diff --git a/client/.babelrc b/.babelrc similarity index 87% rename from client/.babelrc rename to .babelrc index 2af1a3dad..46c04ea27 100644 --- a/client/.babelrc +++ b/.babelrc @@ -1,9 +1,8 @@ { "presets": [ - "es2015" + ["es2015"] ], "plugins": [ - "add-module-exports", "transform-class-properties", "transform-decorators-legacy", "transform-object-assign", @@ -12,4 +11,4 @@ "transform-react-jsx", "syntax-dynamic-import" ] -} \ No newline at end of file +} diff --git a/client/coral-configure/components/QuestionBoxBuilder.js b/client/coral-configure/components/QuestionBoxBuilder.js index 285df40ed..28dfc30b3 100644 --- a/client/coral-configure/components/QuestionBoxBuilder.js +++ b/client/coral-configure/components/QuestionBoxBuilder.js @@ -8,7 +8,7 @@ import styles from './QuestionBoxBuilder.css'; class QuestionBoxBuilder extends React.Component { constructor() { super(); - + this.state = { loading: true }; @@ -17,9 +17,9 @@ class QuestionBoxBuilder extends React.Component { componentWillMount() { this.loadEditor(); } - + async loadEditor() { - const MarkdownEditor = await import('coral-framework/components/MarkdownEditor'); + const {default: MarkdownEditor} = await import('coral-framework/components/MarkdownEditor'); return this.setState({ loading : false, @@ -79,17 +79,17 @@ class QuestionBoxBuilder extends React.Component { - handleChange({}, {questionBoxContent: value})} /> - +
    ); } diff --git a/client/coral-embed/src/index.js b/client/coral-embed/src/index.js index 34bee1797..f60a88439 100644 --- a/client/coral-embed/src/index.js +++ b/client/coral-embed/src/index.js @@ -2,101 +2,98 @@ import URLSearchParams from 'url-search-params'; import Stream from './Stream'; import StreamInterface from './StreamInterface'; -// This function should return value of window.Coral -const Coral = {}; -const Talk = (Coral.Talk = {}); +export class Talk { -/** - * Render a Talk stream - * @param {HTMLElement} el - Element to render the stream in - * @param {Object} opts - Configuration options for talk - * @param {String} opts.talk - Talk base URL - * @param {String} [opts.title] - Title of Stream (rendered in iframe) - * @param {String} [opts.asset_url] - Asset URL - * @param {String} [opts.asset_id] - Asset ID - * @param {String} [opts.auth_token] - (optional) A jwt representing the session - * @return {Object} - * - * Example: - * ``` - * const embed = Talk.render(document.getElementById('talkStreamEmbed'), opts); - * - * // trigger a login with optional token. - * embed.login(token); - * - * // trigger a logout. - * embed.logout(); - * - * // listen to events (in this case all events). - * embed.on('**', function(value) { - * console.log(this.event, value); - * }); - * ``` - */ -Talk.render = (el, opts) => { - if (!el) { - throw new Error('Please provide Coral.Talk.render() the HTMLElement you want to render Talk in.'); - } - if (typeof el !== 'object') { - throw new Error(`Coral.Talk.render() expected HTMLElement but got ${el} (${typeof el})`); - } - - opts = opts || {}; - - // TODO: infer this URL without explicit user input (if possible, may have to be added at build/render time of this script) - if (!opts.talk) { - throw new Error( - 'Coral.Talk.render() expects opts.talk as the Talk Base URL' - ); - } - - // Ensure el has an id, as pym can't directly accept the HTMLElement. - if (!el.id) { - el.id = `_${Math.random()}`; - } - - // Compose the query to send down to the Talk API so it knows what to load. - const query = {}; - - // Parse the url parameters to extract some of the information. - const urlParams = new URLSearchParams(window.location.search); - if (urlParams.get('commentId')) { - query.comment_id = urlParams.get('commentId'); - } - - // Extract the asset id from the options. - if (opts.asset_id) { - query.asset_id = opts.asset_id; - } - - // Extract the asset url. - if (opts.asset_url) { - query.asset_url = opts.asset_url; - } else if (!opts.asset_id) { - - // The asset url was not provided and the asset id was also not provided, - // we need to infer the asset url from details on the page. - - try { - query.asset_url = document.querySelector('link[rel="canonical"]').href; - } catch (e) { - console.warn( - 'This page does not include a canonical link tag. Talk has inferred this asset_url from the window object. Query params have been stripped, which may cause a single thread to be present across multiple pages.' - ); - - if (!window.location.origin) { - window.location.origin = `${window.location.protocol}//${window.location.hostname}${window.location.port ? `:${window.location.port}` : ''}`; - } - - query.asset_url = window.location.origin + window.location.pathname; + /** + * Render a Talk stream + * @param {HTMLElement} el - Element to render the stream in + * @param {Object} opts - Configuration options for talk + * @param {String} opts.talk - Talk base URL + * @param {String} [opts.title] - Title of Stream (rendered in iframe) + * @param {String} [opts.asset_url] - Asset URL + * @param {String} [opts.asset_id] - Asset ID + * @param {String} [opts.auth_token] - (optional) A jwt representing the session + * @return {Object} + * + * Example: + * ``` + * const embed = Talk.render(document.getElementById('talkStreamEmbed'), opts); + * + * // trigger a login with optional token. + * embed.login(token); + * + * // trigger a logout. + * embed.logout(); + * + * // listen to events (in this case all events). + * embed.on('**', function(value) { + * console.log(this.event, value); + * }); + * ``` + */ + static render(el, opts) { + if (!el) { + throw new Error('Please provide Coral.Talk.render() the HTMLElement you want to render Talk in.'); } + if (typeof el !== 'object') { + throw new Error(`Coral.Talk.render() expected HTMLElement but got ${el} (${typeof el})`); + } + + opts = opts || {}; + + // TODO: infer this URL without explicit user input (if possible, may have to be added at build/render time of this script) + if (!opts.talk) { + throw new Error( + 'Coral.Talk.render() expects opts.talk as the Talk Base URL' + ); + } + + // Ensure el has an id, as pym can't directly accept the HTMLElement. + if (!el.id) { + el.id = `_${Math.random()}`; + } + + // Compose the query to send down to the Talk API so it knows what to load. + const query = {}; + + // Parse the url parameters to extract some of the information. + const urlParams = new URLSearchParams(window.location.search); + if (urlParams.get('commentId')) { + query.comment_id = urlParams.get('commentId'); + } + + // Extract the asset id from the options. + if (opts.asset_id) { + query.asset_id = opts.asset_id; + } + + // Extract the asset url. + if (opts.asset_url) { + query.asset_url = opts.asset_url; + } else if (!opts.asset_id) { + + // The asset url was not provided and the asset id was also not provided, + // we need to infer the asset url from details on the page. + + try { + query.asset_url = document.querySelector('link[rel="canonical"]').href; + } catch (e) { + console.warn( + 'This page does not include a canonical link tag. Talk has inferred this asset_url from the window object. Query params have been stripped, which may cause a single thread to be present across multiple pages.' + ); + + if (!window.location.origin) { + window.location.origin = `${window.location.protocol}//${window.location.hostname}${window.location.port ? `:${window.location.port}` : ''}`; + } + + query.asset_url = window.location.origin + window.location.pathname; + } + } + + // Create the new Stream. + const stream = new Stream(el, opts.talk, query, opts); + + // Return the public interface for the stream. + return new StreamInterface(stream); } - - // Create the new Stream. - const stream = new Stream(el, opts.talk, query, opts); - - // Return the public interface for the stream. - return new StreamInterface(stream); -}; - -export default Coral; +} diff --git a/client/coral-framework/services/client.js b/client/coral-framework/services/client.js index 52088ad79..dc5a67d03 100644 --- a/client/coral-framework/services/client.js +++ b/client/coral-framework/services/client.js @@ -1,4 +1,4 @@ -import ApolloClient, {addTypename, IntrospectionFragmentMatcher, createNetworkInterface} from 'apollo-client'; +import ApolloClient, {IntrospectionFragmentMatcher, createNetworkInterface} from 'apollo-client'; import {SubscriptionClient, addGraphQLSubscriptions} from 'subscriptions-transport-ws'; import MessageTypes from 'subscriptions-transport-ws/dist/message-types'; @@ -64,7 +64,6 @@ export function createClient(options = {}) { connectToDevTools: true, addTypename: true, fragmentMatcher: new IntrospectionFragmentMatcher({introspectionQueryResultData: introspectionData}), - queryTransformer: addTypename, dataIdFromObject: (result) => { if (result.id && result.__typename) { // eslint-disable-line no-underscore-dangle return `${result.__typename}_${result.id}`; // eslint-disable-line no-underscore-dangle diff --git a/client/talk-plugin-commentbox/index.js b/client/talk-plugin-commentbox/index.js index 9f166caeb..0d94a840e 100644 --- a/client/talk-plugin-commentbox/index.js +++ b/client/talk-plugin-commentbox/index.js @@ -1,5 +1 @@ -import reducer from './reducer'; - -export default { - reducer -}; +export {default as reducer} from './reducer'; diff --git a/client/talk-plugin-flags/helpers/flagReasons.js b/client/talk-plugin-flags/helpers/flagReasons.js index 514c57398..52bddbb38 100644 --- a/client/talk-plugin-flags/helpers/flagReasons.js +++ b/client/talk-plugin-flags/helpers/flagReasons.js @@ -1,15 +1,14 @@ -export default { - username: { - offensive: 'USERNAME_OFFENSIVE', - nolike: 'USERNAME_NOLIKE', - impersonating: 'USERNAME_IMPERSONATING', - spam: 'USERNAME_SPAM', - other: 'USERNAME_OTHER' - }, - comment: { - offensive: 'COMMENT_OFFENSIVE', - spam: 'COMMENT_SPAM', - noagree: 'COMMENT_NOAGREE', - other: 'COMMENT_OTHER' - } +export const username = { + offensive: 'USERNAME_OFFENSIVE', + nolike: 'USERNAME_NOLIKE', + impersonating: 'USERNAME_IMPERSONATING', + spam: 'USERNAME_SPAM', + other: 'USERNAME_OTHER' +}; + +export const comment = { + offensive: 'COMMENT_OFFENSIVE', + spam: 'COMMENT_SPAM', + noagree: 'COMMENT_NOAGREE', + other: 'COMMENT_OTHER' }; diff --git a/plugins/talk-plugin-auth/client/.babelrc b/plugins/talk-plugin-auth/client/.babelrc deleted file mode 100644 index 60be246eb..000000000 --- a/plugins/talk-plugin-auth/client/.babelrc +++ /dev/null @@ -1,14 +0,0 @@ -{ - "presets": [ - "es2015" - ], - "plugins": [ - "add-module-exports", - "transform-class-properties", - "transform-decorators-legacy", - "transform-object-assign", - "transform-object-rest-spread", - "transform-async-to-generator", - "transform-react-jsx" - ] -} \ No newline at end of file diff --git a/plugins/talk-plugin-author-menu/client/.babelrc b/plugins/talk-plugin-author-menu/client/.babelrc deleted file mode 100644 index 60be246eb..000000000 --- a/plugins/talk-plugin-author-menu/client/.babelrc +++ /dev/null @@ -1,14 +0,0 @@ -{ - "presets": [ - "es2015" - ], - "plugins": [ - "add-module-exports", - "transform-class-properties", - "transform-decorators-legacy", - "transform-object-assign", - "transform-object-rest-spread", - "transform-async-to-generator", - "transform-react-jsx" - ] -} \ No newline at end of file diff --git a/plugins/talk-plugin-comment-content/client/.babelrc b/plugins/talk-plugin-comment-content/client/.babelrc deleted file mode 100644 index 60be246eb..000000000 --- a/plugins/talk-plugin-comment-content/client/.babelrc +++ /dev/null @@ -1,14 +0,0 @@ -{ - "presets": [ - "es2015" - ], - "plugins": [ - "add-module-exports", - "transform-class-properties", - "transform-decorators-legacy", - "transform-object-assign", - "transform-object-rest-spread", - "transform-async-to-generator", - "transform-react-jsx" - ] -} \ No newline at end of file diff --git a/plugins/talk-plugin-featured-comments/client/.babelrc b/plugins/talk-plugin-featured-comments/client/.babelrc deleted file mode 100644 index 60be246eb..000000000 --- a/plugins/talk-plugin-featured-comments/client/.babelrc +++ /dev/null @@ -1,14 +0,0 @@ -{ - "presets": [ - "es2015" - ], - "plugins": [ - "add-module-exports", - "transform-class-properties", - "transform-decorators-legacy", - "transform-object-assign", - "transform-object-rest-spread", - "transform-async-to-generator", - "transform-react-jsx" - ] -} \ No newline at end of file diff --git a/plugins/talk-plugin-featured-comments/client/components/.babelrc b/plugins/talk-plugin-featured-comments/client/components/.babelrc deleted file mode 100644 index 60be246eb..000000000 --- a/plugins/talk-plugin-featured-comments/client/components/.babelrc +++ /dev/null @@ -1,14 +0,0 @@ -{ - "presets": [ - "es2015" - ], - "plugins": [ - "add-module-exports", - "transform-class-properties", - "transform-decorators-legacy", - "transform-object-assign", - "transform-object-rest-spread", - "transform-async-to-generator", - "transform-react-jsx" - ] -} \ No newline at end of file diff --git a/plugins/talk-plugin-featured-comments/client/components/ModTag.js b/plugins/talk-plugin-featured-comments/client/components/ModTag.js index 52c051796..7dfd36f2d 100644 --- a/plugins/talk-plugin-featured-comments/client/components/ModTag.js +++ b/plugins/talk-plugin-featured-comments/client/components/ModTag.js @@ -3,7 +3,7 @@ import cn from 'classnames'; import styles from './ModTag.css'; import {t} from 'plugin-api/beta/client/services'; import {Icon} from 'plugin-api/beta/client/components/ui'; -import * as notification from 'coral-admin/src/services/notification'; +import {getErrorMessages} from 'plugin-api/beta/client/utils'; export default class ModTag extends React.Component { constructor() { @@ -32,10 +32,10 @@ export default class ModTag extends React.Component { postTag = async () => { try { await this.props.postTag(); - notification.success(t('talk-plugin-featured-comments.notify_self_featured', this.props.comment.user.username)); + this.props.notify('success', t('talk-plugin-featured-comments.notify_self_featured', this.props.comment.user.username)); } catch(err) { - notification.showMutationErrors(err); + this.props.notify('error', getErrorMessages(err)); } } diff --git a/plugins/talk-plugin-featured-comments/client/components/TabPane.js b/plugins/talk-plugin-featured-comments/client/components/TabPane.js index 2f5d0c7c2..941f15402 100644 --- a/plugins/talk-plugin-featured-comments/client/components/TabPane.js +++ b/plugins/talk-plugin-featured-comments/client/components/TabPane.js @@ -1,7 +1,7 @@ import React from 'react'; import Comment from '../containers/Comment'; import LoadMore from './LoadMore'; -import {forEachError} from 'plugin-api/beta/client/utils'; +import {getErrorMessages} from 'plugin-api/beta/client/utils'; class TabPane extends React.Component { state = { @@ -16,7 +16,7 @@ class TabPane extends React.Component { }) .catch((error) => { this.setState({loadingState: 'error'}); - forEachError(error, ({msg}) => {this.props.addNotification('error', msg);}); + this.props.notify('error', getErrorMessages(error)); }); } diff --git a/plugins/talk-plugin-featured-comments/client/containers/ModTag.js b/plugins/talk-plugin-featured-comments/client/containers/ModTag.js index 7081c7ec6..88aee73f6 100644 --- a/plugins/talk-plugin-featured-comments/client/containers/ModTag.js +++ b/plugins/talk-plugin-featured-comments/client/containers/ModTag.js @@ -1,6 +1,13 @@ import ModTag from '../components/ModTag'; -import {withTags} from 'plugin-api/beta/client/hocs'; -import {gql} from 'react-apollo'; +import {withTags, connect} from 'plugin-api/beta/client/hocs'; +import {gql, compose} from 'react-apollo'; +import {bindActionCreators} from 'redux'; +import {notify} from 'plugin-api/beta/client/actions/notification'; + +const mapDispatchToProps = (dispatch) => + bindActionCreators({ + notify, + }, dispatch); const fragments = { comment: gql` @@ -11,6 +18,10 @@ const fragments = { } ` }; +const enhance = compose( + withTags('featured', {fragments}), + connect(null, mapDispatchToProps), +); -export default withTags('featured', {fragments})(ModTag); +export default enhance(ModTag); diff --git a/plugins/talk-plugin-featured-comments/client/containers/TabPane.js b/plugins/talk-plugin-featured-comments/client/containers/TabPane.js index 93ef402a9..5f684b228 100644 --- a/plugins/talk-plugin-featured-comments/client/containers/TabPane.js +++ b/plugins/talk-plugin-featured-comments/client/containers/TabPane.js @@ -4,7 +4,7 @@ import {compose, gql} from 'react-apollo'; import TabPane from '../components/TabPane'; import {withFragments, connect} from 'plugin-api/beta/client/hocs'; import Comment from '../containers/Comment'; -import {addNotification} from 'plugin-api/beta/client/actions/notification'; +import {notify} from 'plugin-api/beta/client/actions/notification'; import {viewComment} from 'coral-embed-stream/src/actions/stream'; import {appendNewNodes, getDefinitionName} from 'plugin-api/beta/client/utils'; import update from 'immutability-helper'; @@ -81,7 +81,7 @@ const LOAD_MORE_QUERY = gql` const mapDispatchToProps = (dispatch) => bindActionCreators({ viewComment, - addNotification, + notify, }, dispatch); const enhance = compose( diff --git a/plugins/talk-plugin-ignore-user/client/.babelrc b/plugins/talk-plugin-ignore-user/client/.babelrc deleted file mode 100644 index 60be246eb..000000000 --- a/plugins/talk-plugin-ignore-user/client/.babelrc +++ /dev/null @@ -1,14 +0,0 @@ -{ - "presets": [ - "es2015" - ], - "plugins": [ - "add-module-exports", - "transform-class-properties", - "transform-decorators-legacy", - "transform-object-assign", - "transform-object-rest-spread", - "transform-async-to-generator", - "transform-react-jsx" - ] -} \ No newline at end of file diff --git a/plugins/talk-plugin-like/client/.babelrc b/plugins/talk-plugin-like/client/.babelrc deleted file mode 100644 index 60be246eb..000000000 --- a/plugins/talk-plugin-like/client/.babelrc +++ /dev/null @@ -1,14 +0,0 @@ -{ - "presets": [ - "es2015" - ], - "plugins": [ - "add-module-exports", - "transform-class-properties", - "transform-decorators-legacy", - "transform-object-assign", - "transform-object-rest-spread", - "transform-async-to-generator", - "transform-react-jsx" - ] -} \ No newline at end of file diff --git a/plugins/talk-plugin-love/client/.babelrc b/plugins/talk-plugin-love/client/.babelrc deleted file mode 100644 index 60be246eb..000000000 --- a/plugins/talk-plugin-love/client/.babelrc +++ /dev/null @@ -1,14 +0,0 @@ -{ - "presets": [ - "es2015" - ], - "plugins": [ - "add-module-exports", - "transform-class-properties", - "transform-decorators-legacy", - "transform-object-assign", - "transform-object-rest-spread", - "transform-async-to-generator", - "transform-react-jsx" - ] -} \ No newline at end of file diff --git a/plugins/talk-plugin-member-since/client/.babelrc b/plugins/talk-plugin-member-since/client/.babelrc deleted file mode 100644 index 60be246eb..000000000 --- a/plugins/talk-plugin-member-since/client/.babelrc +++ /dev/null @@ -1,14 +0,0 @@ -{ - "presets": [ - "es2015" - ], - "plugins": [ - "add-module-exports", - "transform-class-properties", - "transform-decorators-legacy", - "transform-object-assign", - "transform-object-rest-spread", - "transform-async-to-generator", - "transform-react-jsx" - ] -} \ No newline at end of file diff --git a/plugins/talk-plugin-moderation-actions/client/.babelrc b/plugins/talk-plugin-moderation-actions/client/.babelrc deleted file mode 100644 index 60be246eb..000000000 --- a/plugins/talk-plugin-moderation-actions/client/.babelrc +++ /dev/null @@ -1,14 +0,0 @@ -{ - "presets": [ - "es2015" - ], - "plugins": [ - "add-module-exports", - "transform-class-properties", - "transform-decorators-legacy", - "transform-object-assign", - "transform-object-rest-spread", - "transform-async-to-generator", - "transform-react-jsx" - ] -} \ No newline at end of file diff --git a/plugins/talk-plugin-offtopic/client/.babelrc b/plugins/talk-plugin-offtopic/client/.babelrc deleted file mode 100644 index 60be246eb..000000000 --- a/plugins/talk-plugin-offtopic/client/.babelrc +++ /dev/null @@ -1,14 +0,0 @@ -{ - "presets": [ - "es2015" - ], - "plugins": [ - "add-module-exports", - "transform-class-properties", - "transform-decorators-legacy", - "transform-object-assign", - "transform-object-rest-spread", - "transform-async-to-generator", - "transform-react-jsx" - ] -} \ No newline at end of file diff --git a/plugins/talk-plugin-permalink/client/.babelrc b/plugins/talk-plugin-permalink/client/.babelrc deleted file mode 100644 index 60be246eb..000000000 --- a/plugins/talk-plugin-permalink/client/.babelrc +++ /dev/null @@ -1,14 +0,0 @@ -{ - "presets": [ - "es2015" - ], - "plugins": [ - "add-module-exports", - "transform-class-properties", - "transform-decorators-legacy", - "transform-object-assign", - "transform-object-rest-spread", - "transform-async-to-generator", - "transform-react-jsx" - ] -} \ No newline at end of file diff --git a/plugins/talk-plugin-remember-sort/client/.babelrc b/plugins/talk-plugin-remember-sort/client/.babelrc deleted file mode 100644 index 60be246eb..000000000 --- a/plugins/talk-plugin-remember-sort/client/.babelrc +++ /dev/null @@ -1,14 +0,0 @@ -{ - "presets": [ - "es2015" - ], - "plugins": [ - "add-module-exports", - "transform-class-properties", - "transform-decorators-legacy", - "transform-object-assign", - "transform-object-rest-spread", - "transform-async-to-generator", - "transform-react-jsx" - ] -} \ No newline at end of file diff --git a/plugins/talk-plugin-respect/client/.babelrc b/plugins/talk-plugin-respect/client/.babelrc deleted file mode 100644 index 60be246eb..000000000 --- a/plugins/talk-plugin-respect/client/.babelrc +++ /dev/null @@ -1,14 +0,0 @@ -{ - "presets": [ - "es2015" - ], - "plugins": [ - "add-module-exports", - "transform-class-properties", - "transform-decorators-legacy", - "transform-object-assign", - "transform-object-rest-spread", - "transform-async-to-generator", - "transform-react-jsx" - ] -} \ No newline at end of file diff --git a/plugins/talk-plugin-sort-most-liked/client/.babelrc b/plugins/talk-plugin-sort-most-liked/client/.babelrc deleted file mode 100644 index 60be246eb..000000000 --- a/plugins/talk-plugin-sort-most-liked/client/.babelrc +++ /dev/null @@ -1,14 +0,0 @@ -{ - "presets": [ - "es2015" - ], - "plugins": [ - "add-module-exports", - "transform-class-properties", - "transform-decorators-legacy", - "transform-object-assign", - "transform-object-rest-spread", - "transform-async-to-generator", - "transform-react-jsx" - ] -} \ No newline at end of file diff --git a/plugins/talk-plugin-sort-most-loved/client/.babelrc b/plugins/talk-plugin-sort-most-loved/client/.babelrc deleted file mode 100644 index 60be246eb..000000000 --- a/plugins/talk-plugin-sort-most-loved/client/.babelrc +++ /dev/null @@ -1,14 +0,0 @@ -{ - "presets": [ - "es2015" - ], - "plugins": [ - "add-module-exports", - "transform-class-properties", - "transform-decorators-legacy", - "transform-object-assign", - "transform-object-rest-spread", - "transform-async-to-generator", - "transform-react-jsx" - ] -} \ No newline at end of file diff --git a/plugins/talk-plugin-sort-most-replied/client/.babelrc b/plugins/talk-plugin-sort-most-replied/client/.babelrc deleted file mode 100644 index 60be246eb..000000000 --- a/plugins/talk-plugin-sort-most-replied/client/.babelrc +++ /dev/null @@ -1,14 +0,0 @@ -{ - "presets": [ - "es2015" - ], - "plugins": [ - "add-module-exports", - "transform-class-properties", - "transform-decorators-legacy", - "transform-object-assign", - "transform-object-rest-spread", - "transform-async-to-generator", - "transform-react-jsx" - ] -} \ No newline at end of file diff --git a/plugins/talk-plugin-sort-most-respected/client/.babelrc b/plugins/talk-plugin-sort-most-respected/client/.babelrc deleted file mode 100644 index 60be246eb..000000000 --- a/plugins/talk-plugin-sort-most-respected/client/.babelrc +++ /dev/null @@ -1,14 +0,0 @@ -{ - "presets": [ - "es2015" - ], - "plugins": [ - "add-module-exports", - "transform-class-properties", - "transform-decorators-legacy", - "transform-object-assign", - "transform-object-rest-spread", - "transform-async-to-generator", - "transform-react-jsx" - ] -} \ No newline at end of file diff --git a/plugins/talk-plugin-sort-newest/client/.babelrc b/plugins/talk-plugin-sort-newest/client/.babelrc deleted file mode 100644 index 60be246eb..000000000 --- a/plugins/talk-plugin-sort-newest/client/.babelrc +++ /dev/null @@ -1,14 +0,0 @@ -{ - "presets": [ - "es2015" - ], - "plugins": [ - "add-module-exports", - "transform-class-properties", - "transform-decorators-legacy", - "transform-object-assign", - "transform-object-rest-spread", - "transform-async-to-generator", - "transform-react-jsx" - ] -} \ No newline at end of file diff --git a/plugins/talk-plugin-sort-oldest/client/.babelrc b/plugins/talk-plugin-sort-oldest/client/.babelrc deleted file mode 100644 index 60be246eb..000000000 --- a/plugins/talk-plugin-sort-oldest/client/.babelrc +++ /dev/null @@ -1,14 +0,0 @@ -{ - "presets": [ - "es2015" - ], - "plugins": [ - "add-module-exports", - "transform-class-properties", - "transform-decorators-legacy", - "transform-object-assign", - "transform-object-rest-spread", - "transform-async-to-generator", - "transform-react-jsx" - ] -} \ No newline at end of file diff --git a/plugins/talk-plugin-toxic-comments/client/.babelrc b/plugins/talk-plugin-toxic-comments/client/.babelrc deleted file mode 100644 index 60be246eb..000000000 --- a/plugins/talk-plugin-toxic-comments/client/.babelrc +++ /dev/null @@ -1,14 +0,0 @@ -{ - "presets": [ - "es2015" - ], - "plugins": [ - "add-module-exports", - "transform-class-properties", - "transform-decorators-legacy", - "transform-object-assign", - "transform-object-rest-spread", - "transform-async-to-generator", - "transform-react-jsx" - ] -} \ No newline at end of file diff --git a/plugins/talk-plugin-viewing-options/client/.babelrc b/plugins/talk-plugin-viewing-options/client/.babelrc deleted file mode 100644 index 60be246eb..000000000 --- a/plugins/talk-plugin-viewing-options/client/.babelrc +++ /dev/null @@ -1,14 +0,0 @@ -{ - "presets": [ - "es2015" - ], - "plugins": [ - "add-module-exports", - "transform-class-properties", - "transform-decorators-legacy", - "transform-object-assign", - "transform-object-rest-spread", - "transform-async-to-generator", - "transform-react-jsx" - ] -} \ No newline at end of file From b1753ecdce1ce91e977e348aa8d1cf7f41ededea Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Tue, 3 Oct 2017 19:57:23 +0700 Subject: [PATCH 19/39] Pass es6 to webpack and profit from tree shaking --- .babelrc | 2 +- bin/templates/plugin/client/.babelrc | 14 -------------- plugin-api/.babelrc | 14 -------------- 3 files changed, 1 insertion(+), 29 deletions(-) delete mode 100644 bin/templates/plugin/client/.babelrc delete mode 100644 plugin-api/.babelrc diff --git a/.babelrc b/.babelrc index 46c04ea27..3dcf42eb7 100644 --- a/.babelrc +++ b/.babelrc @@ -1,6 +1,6 @@ { "presets": [ - ["es2015"] + ["es2015", {modules: false}] ], "plugins": [ "transform-class-properties", diff --git a/bin/templates/plugin/client/.babelrc b/bin/templates/plugin/client/.babelrc deleted file mode 100644 index 60be246eb..000000000 --- a/bin/templates/plugin/client/.babelrc +++ /dev/null @@ -1,14 +0,0 @@ -{ - "presets": [ - "es2015" - ], - "plugins": [ - "add-module-exports", - "transform-class-properties", - "transform-decorators-legacy", - "transform-object-assign", - "transform-object-rest-spread", - "transform-async-to-generator", - "transform-react-jsx" - ] -} \ No newline at end of file diff --git a/plugin-api/.babelrc b/plugin-api/.babelrc deleted file mode 100644 index 63b1c53de..000000000 --- a/plugin-api/.babelrc +++ /dev/null @@ -1,14 +0,0 @@ -{ - "presets": [ - "es2015" - ], - "plugins": [ - "add-module-exports", - "transform-class-properties", - "transform-decorators-legacy", - "transform-object-assign", - "transform-object-rest-spread", - "transform-async-to-generator", - "transform-react-jsx" - ] -} From 942b65648b87dc3256fed880e1c70bcf1b1e3185 Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Tue, 3 Oct 2017 20:37:55 +0700 Subject: [PATCH 20/39] Adapt plugins-loader to es6 --- client/coral-framework/loaders/plugins-loader.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/coral-framework/loaders/plugins-loader.js b/client/coral-framework/loaders/plugins-loader.js index a9fed95ab..7683dae8d 100644 --- a/client/coral-framework/loaders/plugins-loader.js +++ b/client/coral-framework/loaders/plugins-loader.js @@ -21,7 +21,7 @@ module.exports = function(source) { this.cacheable(); const config = this.exec(source, this.resourcePath); const plugins = getPluginList(config).map((plugin) => `{ - module: require('${plugin}/client'), + module: require('${plugin}/client').default, name: '${plugin}' }`); From 11d2f05f73b304ebe0584dc598f4449b18566425 Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Tue, 3 Oct 2017 20:55:44 +0700 Subject: [PATCH 21/39] Remove babel-plugin-add-module-exports --- package.json | 1 - yarn.lock | 10 +--------- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/package.json b/package.json index 52866238b..f8c8c9731 100644 --- a/package.json +++ b/package.json @@ -63,7 +63,6 @@ "babel-core": "^6.26.0", "babel-eslint": "^7.2.1", "babel-loader": "^7.1.2", - "babel-plugin-add-module-exports": "^0.2.1", "babel-plugin-syntax-dynamic-import": "^6.18.0", "babel-plugin-transform-async-to-generator": "^6.16.0", "babel-plugin-transform-class-properties": "^6.23.0", diff --git a/yarn.lock b/yarn.lock index bc012d33e..29d4a2605 100644 --- a/yarn.lock +++ b/yarn.lock @@ -572,10 +572,6 @@ babel-messages@^6.23.0: dependencies: babel-runtime "^6.22.0" -babel-plugin-add-module-exports@^0.2.1: - version "0.2.1" - resolved "https://registry.yarnpkg.com/babel-plugin-add-module-exports/-/babel-plugin-add-module-exports-0.2.1.tgz#9ae9a1f4a8dc67f0cdec4f4aeda1e43a5ff65e25" - babel-plugin-check-es2015-constants@^6.22.0: version "6.22.0" resolved "https://registry.yarnpkg.com/babel-plugin-check-es2015-constants/-/babel-plugin-check-es2015-constants-6.22.0.tgz#35157b101426fd2ffd3da3f75c7d1e91835bbf8a" @@ -3180,11 +3176,7 @@ graceful-fs@^4.1.11, graceful-fs@^4.1.2, graceful-fs@^4.1.4, graceful-fs@^4.1.6, version "1.0.1" resolved "https://registry.yarnpkg.com/graceful-readlink/-/graceful-readlink-1.0.1.tgz#4cafad76bc62f02fa039b2f94e9a3dd3a391a725" -graphql-anywhere@^3.0.0, graphql-anywhere@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/graphql-anywhere/-/graphql-anywhere-3.0.1.tgz#73531db861174c8f212eafb9f8e84944b38b4e5a" - -graphql-anywhere@^3.1.0: +graphql-anywhere@^3.0.0, graphql-anywhere@^3.0.1, graphql-anywhere@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/graphql-anywhere/-/graphql-anywhere-3.1.0.tgz#3ea0d8e8646b5cee68035016a9a7557c15c21e96" From c1f7ef4f3264654c89d8ebef8ede42110ad414cc Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Tue, 3 Oct 2017 21:08:02 +0700 Subject: [PATCH 22/39] Introduce Jest Unit Testing framework --- .babelrc | 9 +- .../components}/__tests__/markdown.spec.js | 0 .../__tests__/commentBox.spec.js | 26 - jest.config.js | 39 + package.json | 11 +- test/client/.eslintrc.json | 3 + test/client/fileMock.js | 1 + test/client/setupJest.js | 38 + test/client/yamlTransformer.js | 8 + yarn.lock | 871 ++++++++++++++++-- 10 files changed, 901 insertions(+), 105 deletions(-) rename client/{talk-plugin-infobox => coral-framework/components}/__tests__/markdown.spec.js (100%) delete mode 100644 client/talk-plugin-commentbox/__tests__/commentBox.spec.js create mode 100644 jest.config.js create mode 100644 test/client/.eslintrc.json create mode 100644 test/client/fileMock.js create mode 100644 test/client/setupJest.js create mode 100644 test/client/yamlTransformer.js diff --git a/.babelrc b/.babelrc index 3dcf42eb7..92a64c2a4 100644 --- a/.babelrc +++ b/.babelrc @@ -10,5 +10,12 @@ "transform-async-to-generator", "transform-react-jsx", "syntax-dynamic-import" - ] + ], + "env": { + "test": { + "plugins": [ + ["transform-es2015-modules-commonjs", "dynamic-import-node"] + ] + } + } } diff --git a/client/talk-plugin-infobox/__tests__/markdown.spec.js b/client/coral-framework/components/__tests__/markdown.spec.js similarity index 100% rename from client/talk-plugin-infobox/__tests__/markdown.spec.js rename to client/coral-framework/components/__tests__/markdown.spec.js diff --git a/client/talk-plugin-commentbox/__tests__/commentBox.spec.js b/client/talk-plugin-commentbox/__tests__/commentBox.spec.js deleted file mode 100644 index 6ae09e786..000000000 --- a/client/talk-plugin-commentbox/__tests__/commentBox.spec.js +++ /dev/null @@ -1,26 +0,0 @@ -import React from 'react'; -import {shallow} from 'enzyme'; -import {expect} from 'chai'; -import CommentBox from '../CommentBox'; - -describe('CommentBox', () => { - let comment; - let render; - beforeEach(() => { - comment = {}; - const postItem = (item) => { - comment.posted = item; - return Promise.resolve(4); - }; - render = shallow( comment.text = e.target.value} - item_id={'1'} - comments={['1', '2', '3']}/>); - }); - - it('should render the CommentBox appropriately', () => { - expect(render.contains('
    /test/client/setupJest.js', + modulePaths: [ + '/plugins', + '/client', + ...buildTargets.map((target) => path.join('', 'client', target, 'src')), + ...buildEmbeds.map((embed) => path.join('', 'client', `coral-embed-${embed}`, 'src')), + ], + moduleFileExtensions: ['js', 'jsx', 'json', 'yaml', 'yml'], + moduleDirectories: ['node_modules'], + + transform: { + '^.+\\.jsx?$': 'babel-jest', + '\\.ya?ml$': '/test/client/yamlTransformer.js' + }, + + moduleNameMapper: { + '^plugin-api\\/(.*)$': '/plugin-api/$1', + '^plugins\\/(.*)$': '/plugins/$1', + '^pluginsConfig$': pluginsPath, + + '\\.(scss|css|less)$': 'identity-obj-proxy', + '\\.(gif|ttf|eot|svg)$': '/test/client/fileMock.js' + } +}; diff --git a/package.json b/package.json index f8c8c9731..b95a16e06 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,7 @@ "lint": "eslint --ext=.js --ext=.json bin/* .", "lint-fix": "yarn lint --fix", "test": "TEST_MODE=unit NODE_ENV=test mocha -R ${MOCHA_REPORTER:-spec}", + "test-jest": "TEST_MODE=unit NODE_ENV=test jest", "test-cover": "TEST_MODE=unit NODE_ENV=test istanbul cover _mocha --report text --check-coverage -- -R spec", "heroku-postbuild": "./bin/cli plugins reconcile && yarn build", "generate-introspection": "WEBPACK=TRUE NODE_ENV=test ./scripts/generateIntrospectionResult.js" @@ -159,6 +160,7 @@ "react-redux": "^4.4.5", "react-router": "^3.0.0", "react-tagsinput": "^3.17.0", + "react-test-renderer": "15.5", "react-toastify": "^1.5.0", "react-transition-group": "^1.1.3", "recompose": "^0.23.1", @@ -179,17 +181,24 @@ "url-search-params": "^0.9.0", "uuid": "^3.1.0", "webpack": "^2.3.1", + "webpack-sources": "^1.0.1", "yaml-loader": "^0.4.0", "yamljs": "^0.2.10" }, "devDependencies": { "@coralproject/eslint-config-talk": "^0.0.3", + "babel-jest": "^21.2.0", + "babel-plugin-dynamic-import-node": "^1.1.0", + "babel-plugin-transform-es2015-modules-commonjs": "^6.26.0", "chai": "^3.5.0", "chai-as-promised": "^6.0.0", "chai-http": "^3.0.0", - "enzyme": "^2.9.1", + "enzyme": "^3.0.0", + "enzyme-adapter-react-15": "^1.0.0", "eslint": "^4.5.0", "eslint-plugin-mocha": "^4.11.0", + "identity-obj-proxy": "^3.0.0", + "jest": "^21.2.1", "mocha": "^3.1.2", "mocha-junit-reporter": "^1.12.1", "nodemon": "^1.11.0", diff --git a/test/client/.eslintrc.json b/test/client/.eslintrc.json new file mode 100644 index 000000000..c8a6db18a --- /dev/null +++ b/test/client/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "@coralproject/eslint-config-talk/client" +} diff --git a/test/client/fileMock.js b/test/client/fileMock.js new file mode 100644 index 000000000..86059f362 --- /dev/null +++ b/test/client/fileMock.js @@ -0,0 +1 @@ +module.exports = 'test-file-stub'; diff --git a/test/client/setupJest.js b/test/client/setupJest.js new file mode 100644 index 000000000..610a57a72 --- /dev/null +++ b/test/client/setupJest.js @@ -0,0 +1,38 @@ +import Enzyme from 'enzyme'; +import Adapter from 'enzyme-adapter-react-15'; + +Enzyme.configure({adapter: new Adapter()}); + +// Storage Mock + +// TODO: If our code is written well, there shouldn't be a hardcoded dependency +// to the local storage, and this global mock wouldn't be needed. + +function storageMock() { + let storage = {}; + + return { + setItem: function(key, value) { + storage[key] = value || ''; + }, + getItem: function(key) { + return key in storage ? storage[key] : null; + }, + removeItem: function(key) { + delete storage[key]; + }, + get length() { + return Object.keys(storage).length; + }, + key: function(i) { + let keys = Object.keys(storage); + return keys[i] || null; + } + }; +} + +// mock the localStorage +window.localStorage = storageMock(); + +// mock the sessionStorage +window.sessionStorage = storageMock(); diff --git a/test/client/yamlTransformer.js b/test/client/yamlTransformer.js new file mode 100644 index 000000000..5434ac98f --- /dev/null +++ b/test/client/yamlTransformer.js @@ -0,0 +1,8 @@ +const yaml = require('yamljs'); + +module.exports = { + process(src) { + const data = yaml.parse(src); + return `module.exports = ${JSON.stringify(data)};`; + }, +}; diff --git a/yarn.lock b/yarn.lock index 29d4a2605..464ac6a26 100644 --- a/yarn.lock +++ b/yarn.lock @@ -50,6 +50,10 @@ version "7.0.12" resolved "https://registry.yarnpkg.com/@types/node/-/node-7.0.12.tgz#ae5f67a19c15f752148004db07cbbb372e69efc9" +"@types/node@^6.0.46": + version "6.0.88" + resolved "https://registry.yarnpkg.com/@types/node/-/node-6.0.88.tgz#f618f11a944f6a18d92b5c472028728a3e3d4b66" + "@types/serve-static@*": version "1.7.31" resolved "https://registry.yarnpkg.com/@types/serve-static/-/serve-static-1.7.31.tgz#15456de8d98d6b4cff31be6c6af7492ae63f521a" @@ -63,7 +67,7 @@ dependencies: "@types/node" "*" -abab@^1.0.0: +abab@^1.0.0, abab@^1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/abab/-/abab-1.0.3.tgz#b81de5f7274ec4e756d797cd834f303642724e5d" @@ -90,7 +94,7 @@ acorn-globals@^1.0.4: dependencies: acorn "^2.1.0" -acorn-globals@^3.0.0: +acorn-globals@^3.0.0, acorn-globals@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/acorn-globals/-/acorn-globals-3.1.0.tgz#fd8270f71fbb4996b004fa880ee5d46573a731bf" dependencies: @@ -178,6 +182,10 @@ ansi-escapes@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-2.0.0.tgz#5bae52be424878dd9783e8910e3fc2922e83c81b" +ansi-escapes@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-3.0.0.tgz#ec3e8b4e9f8064fc02c3ac9b65f1c275bda8ef92" + ansi-regex@^1.0.0, ansi-regex@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-1.1.1.tgz#41c847194646375e6a1a5d10c3ca054ef9fc980d" @@ -194,7 +202,7 @@ ansi-styles@^2.2.1: version "2.2.1" resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-2.2.1.tgz#b432dd3358b634cf75e1e4664368240533c1ddbe" -ansi-styles@^3.1.0: +ansi-styles@^3.1.0, ansi-styles@^3.2.0: version "3.2.0" resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.0.tgz#c159b8d5be0f9e5a6f346dab94f16ce022161b88" dependencies: @@ -280,6 +288,10 @@ arr-flatten@^1.0.1: version "1.0.3" resolved "https://registry.yarnpkg.com/arr-flatten/-/arr-flatten-1.0.3.tgz#a274ed85ac08849b6bd7847c4580745dc51adfb1" +array-equal@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/array-equal/-/array-equal-1.0.0.tgz#8c2a5ef2472fd9ea742b04c77a75093ba2757c93" + array-flatten@1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/array-flatten/-/array-flatten-1.1.1.tgz#9a5f699051b1e7073328f2a008968b64ea2955d2" @@ -305,7 +317,7 @@ array-unique@^0.2.1: version "0.2.1" resolved "https://registry.yarnpkg.com/array-unique/-/array-unique-0.2.1.tgz#a1d97ccafcbc2625cc70fadceb36a50c58b01a53" -arrify@^1.0.0: +arrify@^1.0.0, arrify@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/arrify/-/arrify-1.0.1.tgz#898508da2226f380df904728456849c1501a4b0d" @@ -343,6 +355,10 @@ assertion-error@^1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/assertion-error/-/assertion-error-1.0.2.tgz#13ca515d86206da0bac66e834dd397d87581094c" +astral-regex@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/astral-regex/-/astral-regex-1.0.0.tgz#6c8c3fb827dd43ee3918f27b82782ab7658a6fd9" + async-each@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/async-each/-/async-each-1.0.1.tgz#19d386a1d9edc6e7c1c85d388aedbcc56d33602d" @@ -419,7 +435,7 @@ babel-code-frame@^6.11.0, babel-code-frame@^6.22.0, babel-code-frame@^6.26.0: esutils "^2.0.2" js-tokens "^3.0.2" -babel-core@^6.26.0: +babel-core@^6.0.0, babel-core@^6.26.0: version "6.26.0" resolved "https://registry.yarnpkg.com/babel-core/-/babel-core-6.26.0.tgz#af32f78b31a6fcef119c87b0fd8d9753f03a0bb8" dependencies: @@ -558,6 +574,13 @@ babel-helpers@^6.24.1: babel-runtime "^6.22.0" babel-template "^6.24.1" +babel-jest@^21.2.0: + version "21.2.0" + resolved "https://registry.yarnpkg.com/babel-jest/-/babel-jest-21.2.0.tgz#2ce059519a9374a2c46f2455b6fbef5ad75d863e" + dependencies: + babel-plugin-istanbul "^4.0.0" + babel-preset-jest "^21.2.0" + babel-loader@^7.1.2: version "7.1.2" resolved "https://registry.yarnpkg.com/babel-loader/-/babel-loader-7.1.2.tgz#f6cbe122710f1aa2af4d881c6d5b54358ca24126" @@ -578,6 +601,26 @@ babel-plugin-check-es2015-constants@^6.22.0: dependencies: babel-runtime "^6.22.0" +babel-plugin-dynamic-import-node@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/babel-plugin-dynamic-import-node/-/babel-plugin-dynamic-import-node-1.1.0.tgz#bd1d88ac7aaf98df4917c384373b04d971a2b37a" + dependencies: + babel-plugin-syntax-dynamic-import "^6.18.0" + babel-template "^6.26.0" + babel-types "^6.26.0" + +babel-plugin-istanbul@^4.0.0: + version "4.1.5" + resolved "https://registry.yarnpkg.com/babel-plugin-istanbul/-/babel-plugin-istanbul-4.1.5.tgz#6760cdd977f411d3e175bb064f2bc327d99b2b6e" + dependencies: + find-up "^2.1.0" + istanbul-lib-instrument "^1.7.5" + test-exclude "^4.1.1" + +babel-plugin-jest-hoist@^21.2.0: + version "21.2.0" + resolved "https://registry.yarnpkg.com/babel-plugin-jest-hoist/-/babel-plugin-jest-hoist-21.2.0.tgz#2cef637259bd4b628a6cace039de5fcd14dbb006" + babel-plugin-syntax-async-functions@^6.8.0: version "6.13.0" resolved "https://registry.yarnpkg.com/babel-plugin-syntax-async-functions/-/babel-plugin-syntax-async-functions-6.13.0.tgz#cad9cad1191b5ad634bf30ae0872391e0647be95" @@ -602,7 +645,7 @@ babel-plugin-syntax-jsx@^6.3.13, babel-plugin-syntax-jsx@^6.8.0: version "6.18.0" resolved "https://registry.yarnpkg.com/babel-plugin-syntax-jsx/-/babel-plugin-syntax-jsx-6.18.0.tgz#0af32a9a6e13ca7a3fd5069e62d7b0f58d0d8946" -babel-plugin-syntax-object-rest-spread@^6.8.0: +babel-plugin-syntax-object-rest-spread@^6.13.0, babel-plugin-syntax-object-rest-spread@^6.8.0: version "6.13.0" resolved "https://registry.yarnpkg.com/babel-plugin-syntax-object-rest-spread/-/babel-plugin-syntax-object-rest-spread-6.13.0.tgz#fd6536f2bce13836ffa3a5458c4903a597bb3bf5" @@ -724,6 +767,15 @@ babel-plugin-transform-es2015-modules-commonjs@^6.24.1: babel-template "^6.24.1" babel-types "^6.24.1" +babel-plugin-transform-es2015-modules-commonjs@^6.26.0: + version "6.26.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-modules-commonjs/-/babel-plugin-transform-es2015-modules-commonjs-6.26.0.tgz#0d8394029b7dc6abe1a97ef181e00758dd2e5d8a" + dependencies: + babel-plugin-transform-strict-mode "^6.24.1" + babel-runtime "^6.26.0" + babel-template "^6.26.0" + babel-types "^6.26.0" + babel-plugin-transform-es2015-modules-systemjs@^6.24.1: version "6.24.1" resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-modules-systemjs/-/babel-plugin-transform-es2015-modules-systemjs-6.24.1.tgz#ff89a142b9119a906195f5f106ecf305d9407d23" @@ -903,6 +955,13 @@ babel-preset-flow@^6.23.0: dependencies: babel-plugin-transform-flow-strip-types "^6.22.0" +babel-preset-jest@^21.2.0: + version "21.2.0" + resolved "https://registry.yarnpkg.com/babel-preset-jest/-/babel-preset-jest-21.2.0.tgz#ff9d2bce08abd98e8a36d9a8a5189b9173b85638" + dependencies: + babel-plugin-jest-hoist "^21.2.0" + babel-plugin-syntax-object-rest-spread "^6.13.0" + babel-preset-react@^6.23.0: version "6.24.1" resolved "https://registry.yarnpkg.com/babel-preset-react/-/babel-preset-react-6.24.1.tgz#ba69dfaea45fc3ec639b6a4ecea6e17702c91380" @@ -1094,6 +1153,12 @@ brorand@^1.0.1: version "1.1.0" resolved "https://registry.yarnpkg.com/brorand/-/brorand-1.1.0.tgz#12c25efe40a45e3c323eb8675a0a0ce57b22371f" +browser-resolve@^1.11.2: + version "1.11.2" + resolved "https://registry.yarnpkg.com/browser-resolve/-/browser-resolve-1.11.2.tgz#8ff09b0a2c421718a1051c260b32e48f442938ce" + dependencies: + resolve "1.1.7" + browser-stdout@1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/browser-stdout/-/browser-stdout-1.3.0.tgz#f351d32969d32fa5d7a5567154263d928ae3bd1f" @@ -1156,6 +1221,12 @@ browserslist@^1.3.6, browserslist@^1.5.2, browserslist@^1.7.6: caniuse-db "^1.0.30000639" electron-to-chromium "^1.2.7" +bser@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/bser/-/bser-2.0.0.tgz#9ac78d3ed5d915804fd87acb158bc797147a1719" + dependencies: + node-int64 "^0.4.0" + bson@~1.0.4: version "1.0.4" resolved "https://registry.yarnpkg.com/bson/-/bson-1.0.4.tgz#93c10d39eaa5b58415cbc4052f3e53e562b0b72c" @@ -1218,6 +1289,10 @@ callsites@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/callsites/-/callsites-0.2.0.tgz#afab96262910a7f33c19a5775825c69f34e350ca" +callsites@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/callsites/-/callsites-2.0.0.tgz#06eb84f00eea413da86affefacbffb36093b3c50" + camelcase@^1.0.2: version "1.2.1" resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-1.2.1.tgz#9bb5304d2e0b56698b2c758b08a3eaa9daa58a39" @@ -1226,6 +1301,10 @@ camelcase@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-3.0.0.tgz#32fc4b9fcdaf845fcdf7e73bb97cac2261f0ab0a" +camelcase@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-4.1.0.tgz#d545635be1e33c542649c69173e5de6acfae34dd" + camelize@1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/camelize/-/camelize-1.0.0.tgz#164a5483e630fa4321e5af07020e531831b2609b" @@ -1300,7 +1379,7 @@ chalk@^1.0.0, chalk@^1.1.1, chalk@^1.1.3: strip-ansi "^3.0.0" supports-color "^2.0.0" -chalk@^2.0.0, chalk@^2.1.0: +chalk@^2.0.0, chalk@^2.0.1, chalk@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.1.0.tgz#ac5becf14fa21b99c6c92ca7a7d7cfd5b17e743e" dependencies: @@ -1360,26 +1439,16 @@ cheerio@^0.20.0: optionalDependencies: jsdom "^7.0.2" -cheerio@^0.22.0: - version "0.22.0" - resolved "https://registry.yarnpkg.com/cheerio/-/cheerio-0.22.0.tgz#a9baa860a3f9b595a6b81b1a86873121ed3a269e" +cheerio@^1.0.0-rc.2: + version "1.0.0-rc.2" + resolved "https://registry.yarnpkg.com/cheerio/-/cheerio-1.0.0-rc.2.tgz#4b9f53a81b27e4d5dac31c0ffd0cfa03cc6830db" dependencies: css-select "~1.2.0" dom-serializer "~0.1.0" entities "~1.1.1" htmlparser2 "^3.9.1" - lodash.assignin "^4.0.9" - lodash.bind "^4.1.4" - lodash.defaults "^4.0.1" - lodash.filter "^4.4.0" - lodash.flatten "^4.2.0" - lodash.foreach "^4.3.0" - lodash.map "^4.4.0" - lodash.merge "^4.4.0" - lodash.pick "^4.2.1" - lodash.reduce "^4.4.0" - lodash.reject "^4.4.0" - lodash.some "^4.4.0" + lodash "^4.15.0" + parse5 "^3.0.1" chokidar@^1.4.3, chokidar@^1.6.1: version "1.6.1" @@ -1402,6 +1471,10 @@ chrono-node@^1.2.3: dependencies: moment "^2.10.3" +ci-info@^1.0.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-1.1.1.tgz#47b44df118c48d2597b56d342e7e25791060171a" + cipher-base@^1.0.0, cipher-base@^1.0.1: version "1.0.3" resolved "https://registry.yarnpkg.com/cipher-base/-/cipher-base-1.0.3.tgz#eeabf194419ce900da3018c207d212f2a6df0a07" @@ -1554,6 +1627,10 @@ colormin@^1.0.5: css-color-names "0.0.4" has "^1.0.1" +colors@0.5.x: + version "0.5.1" + resolved "https://registry.yarnpkg.com/colors/-/colors-0.5.1.tgz#7d0023eaeb154e8ee9fce75dcb923d0ed1667774" + colors@1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/colors/-/colors-1.0.3.tgz#0433f44d809680fdeb60ed260f1b0c262e82a40b" @@ -1702,6 +1779,10 @@ content-security-policy-builder@1.1.0: dependencies: dashify "^0.2.0" +content-type-parser@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/content-type-parser/-/content-type-parser-1.0.1.tgz#c3e56988c53c65127fb46d4032a3a900246fdc94" + content-type@~1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/content-type/-/content-type-1.0.2.tgz#b7d113aee7a8dd27bd21133c4dc2529df1721eed" @@ -1719,7 +1800,7 @@ conventional-commit-types@^2.0.0: version "2.1.0" resolved "https://registry.yarnpkg.com/conventional-commit-types/-/conventional-commit-types-2.1.0.tgz#45d860386c9a2e6537ee91d8a1b61bd0411b3d04" -convert-source-map@^1.5.0: +convert-source-map@^1.4.0, convert-source-map@^1.5.0: version "1.5.0" resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.5.0.tgz#9acd70851c6d5dfdd93d9282e5edf94a03ff46b5" @@ -1809,7 +1890,7 @@ create-react-class@^15.5.1, create-react-class@^15.5.2: fbjs "^0.8.9" object-assign "^4.1.1" -cross-spawn@^5.1.0: +cross-spawn@^5.0.1, cross-spawn@^5.1.0: version "5.1.0" resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-5.1.0.tgz#e8bd0efee58fcff6f8f94510a0a554bbfa235449" dependencies: @@ -1955,11 +2036,11 @@ csso@~2.3.1: clap "^1.0.9" source-map "^0.5.3" -cssom@0.3.x, "cssom@>= 0.3.0 < 0.4.0": +cssom@0.3.x, "cssom@>= 0.3.0 < 0.4.0", "cssom@>= 0.3.2 < 0.4.0": version "0.3.2" resolved "https://registry.yarnpkg.com/cssom/-/cssom-0.3.2.tgz#b8036170c79f07a90ff2f16e22284027a243848b" -"cssstyle@>= 0.2.29 < 0.3.0": +"cssstyle@>= 0.2.29 < 0.3.0", "cssstyle@>= 0.2.37 < 0.3.0": version "0.2.37" resolved "https://registry.yarnpkg.com/cssstyle/-/cssstyle-0.2.37.tgz#541097234cb2513c83ceed3acddc27ff27987d54" dependencies: @@ -2153,7 +2234,7 @@ did-you-mean@^0.0.1: levenshtein "*" underscore "*" -diff@3.2.0, diff@^3.1.0: +diff@3.2.0, diff@^3.1.0, diff@^3.2.0: version "3.2.0" resolved "https://registry.yarnpkg.com/diff/-/diff-3.2.0.tgz#c9ce393a4b7cbd0b058a725c93df299027868ff9" @@ -2165,6 +2246,10 @@ diffie-hellman@^5.0.0: miller-rabin "^4.0.0" randombytes "^2.0.0" +discontinuous-range@1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/discontinuous-range/-/discontinuous-range-1.0.0.tgz#e38331f0844bba49b9a9cb71c771585aab1bc65a" + dns-prefetch-control@0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/dns-prefetch-control/-/dns-prefetch-control-0.1.0.tgz#60ddb457774e178f1f9415f0cabb0e85b0b300b2" @@ -2319,22 +2404,40 @@ env-rewrite@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/env-rewrite/-/env-rewrite-1.0.2.tgz#3e344a95af1bdaab34a559479b8be3abd0804183" -enzyme@^2.9.1: - version "2.9.1" - resolved "https://registry.yarnpkg.com/enzyme/-/enzyme-2.9.1.tgz#07d5ce691241240fb817bf2c4b18d6e530240df6" +enzyme-adapter-react-15@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/enzyme-adapter-react-15/-/enzyme-adapter-react-15-1.0.1.tgz#c1a3e5966bf1c7221c40aa0f877850175035406f" dependencies: - cheerio "^0.22.0" - function.prototype.name "^1.0.0" + enzyme-adapter-utils "^1.0.0" + lodash "^4.17.4" + object.assign "^4.0.4" + object.values "^1.0.4" + prop-types "^15.5.10" + +enzyme-adapter-utils@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/enzyme-adapter-utils/-/enzyme-adapter-utils-1.0.1.tgz#fcd81223339a55a312f7552641e045c404084009" + dependencies: + lodash "^4.17.4" + object.assign "^4.0.4" + prop-types "^15.5.10" + +enzyme@^3.0.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/enzyme/-/enzyme-3.1.0.tgz#d8ca84085790fbcec6ed40badd14478faee4c25a" + dependencies: + cheerio "^1.0.0-rc.2" + function.prototype.name "^1.0.3" is-subset "^0.1.1" lodash "^4.17.4" object-is "^1.0.1" object.assign "^4.0.4" object.entries "^1.0.4" object.values "^1.0.4" - prop-types "^15.5.10" - uuid "^3.0.1" + raf "^3.3.2" + rst-selector-parser "^2.2.2" -errno@^0.1.3: +errno@^0.1.3, errno@^0.1.4: version "0.1.4" resolved "https://registry.yarnpkg.com/errno/-/errno-0.1.4.tgz#b896e23a9e5e8ba33871fc996abd3635fc9a1c7d" dependencies: @@ -2555,6 +2658,24 @@ evp_bytestokey@^1.0.0: dependencies: create-hash "^1.1.1" +exec-sh@^0.2.0: + version "0.2.1" + resolved "https://registry.yarnpkg.com/exec-sh/-/exec-sh-0.2.1.tgz#163b98a6e89e6b65b47c2a28d215bc1f63989c38" + dependencies: + merge "^1.1.3" + +execa@^0.7.0: + version "0.7.0" + resolved "https://registry.yarnpkg.com/execa/-/execa-0.7.0.tgz#944becd34cc41ee32a63a9faf27ad5a65fc59777" + dependencies: + cross-spawn "^5.0.1" + get-stream "^3.0.0" + is-stream "^1.1.0" + npm-run-path "^2.0.0" + p-finally "^1.0.0" + signal-exit "^3.0.0" + strip-eof "^1.0.0" + exit-hook@^1.0.0: version "1.1.1" resolved "https://registry.yarnpkg.com/exit-hook/-/exit-hook-1.1.1.tgz#f05ca233b48c05d54fff07765df8507e95c02ff8" @@ -2579,6 +2700,17 @@ expect-ct@0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/expect-ct/-/expect-ct-0.1.0.tgz#52735678de18530890d8d7b95f0ac63640958094" +expect@^21.2.1: + version "21.2.1" + resolved "https://registry.yarnpkg.com/expect/-/expect-21.2.1.tgz#003ac2ac7005c3c29e73b38a272d4afadd6d1d7b" + dependencies: + ansi-styles "^3.2.0" + jest-diff "^21.2.1" + jest-get-type "^21.2.0" + jest-matcher-utils "^21.2.1" + jest-message-util "^21.2.1" + jest-regex-util "^21.2.0" + exports-loader@^0.6.4: version "0.6.4" resolved "https://registry.yarnpkg.com/exports-loader/-/exports-loader-0.6.4.tgz#d70fc6121975b35fc12830cf52754be2740fc886" @@ -2657,6 +2789,12 @@ fastparse@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/fastparse/-/fastparse-1.1.1.tgz#d1e2643b38a94d7583b479060e6c4affc94071f8" +fb-watchman@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/fb-watchman/-/fb-watchman-2.0.0.tgz#54e9abf7dfa2f26cd9b1636c588c1afc05de5d58" + dependencies: + bser "^2.0.0" + fbjs@^0.8.1, fbjs@^0.8.9: version "0.8.12" resolved "https://registry.yarnpkg.com/fbjs/-/fbjs-0.8.12.tgz#10b5d92f76d45575fd63a217d4ea02bea2f8ed04" @@ -2752,7 +2890,7 @@ find-parent-dir@^0.3.0: version "0.3.0" resolved "https://registry.yarnpkg.com/find-parent-dir/-/find-parent-dir-0.3.0.tgz#33c44b429ab2b2f0646299c5f9f718f376ff8d54" -find-up@2.1.0, find-up@^2.1.0: +find-up@2.1.0, find-up@^2.0.0, find-up@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/find-up/-/find-up-2.1.0.tgz#45d1b7e506c717ddd482775a2b77920a3c0c57a7" dependencies: @@ -2906,7 +3044,7 @@ fs.realpath@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" -fsevents@^1.0.0: +fsevents@^1.0.0, fsevents@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-1.1.1.tgz#f19fd28f43eeaf761680e519a203c4d0b3d31aff" dependencies: @@ -2934,7 +3072,7 @@ function-bind@^1.0.2, function-bind@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.0.tgz#16176714c801798e4e8f2cf7f7529467bb4a5771" -function.prototype.name@^1.0.0: +function.prototype.name@^1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/function.prototype.name/-/function.prototype.name-1.0.3.tgz#0099ae5572e9dd6f03c97d023fd92bcc5e639eac" dependencies: @@ -2963,6 +3101,10 @@ get-caller-file@^1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-1.0.2.tgz#f702e63127e7e231c160a80c1554acb70d5047e5" +get-stream@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-3.0.0.tgz#8e943d1358dc37555054ecbe2edb05aa174ede14" + getpass@^0.1.1: version "0.1.7" resolved "https://registry.yarnpkg.com/getpass/-/getpass-0.1.7.tgz#5eff8e3e684d569ae4cb2b1282604e8ba62149fa" @@ -3276,6 +3418,10 @@ growl@1.9.2: version "1.9.2" resolved "https://registry.yarnpkg.com/growl/-/growl-1.9.2.tgz#0ea7743715db8d8de2c5ede1775e1b45ac85c02f" +growly@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/growly/-/growly-1.3.0.tgz#f10748cbe76af964b7c96c93c6bcc28af120c081" + hammerjs@^2.0.8: version "2.0.8" resolved "https://registry.yarnpkg.com/hammerjs/-/hammerjs-2.0.8.tgz#04ef77862cff2bb79d30f7692095930222bf60f1" @@ -3301,6 +3447,10 @@ har-validator@~4.2.1: ajv "^4.9.1" har-schema "^1.0.5" +harmony-reflect@^1.4.6: + version "1.5.1" + resolved "https://registry.yarnpkg.com/harmony-reflect/-/harmony-reflect-1.5.1.tgz#b54ca617b00cc8aef559bbb17b3d85431dc7e329" + has-ansi@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/has-ansi/-/has-ansi-2.0.0.tgz#34f5049ce1ecdf2b0649af3ef24e45ed35416d91" @@ -3436,6 +3586,12 @@ html-comment-regex@^1.1.0: version "1.1.1" resolved "https://registry.yarnpkg.com/html-comment-regex/-/html-comment-regex-1.1.1.tgz#668b93776eaae55ebde8f3ad464b307a4963625e" +html-encoding-sniffer@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/html-encoding-sniffer/-/html-encoding-sniffer-1.0.1.tgz#79bf7a785ea495fe66165e734153f363ff5437da" + dependencies: + whatwg-encoding "^1.0.1" + htmlparser2@3.8.x, htmlparser2@~3.8.1: version "3.8.3" resolved "https://registry.yarnpkg.com/htmlparser2/-/htmlparser2-3.8.3.tgz#996c28b191516a8be86501a7d79757e5c70c1068" @@ -3498,6 +3654,10 @@ https-browserify@0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/https-browserify/-/https-browserify-0.0.1.tgz#3f91365cabe60b77ed0ebba24b454e3e09d95a82" +iconv-lite@0.4.13: + version "0.4.13" + resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.13.tgz#1f88aba4ab0b1508e8312acc39345f36e992e2f2" + iconv-lite@0.4.15: version "0.4.15" resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.15.tgz#fe265a218ac6a57cfe854927e9d04c19825eddeb" @@ -3516,6 +3676,12 @@ icss-utils@^2.1.0: dependencies: postcss "^6.0.1" +identity-obj-proxy@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/identity-obj-proxy/-/identity-obj-proxy-3.0.0.tgz#94d2bda96084453ef36fbc5aaec37e0f79f1fc14" + dependencies: + harmony-reflect "^1.4.6" + ieee754@^1.1.4: version "1.1.8" resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.1.8.tgz#be33d40ac10ef1926701f6f08a2d86fbfd1ad3e4" @@ -3738,6 +3904,12 @@ is-callable@^1.1.1, is-callable@^1.1.3: version "1.1.3" resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.1.3.tgz#86eb75392805ddc33af71c92a0eedf74ee7604b2" +is-ci@^1.0.10: + version "1.0.10" + resolved "https://registry.yarnpkg.com/is-ci/-/is-ci-1.0.10.tgz#f739336b2632365061a9d48270cd56ae3369318e" + dependencies: + ci-info "^1.0.0" + is-date-object@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/is-date-object/-/is-date-object-1.0.1.tgz#9aa20eb6aeebbff77fbd33e74ca01b33581d3a16" @@ -3884,7 +4056,7 @@ is-ssh@^1.3.0: dependencies: protocols "^1.1.0" -is-stream@^1.0.0, is-stream@^1.0.1: +is-stream@^1.0.0, is-stream@^1.0.1, is-stream@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44" @@ -3951,7 +4123,7 @@ isstream@~0.1.2: version "0.1.2" resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a" -istanbul-api@^1.1.0-alpha: +istanbul-api@^1.1.0-alpha, istanbul-api@^1.1.1: version "1.1.7" resolved "https://registry.yarnpkg.com/istanbul-api/-/istanbul-api-1.1.7.tgz#f6f37f09f8002b130f891c646b70ee4a8e7345ae" dependencies: @@ -3967,6 +4139,10 @@ istanbul-api@^1.1.0-alpha: mkdirp "^0.5.1" once "^1.4.0" +istanbul-lib-coverage@^1.0.1, istanbul-lib-coverage@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/istanbul-lib-coverage/-/istanbul-lib-coverage-1.1.1.tgz#73bfb998885299415c93d38a3e9adf784a77a9da" + istanbul-lib-coverage@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/istanbul-lib-coverage/-/istanbul-lib-coverage-1.0.2.tgz#87a0c015b6910651cb3b184814dfb339337e25e1" @@ -3977,6 +4153,18 @@ istanbul-lib-hook@^1.0.5: dependencies: append-transform "^0.4.0" +istanbul-lib-instrument@^1.4.2, istanbul-lib-instrument@^1.7.5: + version "1.8.0" + resolved "https://registry.yarnpkg.com/istanbul-lib-instrument/-/istanbul-lib-instrument-1.8.0.tgz#66f6c9421cc9ec4704f76f2db084ba9078a2b532" + dependencies: + babel-generator "^6.18.0" + babel-template "^6.16.0" + babel-traverse "^6.18.0" + babel-types "^6.18.0" + babylon "^6.18.0" + istanbul-lib-coverage "^1.1.1" + semver "^5.3.0" + istanbul-lib-instrument@^1.7.0: version "1.7.0" resolved "https://registry.yarnpkg.com/istanbul-lib-instrument/-/istanbul-lib-instrument-1.7.0.tgz#b8e0dc25709bb44e17336ab47b7bb5c97c23f659" @@ -3998,7 +4186,7 @@ istanbul-lib-report@^1.0.0: path-parse "^1.0.5" supports-color "^3.1.2" -istanbul-lib-source-maps@^1.1.1: +istanbul-lib-source-maps@^1.1.0, istanbul-lib-source-maps@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/istanbul-lib-source-maps/-/istanbul-lib-source-maps-1.1.1.tgz#f8c8c2e8f2160d1d91526d97e5bd63b2079af71c" dependencies: @@ -4042,6 +4230,231 @@ iterall@^1.1.0, iterall@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/iterall/-/iterall-1.1.1.tgz#f7f0af11e9a04ec6426260f5019d9fcca4d50214" +jest-changed-files@^21.2.0: + version "21.2.0" + resolved "https://registry.yarnpkg.com/jest-changed-files/-/jest-changed-files-21.2.0.tgz#5dbeecad42f5d88b482334902ce1cba6d9798d29" + dependencies: + throat "^4.0.0" + +jest-cli@^21.2.1: + version "21.2.1" + resolved "https://registry.yarnpkg.com/jest-cli/-/jest-cli-21.2.1.tgz#9c528b6629d651911138d228bdb033c157ec8c00" + dependencies: + ansi-escapes "^3.0.0" + chalk "^2.0.1" + glob "^7.1.2" + graceful-fs "^4.1.11" + is-ci "^1.0.10" + istanbul-api "^1.1.1" + istanbul-lib-coverage "^1.0.1" + istanbul-lib-instrument "^1.4.2" + istanbul-lib-source-maps "^1.1.0" + jest-changed-files "^21.2.0" + jest-config "^21.2.1" + jest-environment-jsdom "^21.2.1" + jest-haste-map "^21.2.0" + jest-message-util "^21.2.1" + jest-regex-util "^21.2.0" + jest-resolve-dependencies "^21.2.0" + jest-runner "^21.2.1" + jest-runtime "^21.2.1" + jest-snapshot "^21.2.1" + jest-util "^21.2.1" + micromatch "^2.3.11" + node-notifier "^5.0.2" + pify "^3.0.0" + slash "^1.0.0" + string-length "^2.0.0" + strip-ansi "^4.0.0" + which "^1.2.12" + worker-farm "^1.3.1" + yargs "^9.0.0" + +jest-config@^21.2.1: + version "21.2.1" + resolved "https://registry.yarnpkg.com/jest-config/-/jest-config-21.2.1.tgz#c7586c79ead0bcc1f38c401e55f964f13bf2a480" + dependencies: + chalk "^2.0.1" + glob "^7.1.1" + jest-environment-jsdom "^21.2.1" + jest-environment-node "^21.2.1" + jest-get-type "^21.2.0" + jest-jasmine2 "^21.2.1" + jest-regex-util "^21.2.0" + jest-resolve "^21.2.0" + jest-util "^21.2.1" + jest-validate "^21.2.1" + pretty-format "^21.2.1" + +jest-diff@^21.2.1: + version "21.2.1" + resolved "https://registry.yarnpkg.com/jest-diff/-/jest-diff-21.2.1.tgz#46cccb6cab2d02ce98bc314011764bb95b065b4f" + dependencies: + chalk "^2.0.1" + diff "^3.2.0" + jest-get-type "^21.2.0" + pretty-format "^21.2.1" + +jest-docblock@^21.2.0: + version "21.2.0" + resolved "https://registry.yarnpkg.com/jest-docblock/-/jest-docblock-21.2.0.tgz#51529c3b30d5fd159da60c27ceedc195faf8d414" + +jest-environment-jsdom@^21.2.1: + version "21.2.1" + resolved "https://registry.yarnpkg.com/jest-environment-jsdom/-/jest-environment-jsdom-21.2.1.tgz#38d9980c8259b2a608ec232deee6289a60d9d5b4" + dependencies: + jest-mock "^21.2.0" + jest-util "^21.2.1" + jsdom "^9.12.0" + +jest-environment-node@^21.2.1: + version "21.2.1" + resolved "https://registry.yarnpkg.com/jest-environment-node/-/jest-environment-node-21.2.1.tgz#98c67df5663c7fbe20f6e792ac2272c740d3b8c8" + dependencies: + jest-mock "^21.2.0" + jest-util "^21.2.1" + +jest-get-type@^21.2.0: + version "21.2.0" + resolved "https://registry.yarnpkg.com/jest-get-type/-/jest-get-type-21.2.0.tgz#f6376ab9db4b60d81e39f30749c6c466f40d4a23" + +jest-haste-map@^21.2.0: + version "21.2.0" + resolved "https://registry.yarnpkg.com/jest-haste-map/-/jest-haste-map-21.2.0.tgz#1363f0a8bb4338f24f001806571eff7a4b2ff3d8" + dependencies: + fb-watchman "^2.0.0" + graceful-fs "^4.1.11" + jest-docblock "^21.2.0" + micromatch "^2.3.11" + sane "^2.0.0" + worker-farm "^1.3.1" + +jest-jasmine2@^21.2.1: + version "21.2.1" + resolved "https://registry.yarnpkg.com/jest-jasmine2/-/jest-jasmine2-21.2.1.tgz#9cc6fc108accfa97efebce10c4308548a4ea7592" + dependencies: + chalk "^2.0.1" + expect "^21.2.1" + graceful-fs "^4.1.11" + jest-diff "^21.2.1" + jest-matcher-utils "^21.2.1" + jest-message-util "^21.2.1" + jest-snapshot "^21.2.1" + p-cancelable "^0.3.0" + +jest-matcher-utils@^21.2.1: + version "21.2.1" + resolved "https://registry.yarnpkg.com/jest-matcher-utils/-/jest-matcher-utils-21.2.1.tgz#72c826eaba41a093ac2b4565f865eb8475de0f64" + dependencies: + chalk "^2.0.1" + jest-get-type "^21.2.0" + pretty-format "^21.2.1" + +jest-message-util@^21.2.1: + version "21.2.1" + resolved "https://registry.yarnpkg.com/jest-message-util/-/jest-message-util-21.2.1.tgz#bfe5d4692c84c827d1dcf41823795558f0a1acbe" + dependencies: + chalk "^2.0.1" + micromatch "^2.3.11" + slash "^1.0.0" + +jest-mock@^21.2.0: + version "21.2.0" + resolved "https://registry.yarnpkg.com/jest-mock/-/jest-mock-21.2.0.tgz#7eb0770e7317968165f61ea2a7281131534b3c0f" + +jest-regex-util@^21.2.0: + version "21.2.0" + resolved "https://registry.yarnpkg.com/jest-regex-util/-/jest-regex-util-21.2.0.tgz#1b1e33e63143babc3e0f2e6c9b5ba1eb34b2d530" + +jest-resolve-dependencies@^21.2.0: + version "21.2.0" + resolved "https://registry.yarnpkg.com/jest-resolve-dependencies/-/jest-resolve-dependencies-21.2.0.tgz#9e231e371e1a736a1ad4e4b9a843bc72bfe03d09" + dependencies: + jest-regex-util "^21.2.0" + +jest-resolve@^21.2.0: + version "21.2.0" + resolved "https://registry.yarnpkg.com/jest-resolve/-/jest-resolve-21.2.0.tgz#068913ad2ba6a20218e5fd32471f3874005de3a6" + dependencies: + browser-resolve "^1.11.2" + chalk "^2.0.1" + is-builtin-module "^1.0.0" + +jest-runner@^21.2.1: + version "21.2.1" + resolved "https://registry.yarnpkg.com/jest-runner/-/jest-runner-21.2.1.tgz#194732e3e518bfb3d7cbfc0fd5871246c7e1a467" + dependencies: + jest-config "^21.2.1" + jest-docblock "^21.2.0" + jest-haste-map "^21.2.0" + jest-jasmine2 "^21.2.1" + jest-message-util "^21.2.1" + jest-runtime "^21.2.1" + jest-util "^21.2.1" + pify "^3.0.0" + throat "^4.0.0" + worker-farm "^1.3.1" + +jest-runtime@^21.2.1: + version "21.2.1" + resolved "https://registry.yarnpkg.com/jest-runtime/-/jest-runtime-21.2.1.tgz#99dce15309c670442eee2ebe1ff53a3cbdbbb73e" + dependencies: + babel-core "^6.0.0" + babel-jest "^21.2.0" + babel-plugin-istanbul "^4.0.0" + chalk "^2.0.1" + convert-source-map "^1.4.0" + graceful-fs "^4.1.11" + jest-config "^21.2.1" + jest-haste-map "^21.2.0" + jest-regex-util "^21.2.0" + jest-resolve "^21.2.0" + jest-util "^21.2.1" + json-stable-stringify "^1.0.1" + micromatch "^2.3.11" + slash "^1.0.0" + strip-bom "3.0.0" + write-file-atomic "^2.1.0" + yargs "^9.0.0" + +jest-snapshot@^21.2.1: + version "21.2.1" + resolved "https://registry.yarnpkg.com/jest-snapshot/-/jest-snapshot-21.2.1.tgz#29e49f16202416e47343e757e5eff948c07fd7b0" + dependencies: + chalk "^2.0.1" + jest-diff "^21.2.1" + jest-matcher-utils "^21.2.1" + mkdirp "^0.5.1" + natural-compare "^1.4.0" + pretty-format "^21.2.1" + +jest-util@^21.2.1: + version "21.2.1" + resolved "https://registry.yarnpkg.com/jest-util/-/jest-util-21.2.1.tgz#a274b2f726b0897494d694a6c3d6a61ab819bb78" + dependencies: + callsites "^2.0.0" + chalk "^2.0.1" + graceful-fs "^4.1.11" + jest-message-util "^21.2.1" + jest-mock "^21.2.0" + jest-validate "^21.2.1" + mkdirp "^0.5.1" + +jest-validate@^21.2.1: + version "21.2.1" + resolved "https://registry.yarnpkg.com/jest-validate/-/jest-validate-21.2.1.tgz#cc0cbca653cd54937ba4f2a111796774530dd3c7" + dependencies: + chalk "^2.0.1" + jest-get-type "^21.2.0" + leven "^2.1.0" + pretty-format "^21.2.1" + +jest@^21.2.1: + version "21.2.1" + resolved "https://registry.yarnpkg.com/jest/-/jest-21.2.1.tgz#c964e0b47383768a1438e3ccf3c3d470327604e1" + dependencies: + jest-cli "^21.2.1" + jju@^1.1.0: version "1.3.0" resolved "https://registry.yarnpkg.com/jju/-/jju-1.3.0.tgz#dadd9ef01924bc728b03f2f7979bdbd62f7a2aaa" @@ -4131,6 +4544,30 @@ jsdom@^7.0.2: whatwg-url-compat "~0.6.5" xml-name-validator ">= 2.0.1 < 3.0.0" +jsdom@^9.12.0: + version "9.12.0" + resolved "https://registry.yarnpkg.com/jsdom/-/jsdom-9.12.0.tgz#e8c546fffcb06c00d4833ca84410fed7f8a097d4" + dependencies: + abab "^1.0.3" + acorn "^4.0.4" + acorn-globals "^3.1.0" + array-equal "^1.0.0" + content-type-parser "^1.0.1" + cssom ">= 0.3.2 < 0.4.0" + cssstyle ">= 0.2.37 < 0.3.0" + escodegen "^1.6.1" + html-encoding-sniffer "^1.0.1" + nwmatcher ">= 1.3.9 < 2.0.0" + parse5 "^1.5.1" + request "^2.79.0" + sax "^1.2.1" + symbol-tree "^3.2.1" + tough-cookie "^2.3.2" + webidl-conversions "^4.0.0" + whatwg-encoding "^1.0.1" + whatwg-url "^4.3.0" + xml-name-validator "^2.0.1" + jsesc@^1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-1.3.0.tgz#46c3fec8c1892b12b0833db9bc7622176dbab34b" @@ -4332,6 +4769,10 @@ lcid@^1.0.0: dependencies: invert-kv "^1.0.0" +leven@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/leven/-/leven-2.1.0.tgz#c2e7a9f772094dee9d34202ae8acce4687875580" + levenshtein@*: version "1.0.5" resolved "https://registry.yarnpkg.com/levenshtein/-/levenshtein-1.0.5.tgz#3911737a9cb56da345d008f55782c6f138979ba3" @@ -4381,6 +4822,15 @@ load-json-file@^1.0.0: pinkie-promise "^2.0.0" strip-bom "^2.0.0" +load-json-file@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/load-json-file/-/load-json-file-2.0.0.tgz#7947e42149af80d696cbf797bcaabcfe1fe29ca8" + dependencies: + graceful-fs "^4.1.2" + parse-json "^2.2.0" + pify "^2.0.0" + strip-bom "^3.0.0" + loader-runner@^2.3.0: version "2.3.0" resolved "https://registry.yarnpkg.com/loader-runner/-/loader-runner-2.3.0.tgz#f482aea82d543e07921700d5a46ef26fdac6b8a2" @@ -4460,11 +4910,7 @@ lodash.assign@^4.0.3, lodash.assign@^4.0.6, lodash.assign@^4.1.0, lodash.assign@ version "4.2.0" resolved "https://registry.yarnpkg.com/lodash.assign/-/lodash.assign-4.2.0.tgz#0d99f3ccd7a6d261d19bdaeb9245005d285808e7" -lodash.assignin@^4.0.9: - version "4.2.0" - resolved "https://registry.yarnpkg.com/lodash.assignin/-/lodash.assignin-4.2.0.tgz#ba8df5fb841eb0a3e8044232b0e263a8dc6a28a2" - -lodash.bind@^4.1.4, lodash.bind@^4.2.1: +lodash.bind@^4.2.1: version "4.2.1" resolved "https://registry.yarnpkg.com/lodash.bind/-/lodash.bind-4.2.1.tgz#7ae3017e939622ac31b7d7d7dcb1b34db1690d35" @@ -4495,7 +4941,7 @@ lodash.defaults@^3.1.2: lodash.assign "^3.0.0" lodash.restparam "^3.0.0" -lodash.defaults@^4.0.1, lodash.defaults@^4.2.0: +lodash.defaults@^4.2.0: version "4.2.0" resolved "https://registry.yarnpkg.com/lodash.defaults/-/lodash.defaults-4.2.0.tgz#d09178716ffea4dde9e5fb7b37f6f0802274580c" @@ -4503,15 +4949,15 @@ lodash.difference@^4.5.0: version "4.5.0" resolved "https://registry.yarnpkg.com/lodash.difference/-/lodash.difference-4.5.0.tgz#9ccb4e505d486b91651345772885a2df27fd017c" -lodash.filter@^4.4.0: - version "4.6.0" - resolved "https://registry.yarnpkg.com/lodash.filter/-/lodash.filter-4.6.0.tgz#668b1d4981603ae1cc5a6fa760143e480b4c4ace" - lodash.flatten@^4.2.0, lodash.flatten@^4.4.0: version "4.4.0" resolved "https://registry.yarnpkg.com/lodash.flatten/-/lodash.flatten-4.4.0.tgz#f31c22225a9632d2bbf8e4addbef240aa765a61f" -lodash.foreach@^4.3.0, lodash.foreach@^4.5.0: +lodash.flattendeep@^4.4.0: + version "4.4.0" + resolved "https://registry.yarnpkg.com/lodash.flattendeep/-/lodash.flattendeep-4.4.0.tgz#fb030917f86a3134e5bc9bec0d69e0013ddfedb2" + +lodash.foreach@^4.5.0: version "4.5.0" resolved "https://registry.yarnpkg.com/lodash.foreach/-/lodash.foreach-4.5.0.tgz#1a6a35eace401280c7f06dddec35165ab27e3e53" @@ -4551,7 +4997,7 @@ lodash.keys@^4.2.0: version "4.2.0" resolved "https://registry.yarnpkg.com/lodash.keys/-/lodash.keys-4.2.0.tgz#a08602ac12e4fb83f91fc1fb7a360a4d9ba35205" -lodash.map@^4.4.0, lodash.map@^4.5.1: +lodash.map@^4.5.1: version "4.6.0" resolved "https://registry.yarnpkg.com/lodash.map/-/lodash.map-4.6.0.tgz#771ec7839e3473d9c4cde28b19394c3562f4f6d3" @@ -4559,10 +5005,6 @@ lodash.memoize@^4.1.2: version "4.1.2" resolved "https://registry.yarnpkg.com/lodash.memoize/-/lodash.memoize-4.1.2.tgz#bcc6c49a42a2840ed997f323eada5ecd182e0bfe" -lodash.merge@^4.4.0: - version "4.6.0" - resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.0.tgz#69884ba144ac33fe699737a6086deffadd0f89c5" - lodash.noop@^3.0.1: version "3.0.1" resolved "https://registry.yarnpkg.com/lodash.noop/-/lodash.noop-3.0.1.tgz#38188f4d650a3a474258439b96ec45b32617133c" @@ -4575,18 +5017,14 @@ lodash.partial@^4.2.1: version "4.2.1" resolved "https://registry.yarnpkg.com/lodash.partial/-/lodash.partial-4.2.1.tgz#49f3d8cfdaa3bff8b3a91d127e923245418961d4" -lodash.pick@^4.2.1, lodash.pick@^4.4.0: +lodash.pick@^4.4.0: version "4.4.0" resolved "https://registry.yarnpkg.com/lodash.pick/-/lodash.pick-4.4.0.tgz#52f05610fff9ded422611441ed1fc123a03001b3" -lodash.reduce@4.6.0, lodash.reduce@^4.4.0: +lodash.reduce@4.6.0: version "4.6.0" resolved "https://registry.yarnpkg.com/lodash.reduce/-/lodash.reduce-4.6.0.tgz#f1ab6b839299ad48f784abbf476596f03b914d3b" -lodash.reject@^4.4.0: - version "4.6.0" - resolved "https://registry.yarnpkg.com/lodash.reject/-/lodash.reject-4.6.0.tgz#80d6492dc1470864bbf583533b651f42a9f52415" - lodash.restparam@^3.0.0: version "3.6.1" resolved "https://registry.yarnpkg.com/lodash.restparam/-/lodash.restparam-3.6.1.tgz#936a4e309ef330a7645ed4145986c85ae5b20805" @@ -4599,10 +5037,6 @@ lodash.shuffle@^4.2.0: version "4.2.0" resolved "https://registry.yarnpkg.com/lodash.shuffle/-/lodash.shuffle-4.2.0.tgz#145b5053cf875f6f5c2a33f48b6e9948c6ec7b4b" -lodash.some@^4.4.0: - version "4.6.0" - resolved "https://registry.yarnpkg.com/lodash.some/-/lodash.some-4.6.0.tgz#1bb9f314ef6b8baded13b549169b2a945eb68e4d" - lodash.toarray@^4.4.0: version "4.4.0" resolved "https://registry.yarnpkg.com/lodash.toarray/-/lodash.toarray-4.4.0.tgz#24c4bfcd6b2fba38bfd0594db1179d8e9b656561" @@ -4623,7 +5057,7 @@ lodash@3.7.x: version "3.7.0" resolved "https://registry.yarnpkg.com/lodash/-/lodash-3.7.0.tgz#3678bd8ab995057c07ade836ed2ef087da811d45" -lodash@4.17.4, lodash@^4.0.0, lodash@^4.1.0, lodash@^4.14.0, lodash@^4.16.6, lodash@^4.17.4, lodash@^4.2.0, lodash@^4.2.1, lodash@^4.3.0: +lodash@4.17.4, lodash@^4.0.0, lodash@^4.1.0, lodash@^4.14.0, lodash@^4.15.0, lodash@^4.16.6, lodash@^4.17.4, lodash@^4.2.0, lodash@^4.2.1, lodash@^4.3.0: version "4.17.4" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae" @@ -4691,6 +5125,12 @@ make-error@^1.2.0: version "1.2.3" resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.2.3.tgz#6c4402df732e0977ac6faf754a5074b3d2b1d19d" +makeerror@1.0.x: + version "1.0.11" + resolved "https://registry.yarnpkg.com/makeerror/-/makeerror-1.0.11.tgz#e01a5c9109f2af79660e4e8b9587790184f5a96c" + dependencies: + tmpl "1.0.x" + map-stream@~0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/map-stream/-/map-stream-0.1.0.tgz#e56aa94c4c8055a16404a0674b78f215f7c8e194" @@ -4719,6 +5159,12 @@ media-typer@0.3.0: version "0.3.0" resolved "https://registry.yarnpkg.com/media-typer/-/media-typer-0.3.0.tgz#8710d7af0aa626f8fffa1ce00168545263255748" +mem@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/mem/-/mem-1.1.0.tgz#5edd52b485ca1d900fe64895505399a0dfa45f76" + dependencies: + mimic-fn "^1.0.0" + memory-fs@^0.4.0, memory-fs@~0.4.1: version "0.4.1" resolved "https://registry.yarnpkg.com/memory-fs/-/memory-fs-0.4.1.tgz#3a9a20b8462523e447cfbc7e8bb80ed667bfc552" @@ -4730,6 +5176,10 @@ merge-descriptors@1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/merge-descriptors/-/merge-descriptors-1.0.1.tgz#b00aaa556dd8b44568150ec9d1b953f3f90cbb61" +merge@^1.1.3: + version "1.2.0" + resolved "https://registry.yarnpkg.com/merge/-/merge-1.2.0.tgz#7531e39d4949c281a66b8c5a6e0265e8b05894da" + metascraper@^1.0.7: version "1.0.7" resolved "https://registry.yarnpkg.com/metascraper/-/metascraper-1.0.7.tgz#2343f9108f34e4d2b55b7b4f543c96dfc52e1478" @@ -4745,7 +5195,7 @@ methods@^1.1.1, methods@^1.1.2, methods@~1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/methods/-/methods-1.1.2.tgz#5529a4d67654134edcc5266656835b0f851afcee" -micromatch@^2.1.5: +micromatch@^2.1.5, micromatch@^2.3.11: version "2.3.11" resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-2.3.11.tgz#86677c97d1720b363431d04d0d15293bd38c1565" dependencies: @@ -4816,7 +5266,7 @@ minimist@0.0.8, minimist@~0.0.1: version "0.0.8" resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d" -minimist@^1.2.0: +minimist@^1.1.1, minimist@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284" @@ -4966,6 +5416,14 @@ natural@^0.2.0: sylvester ">= 0.0.12" underscore ">=1.3.1" +nearley@^2.7.10: + version "2.11.0" + resolved "https://registry.yarnpkg.com/nearley/-/nearley-2.11.0.tgz#5e626c79a6cd2f6ab9e7e5d5805e7668967757ae" + dependencies: + nomnom "~1.6.2" + railroad-diagrams "^1.0.0" + randexp "^0.4.2" + negotiator@0.6.1: version "0.6.1" resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-0.6.1.tgz#2b327184e8992101177b28563fb5e7102acd0ca9" @@ -5020,6 +5478,10 @@ node-fetch@^1.0.1, node-fetch@^1.7.2: encoding "^0.1.11" is-stream "^1.0.1" +node-int64@^0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/node-int64/-/node-int64-0.4.0.tgz#87a9065cdb355d3182d8f94ce11188b825c68a3b" + node-libs-browser@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/node-libs-browser/-/node-libs-browser-2.0.0.tgz#a3a59ec97024985b46e958379646f96c4b616646" @@ -5048,6 +5510,15 @@ node-libs-browser@^2.0.0: util "^0.10.3" vm-browserify "0.0.4" +node-notifier@^5.0.2: + version "5.1.2" + resolved "https://registry.yarnpkg.com/node-notifier/-/node-notifier-5.1.2.tgz#2fa9e12605fa10009d44549d6fcd8a63dde0e4ff" + dependencies: + growly "^1.3.0" + semver "^5.3.0" + shellwords "^0.1.0" + which "^1.2.12" + node-pre-gyp@^0.6.29: version "0.6.32" resolved "https://registry.yarnpkg.com/node-pre-gyp/-/node-pre-gyp-0.6.32.tgz#fc452b376e7319b3d255f5f34853ef6fd8fe1fd5" @@ -5140,6 +5611,13 @@ nodemon@^1.11.0: undefsafe "0.0.3" update-notifier "0.5.0" +nomnom@~1.6.2: + version "1.6.2" + resolved "https://registry.yarnpkg.com/nomnom/-/nomnom-1.6.2.tgz#84a66a260174408fc5b77a18f888eccc44fb6971" + dependencies: + colors "0.5.x" + underscore "~1.4.4" + nopt@3.x, nopt@~3.0.6: version "3.0.6" resolved "https://registry.yarnpkg.com/nopt/-/nopt-3.0.6.tgz#c6465dbf08abcd4db359317f79ac68a646b28ff9" @@ -5180,6 +5658,12 @@ normalize-url@^1.4.0: query-string "^4.1.0" sort-keys "^1.0.0" +npm-run-path@^2.0.0: + version "2.0.2" + resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-2.0.2.tgz#35a9232dfa35d7067b4cb2ddf2357b1871536c5f" + dependencies: + path-key "^2.0.0" + npmlog@^4.0.1: version "4.0.2" resolved "https://registry.yarnpkg.com/npmlog/-/npmlog-4.0.2.tgz#d03950e0e78ce1527ba26d2a7592e9348ac3e75f" @@ -5203,7 +5687,7 @@ number-is-nan@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/number-is-nan/-/number-is-nan-1.0.1.tgz#097b602b53422a522c1afb8790318336941a011d" -"nwmatcher@>= 1.3.7 < 2.0.0": +"nwmatcher@>= 1.3.7 < 2.0.0", "nwmatcher@>= 1.3.9 < 2.0.0": version "1.3.9" resolved "https://registry.yarnpkg.com/nwmatcher/-/nwmatcher-1.3.9.tgz#8bab486ff7fa3dfd086656bbe8b17116d3692d2a" @@ -5324,6 +5808,14 @@ os-locale@^1.4.0: dependencies: lcid "^1.0.0" +os-locale@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/os-locale/-/os-locale-2.1.0.tgz#42bc2900a6b5b8bd17376c8e882b65afccf24bf2" + dependencies: + execa "^0.7.0" + lcid "^1.0.0" + mem "^1.1.0" + os-tmpdir@^1.0.0, os-tmpdir@^1.0.1, os-tmpdir@~1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" @@ -5343,6 +5835,14 @@ output-file-sync@^1.1.2: mkdirp "^0.5.1" object-assign "^4.1.0" +p-cancelable@^0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/p-cancelable/-/p-cancelable-0.3.0.tgz#b9e123800bcebb7ac13a479be195b507b98d30fa" + +p-finally@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/p-finally/-/p-finally-1.0.0.tgz#3fbcfb15b899a44123b34b6dcc18b724336a2cae" + p-limit@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-1.1.0.tgz#b07ff2d9a5d88bec806035895a2bab66a27988bc" @@ -5406,6 +5906,12 @@ parse5@^1.5.1: version "1.5.1" resolved "https://registry.yarnpkg.com/parse5/-/parse5-1.5.1.tgz#9b7f3b0de32be78dc2401b17573ccaf0f6f59d94" +parse5@^3.0.1: + version "3.0.2" + resolved "https://registry.yarnpkg.com/parse5/-/parse5-3.0.2.tgz#05eff57f0ef4577fb144a79f8b9a967a6cc44510" + dependencies: + "@types/node" "^6.0.46" + parseurl@~1.3.1: version "1.3.1" resolved "https://registry.yarnpkg.com/parseurl/-/parseurl-1.3.1.tgz#c8ab8c9223ba34888aa64a297b28853bec18da56" @@ -5456,6 +5962,10 @@ path-is-inside@^1.0.1, path-is-inside@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/path-is-inside/-/path-is-inside-1.0.2.tgz#365417dede44430d1c11af61027facf074bdfc53" +path-key@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/path-key/-/path-key-2.0.1.tgz#411cadb574c5a140d3a4b1910d40d80cc9f40b40" + path-parse@^1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.5.tgz#3c1adf871ea9cd6c9431b6ea2bd74a0ff055c4c1" @@ -5478,6 +5988,12 @@ path-type@^1.0.0: pify "^2.0.0" pinkie-promise "^2.0.0" +path-type@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/path-type/-/path-type-2.0.0.tgz#f012ccb8415b7096fc2daa1054c3d72389594c73" + dependencies: + pify "^2.0.0" + pause-stream@0.0.11: version "0.0.11" resolved "https://registry.yarnpkg.com/pause-stream/-/pause-stream-0.0.11.tgz#fe5a34b0cbce12b5aa6a2b403ee2e73b602f1445" @@ -5498,10 +6014,18 @@ performance-now@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-0.2.0.tgz#33ef30c5c77d4ea21c5a53869d91b56d8f2555e5" +performance-now@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b" + pify@^2.0.0, pify@^2.3.0: version "2.3.0" resolved "https://registry.yarnpkg.com/pify/-/pify-2.3.0.tgz#ed141a6ac043a849ea588498e7dca8b15330e90c" +pify@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/pify/-/pify-3.0.0.tgz#e5a4acd2c101fdf3d9a4d07f0dbc4db49dd28176" + pinkie-promise@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/pinkie-promise/-/pinkie-promise-1.0.0.tgz#d1da67f5482563bb7cf57f286ae2822ecfbf3670" @@ -6023,6 +6547,13 @@ preserve@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b" +pretty-format@^21.2.1: + version "21.2.1" + resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-21.2.1.tgz#ae5407f3cf21066cd011aa1ba5fce7b6a2eddb36" + dependencies: + ansi-regex "^3.0.0" + ansi-styles "^3.2.0" + private@^0.1.6, private@^0.1.7: version "0.1.7" resolved "https://registry.yarnpkg.com/private/-/private-0.1.7.tgz#68ce5e8a1ef0a23bb570cc28537b5332aba63ef1" @@ -6245,10 +6776,27 @@ quote@0.4.0: version "0.4.0" resolved "https://registry.yarnpkg.com/quote/-/quote-0.4.0.tgz#10839217f6c1362b89194044d29b233fd7f32f01" +raf@^3.3.2: + version "3.4.0" + resolved "https://registry.yarnpkg.com/raf/-/raf-3.4.0.tgz#a28876881b4bc2ca9117d4138163ddb80f781575" + dependencies: + performance-now "^2.1.0" + +railroad-diagrams@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/railroad-diagrams/-/railroad-diagrams-1.0.0.tgz#eb7e6267548ddedfb899c1b90e57374559cddb7e" + ramda@0.24.1, ramda@^0.24.1: version "0.24.1" resolved "https://registry.yarnpkg.com/ramda/-/ramda-0.24.1.tgz#c3b7755197f35b8dc3502228262c4c91ddb6b857" +randexp@^0.4.2: + version "0.4.6" + resolved "https://registry.yarnpkg.com/randexp/-/randexp-0.4.6.tgz#e986ad5e5e31dae13ddd6f7b3019aa7c87f60ca3" + dependencies: + discontinuous-range "1.0.0" + ret "~0.1.10" + randomatic@^1.1.3: version "1.1.6" resolved "https://registry.yarnpkg.com/randomatic/-/randomatic-1.1.6.tgz#110dcabff397e9dcff7c0789ccc0a49adf1ec5bb" @@ -6363,6 +6911,13 @@ react-tagsinput@^3.17.0: version "3.17.0" resolved "https://registry.yarnpkg.com/react-tagsinput/-/react-tagsinput-3.17.0.tgz#d699bc7ff3be3492d5a3d2a57f6976908774fba3" +react-test-renderer@15.5: + version "15.5.4" + resolved "https://registry.yarnpkg.com/react-test-renderer/-/react-test-renderer-15.5.4.tgz#d4ebb23f613d685ea8f5390109c2d20fbf7c83bc" + dependencies: + fbjs "^0.8.9" + object-assign "^4.1.0" + react-toastify@^1.5.0: version "1.5.0" resolved "https://registry.yarnpkg.com/react-toastify/-/react-toastify-1.5.0.tgz#e9857e0b5d640064e5ba6caf7a96bb1578273de7" @@ -6408,6 +6963,13 @@ read-pkg-up@^1.0.1: find-up "^1.0.0" read-pkg "^1.0.0" +read-pkg-up@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/read-pkg-up/-/read-pkg-up-2.0.0.tgz#6b72a8048984e0c41e79510fd5e9fa99b3b549be" + dependencies: + find-up "^2.0.0" + read-pkg "^2.0.0" + read-pkg@^1.0.0: version "1.1.0" resolved "https://registry.yarnpkg.com/read-pkg/-/read-pkg-1.1.0.tgz#f5ffaa5ecd29cb31c0474bca7d756b6bb29e3f28" @@ -6416,6 +6978,14 @@ read-pkg@^1.0.0: normalize-package-data "^2.3.2" path-type "^1.0.0" +read-pkg@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/read-pkg/-/read-pkg-2.0.0.tgz#8ef1c0623c6a6db0dc6713c4bfac46332b2368f8" + dependencies: + load-json-file "^2.0.0" + normalize-package-data "^2.3.2" + path-type "^2.0.0" + readable-stream@1.1: version "1.1.13" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-1.1.13.tgz#f6eef764f514c89e2b9e23146a75ba106756d23e" @@ -6698,6 +7268,10 @@ resolve-from@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-2.0.0.tgz#9480ab20e94ffa1d9e80a804c7ea147611966b57" +resolve@1.1.7: + version "1.1.7" + resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.1.7.tgz#203114d82ad2c5ed9e8e0411b3932875e889e97b" + resolve@^1.1.6, resolve@^1.1.7, resolve@^1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.4.0.tgz#a75be01c53da25d934a98ebd0e4c4a7312f92a86" @@ -6718,6 +7292,10 @@ restore-cursor@^2.0.0: onetime "^2.0.0" signal-exit "^3.0.2" +ret@~0.1.10: + version "0.1.15" + resolved "https://registry.yarnpkg.com/ret/-/ret-0.1.15.tgz#b8a4825d5bdb1fc3f6f53c2bc33f81388681c7bc" + rgb@~0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/rgb/-/rgb-0.1.0.tgz#be27b291e8feffeac1bd99729721bfa40fc037b5" @@ -6742,6 +7320,13 @@ ripemd160@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/ripemd160/-/ripemd160-1.0.1.tgz#93a4bbd4942bc574b69a8fa57c71de10ecca7d6e" +rst-selector-parser@^2.2.2: + version "2.2.2" + resolved "https://registry.yarnpkg.com/rst-selector-parser/-/rst-selector-parser-2.2.2.tgz#9927b619bd5af8dc23a76c64caef04edf90d2c65" + dependencies: + lodash.flattendeep "^4.4.0" + nearley "^2.7.10" + run-async@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/run-async/-/run-async-0.1.0.tgz#c8ad4a5e110661e402a7d21b530e009f25f8e389" @@ -6784,11 +7369,25 @@ samsam@1.x, samsam@^1.1.3: version "1.2.1" resolved "https://registry.yarnpkg.com/samsam/-/samsam-1.2.1.tgz#edd39093a3184370cb859243b2bdf255e7d8ea67" +sane@^2.0.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/sane/-/sane-2.2.0.tgz#d6d2e2fcab00e3d283c93b912b7c3a20846f1d56" + dependencies: + anymatch "^1.3.0" + exec-sh "^0.2.0" + fb-watchman "^2.0.0" + minimatch "^3.0.2" + minimist "^1.1.1" + walker "~1.0.5" + watch "~0.18.0" + optionalDependencies: + fsevents "^1.1.1" + sax@0.5.x: version "0.5.8" resolved "https://registry.yarnpkg.com/sax/-/sax-0.5.8.tgz#d472db228eb331c2506b0e8c15524adb939d12c1" -sax@^1.1.4, sax@~1.2.1: +sax@^1.1.4, sax@^1.2.1, sax@~1.2.1: version "1.2.2" resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.2.tgz#fd8631a23bc7826bef5d871bdb87378c95647828" @@ -6885,6 +7484,10 @@ shelljs@0.7.8, shelljs@^0.7.0: interpret "^1.0.0" rechoir "^0.6.2" +shellwords@^0.1.0: + version "0.1.1" + resolved "https://registry.yarnpkg.com/shellwords/-/shellwords-0.1.1.tgz#d6b9181c1a48d397324c84871efbcfc73fc0654b" + signal-exit@^3.0.0, signal-exit@^3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d" @@ -7119,6 +7722,13 @@ string-length@^1.0.0: dependencies: strip-ansi "^3.0.0" +string-length@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/string-length/-/string-length-2.0.0.tgz#d40dbb686a3ace960c1cffca562bf2c45f8363ed" + dependencies: + astral-regex "^1.0.0" + strip-ansi "^4.0.0" + string-width@^1.0.1, string-width@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/string-width/-/string-width-1.0.2.tgz#118bdf5b8cdc51a2a7e70d211e07e2b0b9b107d3" @@ -7166,12 +7776,20 @@ strip-ansi@^4.0.0: dependencies: ansi-regex "^3.0.0" +strip-bom@3.0.0, strip-bom@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-3.0.0.tgz#2334c18e9c759f7bdd56fdef7e9ae3d588e68ed3" + strip-bom@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-2.0.0.tgz#6219a85616520491f35788bdbf1447a99c7e6b0e" dependencies: is-utf8 "^0.2.0" +strip-eof@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/strip-eof/-/strip-eof-1.0.0.tgz#bb43ff5598a6eb05d89b59fcd129c983313606bf" + strip-json-comments@1.0.x: version "1.0.4" resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-1.0.4.tgz#1e15fbcac97d3ee99bf2d73b4c656b082bbafb91" @@ -7275,7 +7893,7 @@ symbol-observable@^1.0.2, symbol-observable@^1.0.4: version "1.0.4" resolved "https://registry.yarnpkg.com/symbol-observable/-/symbol-observable-1.0.4.tgz#29bf615d4aa7121bdd898b22d4b3f9bc4e2aa03d" -"symbol-tree@>= 3.1.0 < 4.0.0": +"symbol-tree@>= 3.1.0 < 4.0.0", symbol-tree@^3.2.1: version "3.2.2" resolved "https://registry.yarnpkg.com/symbol-tree/-/symbol-tree-3.2.2.tgz#ae27db38f660a7ae2e1c3b7d1bc290819b8519e6" @@ -7319,6 +7937,16 @@ tcomb@^2.5.1: version "2.7.0" resolved "https://registry.yarnpkg.com/tcomb/-/tcomb-2.7.0.tgz#10d62958041669a5d53567b9a4ee8cde22b1c2b0" +test-exclude@^4.1.1: + version "4.1.1" + resolved "https://registry.yarnpkg.com/test-exclude/-/test-exclude-4.1.1.tgz#4d84964b0966b0087ecc334a2ce002d3d9341e26" + dependencies: + arrify "^1.0.1" + micromatch "^2.3.11" + object-assign "^4.1.0" + read-pkg-up "^1.0.1" + require-main-filename "^1.0.1" + text-encoding@0.6.4: version "0.6.4" resolved "https://registry.yarnpkg.com/text-encoding/-/text-encoding-0.6.4.tgz#e399a982257a276dae428bb92845cb71bdc26d19" @@ -7327,6 +7955,10 @@ text-table@~0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4" +throat@^4.0.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/throat/-/throat-4.1.0.tgz#89037cbc92c56ab18926e6ba4cbb200e15672a6a" + through@2, through@^2.3.6, through@~2.3, through@~2.3.1: version "2.3.8" resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5" @@ -7373,6 +8005,10 @@ tmp@^0.0.31: dependencies: os-tmpdir "~1.0.1" +tmpl@1.0.x: + version "1.0.4" + resolved "https://registry.yarnpkg.com/tmpl/-/tmpl-1.0.4.tgz#23640dd7b42d00433911140820e5cf440e521dd1" + to-arraybuffer@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/to-arraybuffer/-/to-arraybuffer-1.0.1.tgz#7d229b1fcc637e466ca081180836a7aabff83f43" @@ -7434,13 +8070,13 @@ touch@1.0.0: dependencies: nopt "~1.0.10" -tough-cookie@^2.0.0, tough-cookie@^2.2.0, tough-cookie@~2.3.0: +tough-cookie@^2.0.0, tough-cookie@^2.2.0, tough-cookie@^2.3.2, tough-cookie@~2.3.0: version "2.3.2" resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.3.2.tgz#f081f76e4c85720e6c37a5faced737150d84072a" dependencies: punycode "^1.4.1" -tr46@~0.0.1: +tr46@~0.0.1, tr46@~0.0.3: version "0.0.3" resolved "https://registry.yarnpkg.com/tr46/-/tr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a" @@ -7536,6 +8172,10 @@ underscore@*, underscore@>=1.3.1: version "1.8.3" resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.8.3.tgz#4f3fb53b106e6097fcf9cb4109f2a5e9bdfa5022" +underscore@~1.4.4: + version "1.4.4" + resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.4.4.tgz#61a6a32010622afa07963bf325203cf12239d604" + underscore@~1.7.0: version "1.7.0" resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.7.0.tgz#6bbaf0877500d36be34ecaa584e0db9fef035209" @@ -7668,12 +8308,25 @@ void-elements@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/void-elements/-/void-elements-2.0.1.tgz#c066afb582bb1cb4128d60ea92392e94d5e9dbec" +walker@~1.0.5: + version "1.0.7" + resolved "https://registry.yarnpkg.com/walker/-/walker-1.0.7.tgz#2f7f9b8fd10d677262b18a884e28d19618e028fb" + dependencies: + makeerror "1.0.x" + warning@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/warning/-/warning-3.0.0.tgz#32e5377cb572de4ab04753bdf8821c01ed605b7c" dependencies: loose-envify "^1.0.0" +watch@~0.18.0: + version "0.18.0" + resolved "https://registry.yarnpkg.com/watch/-/watch-0.18.0.tgz#28095476c6df7c90c963138990c0a5423eb4b986" + dependencies: + exec-sh "^0.2.0" + minimist "^1.2.0" + watchpack@^1.3.1: version "1.3.1" resolved "https://registry.yarnpkg.com/watchpack/-/watchpack-1.3.1.tgz#7d8693907b28ce6013e7f3610aa2a1acf07dad87" @@ -7690,6 +8343,14 @@ webidl-conversions@^2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-2.0.1.tgz#3bf8258f7d318c7443c36f2e169402a1a6703506" +webidl-conversions@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871" + +webidl-conversions@^4.0.0: + version "4.0.2" + resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-4.0.2.tgz#a855980b1f0b6b359ba1d5d9fb39ae941faa63ad" + webpack-sources@^0.2.3: version "0.2.3" resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-0.2.3.tgz#17c62bfaf13c707f9d02c479e0dcdde8380697fb" @@ -7730,6 +8391,12 @@ webpack@^2.3.1: webpack-sources "^0.2.3" yargs "^6.0.0" +whatwg-encoding@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/whatwg-encoding/-/whatwg-encoding-1.0.1.tgz#3c6c451a198ee7aec55b1ec61d0920c67801a5f4" + dependencies: + iconv-lite "0.4.13" + whatwg-fetch@>=0.10.0, whatwg-fetch@^2.0.0: version "2.0.3" resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-2.0.3.tgz#9c84ec2dcf68187ff00bc64e1274b442176e1c84" @@ -7740,6 +8407,13 @@ whatwg-url-compat@~0.6.5: dependencies: tr46 "~0.0.1" +whatwg-url@^4.3.0: + version "4.8.0" + resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-4.8.0.tgz#d2981aa9148c1e00a41c5a6131166ab4683bbcc0" + dependencies: + tr46 "~0.0.3" + webidl-conversions "^3.0.0" + whet.extend@~0.9.9: version "0.9.9" resolved "https://registry.yarnpkg.com/whet.extend/-/whet.extend-0.9.9.tgz#f877d5bf648c97e5aa542fadc16d6a259b9c11a1" @@ -7748,7 +8422,11 @@ which-module@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/which-module/-/which-module-1.0.0.tgz#bba63ca861948994ff307736089e3b96026c2a4f" -which@^1.1.1, which@^1.2.9: +which-module@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/which-module/-/which-module-2.0.0.tgz#d9ef07dce77b9902b8a3a8fa4b31c3e3f7e6e87a" + +which@^1.1.1, which@^1.2.12, which@^1.2.9: version "1.2.14" resolved "https://registry.yarnpkg.com/which/-/which-1.2.14.tgz#9a87c4378f03e827cecaf1acdf56c736c01c14e5" dependencies: @@ -7791,6 +8469,13 @@ wordwrap@^1.0.0, wordwrap@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-1.0.0.tgz#27584810891456a4171c8d0226441ade90cbcaeb" +worker-farm@^1.3.1: + version "1.5.0" + resolved "https://registry.yarnpkg.com/worker-farm/-/worker-farm-1.5.0.tgz#adfdf0cd40581465ed0a1f648f9735722afd5c8d" + dependencies: + errno "^0.1.4" + xtend "^4.0.1" + wrap-ansi@^2.0.0: version "2.1.0" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-2.1.0.tgz#d8fc3d284dd05794fe84973caecdd1cf824fdd85" @@ -7810,6 +8495,14 @@ write-file-atomic@^1.1.2: imurmurhash "^0.1.4" slide "^1.1.5" +write-file-atomic@^2.1.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/write-file-atomic/-/write-file-atomic-2.3.0.tgz#1ff61575c2e2a4e8e510d6fa4e243cce183999ab" + dependencies: + graceful-fs "^4.1.11" + imurmurhash "^0.1.4" + signal-exit "^3.0.2" + write@^0.2.1: version "0.2.1" resolved "https://registry.yarnpkg.com/write/-/write-0.2.1.tgz#5fc03828e264cea3fe91455476f7a3c566cb0757" @@ -7833,7 +8526,7 @@ xdg-basedir@^2.0.0: dependencies: os-homedir "^1.0.0" -"xml-name-validator@>= 2.0.1 < 3.0.0": +"xml-name-validator@>= 2.0.1 < 3.0.0", xml-name-validator@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/xml-name-validator/-/xml-name-validator-2.0.1.tgz#4d8b8f1eccd3419aa362061becef515e1e559635" @@ -7886,6 +8579,12 @@ yargs-parser@^4.2.0: dependencies: camelcase "^3.0.0" +yargs-parser@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-7.0.0.tgz#8d0ac42f16ea55debd332caf4c4038b3e3f5dfd9" + dependencies: + camelcase "^4.1.0" + yargs@^4.0.0: version "4.8.1" resolved "https://registry.yarnpkg.com/yargs/-/yargs-4.8.1.tgz#c0c42924ca4aaa6b0e6da1739dfb216439f9ddc0" @@ -7942,6 +8641,24 @@ yargs@^6.0.0: y18n "^3.2.1" yargs-parser "^4.2.0" +yargs@^9.0.0: + version "9.0.1" + resolved "https://registry.yarnpkg.com/yargs/-/yargs-9.0.1.tgz#52acc23feecac34042078ee78c0c007f5085db4c" + dependencies: + camelcase "^4.1.0" + cliui "^3.2.0" + decamelize "^1.1.1" + get-caller-file "^1.0.1" + os-locale "^2.0.0" + read-pkg-up "^2.0.0" + require-directory "^2.1.1" + require-main-filename "^1.0.1" + set-blocking "^2.0.0" + string-width "^2.0.0" + which-module "^2.0.0" + y18n "^3.2.1" + yargs-parser "^7.0.0" + yargs@~3.10.0: version "3.10.0" resolved "https://registry.yarnpkg.com/yargs/-/yargs-3.10.0.tgz#f7ee7bd857dd7c1d2d38c0e74efbd681d1431fd1" From 511cdd619791acb2a91b51dda472887955115aa7 Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Tue, 3 Oct 2017 21:10:33 +0700 Subject: [PATCH 23/39] Remove .babelrc from talk-plugin-flag-details --- plugins/talk-plugin-flag-details/client/.babelrc | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 plugins/talk-plugin-flag-details/client/.babelrc diff --git a/plugins/talk-plugin-flag-details/client/.babelrc b/plugins/talk-plugin-flag-details/client/.babelrc deleted file mode 100644 index 60be246eb..000000000 --- a/plugins/talk-plugin-flag-details/client/.babelrc +++ /dev/null @@ -1,14 +0,0 @@ -{ - "presets": [ - "es2015" - ], - "plugins": [ - "add-module-exports", - "transform-class-properties", - "transform-decorators-legacy", - "transform-object-assign", - "transform-object-rest-spread", - "transform-async-to-generator", - "transform-react-jsx" - ] -} \ No newline at end of file From 14ce9b1e7704f795a413508de43658a96ae24a70 Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Tue, 3 Oct 2017 21:19:19 +0700 Subject: [PATCH 24/39] relax language --- test/client/setupJest.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/client/setupJest.js b/test/client/setupJest.js index 610a57a72..0f985fc68 100644 --- a/test/client/setupJest.js +++ b/test/client/setupJest.js @@ -5,8 +5,8 @@ Enzyme.configure({adapter: new Adapter()}); // Storage Mock -// TODO: If our code is written well, there shouldn't be a hardcoded dependency -// to the local storage, and this global mock wouldn't be needed. +// TODO: Some places in our code (e.g. translations) has a hardcoded dependency +// to the local storage. Fixing it and we can remove this global mock. function storageMock() { let storage = {}; From 2be8750d0e94e1bf0a5aef807d32ebbf630e2f44 Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Tue, 3 Oct 2017 21:30:55 +0700 Subject: [PATCH 25/39] Add yarn jest-watch --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index b95a16e06..03ed8a04f 100644 --- a/package.json +++ b/package.json @@ -14,8 +14,8 @@ "build-watch": "WEBPACK=TRUE NODE_ENV=development webpack --progress --config webpack.config.js --watch", "lint": "eslint --ext=.js --ext=.json bin/* .", "lint-fix": "yarn lint --fix", - "test": "TEST_MODE=unit NODE_ENV=test mocha -R ${MOCHA_REPORTER:-spec}", - "test-jest": "TEST_MODE=unit NODE_ENV=test jest", + "jest-watch": "TEST_MODE=unit NODE_ENV=test jest --watch", + "test": "TEST_MODE=unit NODE_ENV=test jest && TEST_MODE=unit NODE_ENV=test mocha -R ${MOCHA_REPORTER:-spec}", "test-cover": "TEST_MODE=unit NODE_ENV=test istanbul cover _mocha --report text --check-coverage -- -R spec", "heroku-postbuild": "./bin/cli plugins reconcile && yarn build", "generate-introspection": "WEBPACK=TRUE NODE_ENV=test ./scripts/generateIntrospectionResult.js" From bd83e9e118499b89033eda0423ab3289b46e81d5 Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Tue, 3 Oct 2017 21:31:10 +0700 Subject: [PATCH 26/39] Add first Snapshot testing --- .../__tests__/infoBox.spec.js | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/client/talk-plugin-infobox/__tests__/infoBox.spec.js b/client/talk-plugin-infobox/__tests__/infoBox.spec.js index 2110f5dc9..e26baa54f 100644 --- a/client/talk-plugin-infobox/__tests__/infoBox.spec.js +++ b/client/talk-plugin-infobox/__tests__/infoBox.spec.js @@ -1,29 +1,36 @@ import React from 'react'; import {shallow} from 'enzyme'; -import {expect} from 'chai'; import InfoBox from '../InfoBox'; +import renderer from 'react-test-renderer'; const render = (props) => shallow(); describe('InfoBox', () => { + it('renders correctly', () => { + const tree = renderer.create( + + ).toJSON(); + expect(tree).toMatchSnapshot(); + }); + it('should render hidden InfoBox', () => { const wrapper = render(); const className = wrapper.prop('className'); - expect(className).to.include('-info'); - expect(className).to.include('hidden'); + expect(className).toMatch('-info'); + expect(className).toMatch('hidden'); }); it('should render enabled InfoBox', () => { const wrapper = render({enable: true}); const className = wrapper.prop('className'); - expect(className).to.include('-info'); - expect(className).to.not.include('hidden'); + expect(className).toMatch('-info'); + expect(className).not.toMatch('hidden'); }); it('should render Markdown', () => { const wrapper = render({content: 'x'}); const Markddown = wrapper.find('Markdown'); - expect(Markddown).to.have.length(1); - expect(Markddown.prop('content')).to.equal('x'); + expect(Markddown).toHaveLength(1); + expect(Markddown.prop('content')).toEqual('x'); }); }); From 33920afc74e69f2a9b01b9eb4576ee7adbe1bf47 Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Tue, 3 Oct 2017 21:54:15 +0700 Subject: [PATCH 27/39] Port form chai to jest --- .../{markdown.spec.js => Markdown.spec.js} | 5 ++--- .../{infoBox.spec.js => InfoBox.spec.js} | 0 .../__tests__/__snapshots__/InfoBox.spec.js.snap | 16 ++++++++++++++++ 3 files changed, 18 insertions(+), 3 deletions(-) rename client/coral-framework/components/__tests__/{markdown.spec.js => Markdown.spec.js} (81%) rename client/talk-plugin-infobox/__tests__/{infoBox.spec.js => InfoBox.spec.js} (100%) create mode 100644 client/talk-plugin-infobox/__tests__/__snapshots__/InfoBox.spec.js.snap diff --git a/client/coral-framework/components/__tests__/markdown.spec.js b/client/coral-framework/components/__tests__/Markdown.spec.js similarity index 81% rename from client/coral-framework/components/__tests__/markdown.spec.js rename to client/coral-framework/components/__tests__/Markdown.spec.js index 1d98dabae..ab2c1afd1 100644 --- a/client/coral-framework/components/__tests__/markdown.spec.js +++ b/client/coral-framework/components/__tests__/Markdown.spec.js @@ -1,6 +1,5 @@ import React from 'react'; import {shallow} from 'enzyme'; -import {expect} from 'chai'; import Markdown from '../Markdown'; const render = (props) => shallow(); @@ -9,12 +8,12 @@ describe('Markdown', () => { it('should convert Markdown to html', () => { const wrapper = render({content: '*test*'}); const html = wrapper.html(); - expect(html).to.contain(''); + expect(html).toMatch(''); }); it('should set target="_parent" for links', () => { const wrapper = render({content: '[link](https://coralproject.net)'}); const html = wrapper.html(); - expect(html).to.contain('target="_parent"'); + expect(html).toMatch('target="_parent"'); }); }); diff --git a/client/talk-plugin-infobox/__tests__/infoBox.spec.js b/client/talk-plugin-infobox/__tests__/InfoBox.spec.js similarity index 100% rename from client/talk-plugin-infobox/__tests__/infoBox.spec.js rename to client/talk-plugin-infobox/__tests__/InfoBox.spec.js diff --git a/client/talk-plugin-infobox/__tests__/__snapshots__/InfoBox.spec.js.snap b/client/talk-plugin-infobox/__tests__/__snapshots__/InfoBox.spec.js.snap new file mode 100644 index 000000000..4c90404bd --- /dev/null +++ b/client/talk-plugin-infobox/__tests__/__snapshots__/InfoBox.spec.js.snap @@ -0,0 +1,16 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`InfoBox renders correctly 1`] = ` +
    +
    test

    +", + } + } + /> +
    +`; From faf75c5c2f989a6fc2f667629d814fd89441f3b1 Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Tue, 3 Oct 2017 22:08:55 +0700 Subject: [PATCH 28/39] Upgrade linters --- package.json | 2 +- yarn.lock | 32 ++++++++++++++------------------ 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/package.json b/package.json index 03ed8a04f..57abb4f1d 100644 --- a/package.json +++ b/package.json @@ -186,7 +186,7 @@ "yamljs": "^0.2.10" }, "devDependencies": { - "@coralproject/eslint-config-talk": "^0.0.3", + "@coralproject/eslint-config-talk": "^0.0.4", "babel-jest": "^21.2.0", "babel-plugin-dynamic-import-node": "^1.1.0", "babel-plugin-transform-es2015-modules-commonjs": "^6.26.0", diff --git a/yarn.lock b/yarn.lock index 464ac6a26..3f49f0d23 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,10 +2,11 @@ # yarn lockfile v1 -"@coralproject/eslint-config-talk@^0.0.3": - version "0.0.3" - resolved "https://registry.yarnpkg.com/@coralproject/eslint-config-talk/-/eslint-config-talk-0.0.3.tgz#94965e984519920510f8a18be381f57ea38ee999" +"@coralproject/eslint-config-talk@^0.0.4": + version "0.0.4" + resolved "https://registry.yarnpkg.com/@coralproject/eslint-config-talk/-/eslint-config-talk-0.0.4.tgz#35a28c10b12bc4da96417afbce17b4743d3bfcf6" dependencies: + eslint-plugin-jest "^21.2.0" eslint-plugin-json "^1.2.0" eslint-plugin-promise "^3.3.1" eslint-plugin-react "^7.3.0" @@ -758,16 +759,7 @@ babel-plugin-transform-es2015-modules-amd@^6.24.1: babel-runtime "^6.22.0" babel-template "^6.24.1" -babel-plugin-transform-es2015-modules-commonjs@^6.24.1: - version "6.24.1" - resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-modules-commonjs/-/babel-plugin-transform-es2015-modules-commonjs-6.24.1.tgz#d3e310b40ef664a36622200097c6d440298f2bfe" - dependencies: - babel-plugin-transform-strict-mode "^6.24.1" - babel-runtime "^6.22.0" - babel-template "^6.24.1" - babel-types "^6.24.1" - -babel-plugin-transform-es2015-modules-commonjs@^6.26.0: +babel-plugin-transform-es2015-modules-commonjs@^6.24.1, babel-plugin-transform-es2015-modules-commonjs@^6.26.0: version "6.26.0" resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-modules-commonjs/-/babel-plugin-transform-es2015-modules-commonjs-6.26.0.tgz#0d8394029b7dc6abe1a97ef181e00758dd2e5d8a" dependencies: @@ -2502,6 +2494,10 @@ escodegen@^1.6.1: optionalDependencies: source-map "~0.2.0" +eslint-plugin-jest@^21.2.0: + version "21.2.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-jest/-/eslint-plugin-jest-21.2.0.tgz#292044df9cf0866ad9c530e78e6528fae287b926" + eslint-plugin-json@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/eslint-plugin-json/-/eslint-plugin-json-1.2.0.tgz#9ba73bb0be99d50093e889f5b968463d2a30efae" @@ -4139,14 +4135,14 @@ istanbul-api@^1.1.0-alpha, istanbul-api@^1.1.1: mkdirp "^0.5.1" once "^1.4.0" -istanbul-lib-coverage@^1.0.1, istanbul-lib-coverage@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/istanbul-lib-coverage/-/istanbul-lib-coverage-1.1.1.tgz#73bfb998885299415c93d38a3e9adf784a77a9da" - -istanbul-lib-coverage@^1.0.2: +istanbul-lib-coverage@^1.0.1, istanbul-lib-coverage@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/istanbul-lib-coverage/-/istanbul-lib-coverage-1.0.2.tgz#87a0c015b6910651cb3b184814dfb339337e25e1" +istanbul-lib-coverage@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/istanbul-lib-coverage/-/istanbul-lib-coverage-1.1.1.tgz#73bfb998885299415c93d38a3e9adf784a77a9da" + istanbul-lib-hook@^1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/istanbul-lib-hook/-/istanbul-lib-hook-1.0.5.tgz#6ca3d16d60c5f4082da39f7c5cd38ea8a772b88e" From 79d312df50e7c735512a936d0c386f1e5bfb8b37 Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Tue, 3 Oct 2017 22:25:37 +0700 Subject: [PATCH 29/39] Fix styling of edited marker --- client/coral-embed-stream/src/components/Comment.css | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/client/coral-embed-stream/src/components/Comment.css b/client/coral-embed-stream/src/components/Comment.css index e32b7333b..3ca7b842f 100644 --- a/client/coral-embed-stream/src/components/Comment.css +++ b/client/coral-embed-stream/src/components/Comment.css @@ -45,6 +45,12 @@ border-left: 3px solid rgb(35,118,216); } +.bylineSecondary { + display: flex; + color: #696969; + font-size: 12px; +} + .pendingComment { filter: blur(2px); pointer-events: none; From d2b6e0b2351d2338abe2526c6b83c9ea9aa73646 Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Tue, 3 Oct 2017 23:29:46 +0700 Subject: [PATCH 30/39] Remove .babelrc from plugin --- plugins/talk-plugin-subscriber/client/.babelrc | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 plugins/talk-plugin-subscriber/client/.babelrc diff --git a/plugins/talk-plugin-subscriber/client/.babelrc b/plugins/talk-plugin-subscriber/client/.babelrc deleted file mode 100644 index 60be246eb..000000000 --- a/plugins/talk-plugin-subscriber/client/.babelrc +++ /dev/null @@ -1,14 +0,0 @@ -{ - "presets": [ - "es2015" - ], - "plugins": [ - "add-module-exports", - "transform-class-properties", - "transform-decorators-legacy", - "transform-object-assign", - "transform-object-rest-spread", - "transform-async-to-generator", - "transform-react-jsx" - ] -} \ No newline at end of file From b11783d54f0c0f6b1e3168d61a03c67b78f3a0df Mon Sep 17 00:00:00 2001 From: Wyatt Johnson Date: Tue, 3 Oct 2017 14:15:42 -0600 Subject: [PATCH 31/39] Fixes Featured Tag Permissions - When a comment is created, there is a possibility of injecting a tag into the payload, this removes that permission error --- plugins/talk-plugin-featured-comments/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/talk-plugin-featured-comments/index.js b/plugins/talk-plugin-featured-comments/index.js index 46e3f97fa..6cfc0b8d5 100644 --- a/plugins/talk-plugin-featured-comments/index.js +++ b/plugins/talk-plugin-featured-comments/index.js @@ -87,7 +87,7 @@ module.exports = { name: 'FEATURED', permissions: { public: true, - self: true, + self: false, roles: [] }, models: ['COMMENTS'], From c6526a71ba8cdaeff38e21c3934cb4189a20018e Mon Sep 17 00:00:00 2001 From: Wyatt Johnson Date: Tue, 3 Oct 2017 14:21:55 -0600 Subject: [PATCH 32/39] Revert "Remove .babelrc from plugin" --- plugins/talk-plugin-subscriber/client/.babelrc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 plugins/talk-plugin-subscriber/client/.babelrc diff --git a/plugins/talk-plugin-subscriber/client/.babelrc b/plugins/talk-plugin-subscriber/client/.babelrc new file mode 100644 index 000000000..60be246eb --- /dev/null +++ b/plugins/talk-plugin-subscriber/client/.babelrc @@ -0,0 +1,14 @@ +{ + "presets": [ + "es2015" + ], + "plugins": [ + "add-module-exports", + "transform-class-properties", + "transform-decorators-legacy", + "transform-object-assign", + "transform-object-rest-spread", + "transform-async-to-generator", + "transform-react-jsx" + ] +} \ No newline at end of file From b5ab829f9b69cec367887e0a76ed0d6e8425f53d Mon Sep 17 00:00:00 2001 From: Wyatt Johnson Date: Tue, 3 Oct 2017 14:36:36 -0600 Subject: [PATCH 33/39] Revert "Es6 modules + tree shaking" --- bin/templates/plugin/client/.babelrc | 14 ++ .babelrc => client/.babelrc | 5 +- .../components/QuestionBoxBuilder.js | 14 +- client/coral-embed/src/index.js | 189 +++++++++--------- .../coral-framework/loaders/plugins-loader.js | 2 +- client/coral-framework/services/client.js | 3 +- client/talk-plugin-commentbox/index.js | 6 +- .../talk-plugin-flags/helpers/flagReasons.js | 27 +-- package.json | 1 + plugin-api/.babelrc | 14 ++ plugins/talk-plugin-auth/client/.babelrc | 14 ++ .../talk-plugin-author-menu/client/.babelrc | 14 ++ .../client/.babelrc | 14 ++ .../client/.babelrc | 14 ++ .../client/components/.babelrc | 14 ++ .../client/components/ModTag.js | 6 +- .../client/components/TabPane.js | 4 +- .../client/containers/ModTag.js | 17 +- .../client/containers/TabPane.js | 4 +- .../talk-plugin-flag-details/client/.babelrc | 14 ++ .../talk-plugin-ignore-user/client/.babelrc | 14 ++ plugins/talk-plugin-like/client/.babelrc | 14 ++ plugins/talk-plugin-love/client/.babelrc | 14 ++ .../talk-plugin-member-since/client/.babelrc | 14 ++ .../client/.babelrc | 14 ++ plugins/talk-plugin-offtopic/client/.babelrc | 14 ++ plugins/talk-plugin-permalink/client/.babelrc | 14 ++ .../talk-plugin-remember-sort/client/.babelrc | 14 ++ plugins/talk-plugin-respect/client/.babelrc | 14 ++ .../client/.babelrc | 14 ++ .../client/.babelrc | 14 ++ .../client/.babelrc | 14 ++ .../client/.babelrc | 14 ++ .../talk-plugin-sort-newest/client/.babelrc | 14 ++ .../talk-plugin-sort-oldest/client/.babelrc | 14 ++ .../client/.babelrc | 14 ++ .../client/.babelrc | 14 ++ yarn.lock | 10 +- 38 files changed, 498 insertions(+), 140 deletions(-) create mode 100644 bin/templates/plugin/client/.babelrc rename .babelrc => client/.babelrc (87%) create mode 100644 plugin-api/.babelrc create mode 100644 plugins/talk-plugin-auth/client/.babelrc create mode 100644 plugins/talk-plugin-author-menu/client/.babelrc create mode 100644 plugins/talk-plugin-comment-content/client/.babelrc create mode 100644 plugins/talk-plugin-featured-comments/client/.babelrc create mode 100644 plugins/talk-plugin-featured-comments/client/components/.babelrc create mode 100644 plugins/talk-plugin-flag-details/client/.babelrc create mode 100644 plugins/talk-plugin-ignore-user/client/.babelrc create mode 100644 plugins/talk-plugin-like/client/.babelrc create mode 100644 plugins/talk-plugin-love/client/.babelrc create mode 100644 plugins/talk-plugin-member-since/client/.babelrc create mode 100644 plugins/talk-plugin-moderation-actions/client/.babelrc create mode 100644 plugins/talk-plugin-offtopic/client/.babelrc create mode 100644 plugins/talk-plugin-permalink/client/.babelrc create mode 100644 plugins/talk-plugin-remember-sort/client/.babelrc create mode 100644 plugins/talk-plugin-respect/client/.babelrc create mode 100644 plugins/talk-plugin-sort-most-liked/client/.babelrc create mode 100644 plugins/talk-plugin-sort-most-loved/client/.babelrc create mode 100644 plugins/talk-plugin-sort-most-replied/client/.babelrc create mode 100644 plugins/talk-plugin-sort-most-respected/client/.babelrc create mode 100644 plugins/talk-plugin-sort-newest/client/.babelrc create mode 100644 plugins/talk-plugin-sort-oldest/client/.babelrc create mode 100644 plugins/talk-plugin-toxic-comments/client/.babelrc create mode 100644 plugins/talk-plugin-viewing-options/client/.babelrc diff --git a/bin/templates/plugin/client/.babelrc b/bin/templates/plugin/client/.babelrc new file mode 100644 index 000000000..60be246eb --- /dev/null +++ b/bin/templates/plugin/client/.babelrc @@ -0,0 +1,14 @@ +{ + "presets": [ + "es2015" + ], + "plugins": [ + "add-module-exports", + "transform-class-properties", + "transform-decorators-legacy", + "transform-object-assign", + "transform-object-rest-spread", + "transform-async-to-generator", + "transform-react-jsx" + ] +} \ No newline at end of file diff --git a/.babelrc b/client/.babelrc similarity index 87% rename from .babelrc rename to client/.babelrc index 3dcf42eb7..2af1a3dad 100644 --- a/.babelrc +++ b/client/.babelrc @@ -1,8 +1,9 @@ { "presets": [ - ["es2015", {modules: false}] + "es2015" ], "plugins": [ + "add-module-exports", "transform-class-properties", "transform-decorators-legacy", "transform-object-assign", @@ -11,4 +12,4 @@ "transform-react-jsx", "syntax-dynamic-import" ] -} +} \ No newline at end of file diff --git a/client/coral-configure/components/QuestionBoxBuilder.js b/client/coral-configure/components/QuestionBoxBuilder.js index 28dfc30b3..285df40ed 100644 --- a/client/coral-configure/components/QuestionBoxBuilder.js +++ b/client/coral-configure/components/QuestionBoxBuilder.js @@ -8,7 +8,7 @@ import styles from './QuestionBoxBuilder.css'; class QuestionBoxBuilder extends React.Component { constructor() { super(); - + this.state = { loading: true }; @@ -17,9 +17,9 @@ class QuestionBoxBuilder extends React.Component { componentWillMount() { this.loadEditor(); } - + async loadEditor() { - const {default: MarkdownEditor} = await import('coral-framework/components/MarkdownEditor'); + const MarkdownEditor = await import('coral-framework/components/MarkdownEditor'); return this.setState({ loading : false, @@ -79,17 +79,17 @@ class QuestionBoxBuilder extends React.Component { - handleChange({}, {questionBoxContent: value})} /> - +
    ); } diff --git a/client/coral-embed/src/index.js b/client/coral-embed/src/index.js index f60a88439..34bee1797 100644 --- a/client/coral-embed/src/index.js +++ b/client/coral-embed/src/index.js @@ -2,98 +2,101 @@ import URLSearchParams from 'url-search-params'; import Stream from './Stream'; import StreamInterface from './StreamInterface'; -export class Talk { +// This function should return value of window.Coral +const Coral = {}; +const Talk = (Coral.Talk = {}); - /** - * Render a Talk stream - * @param {HTMLElement} el - Element to render the stream in - * @param {Object} opts - Configuration options for talk - * @param {String} opts.talk - Talk base URL - * @param {String} [opts.title] - Title of Stream (rendered in iframe) - * @param {String} [opts.asset_url] - Asset URL - * @param {String} [opts.asset_id] - Asset ID - * @param {String} [opts.auth_token] - (optional) A jwt representing the session - * @return {Object} - * - * Example: - * ``` - * const embed = Talk.render(document.getElementById('talkStreamEmbed'), opts); - * - * // trigger a login with optional token. - * embed.login(token); - * - * // trigger a logout. - * embed.logout(); - * - * // listen to events (in this case all events). - * embed.on('**', function(value) { - * console.log(this.event, value); - * }); - * ``` - */ - static render(el, opts) { - if (!el) { - throw new Error('Please provide Coral.Talk.render() the HTMLElement you want to render Talk in.'); - } - if (typeof el !== 'object') { - throw new Error(`Coral.Talk.render() expected HTMLElement but got ${el} (${typeof el})`); - } - - opts = opts || {}; - - // TODO: infer this URL without explicit user input (if possible, may have to be added at build/render time of this script) - if (!opts.talk) { - throw new Error( - 'Coral.Talk.render() expects opts.talk as the Talk Base URL' - ); - } - - // Ensure el has an id, as pym can't directly accept the HTMLElement. - if (!el.id) { - el.id = `_${Math.random()}`; - } - - // Compose the query to send down to the Talk API so it knows what to load. - const query = {}; - - // Parse the url parameters to extract some of the information. - const urlParams = new URLSearchParams(window.location.search); - if (urlParams.get('commentId')) { - query.comment_id = urlParams.get('commentId'); - } - - // Extract the asset id from the options. - if (opts.asset_id) { - query.asset_id = opts.asset_id; - } - - // Extract the asset url. - if (opts.asset_url) { - query.asset_url = opts.asset_url; - } else if (!opts.asset_id) { - - // The asset url was not provided and the asset id was also not provided, - // we need to infer the asset url from details on the page. - - try { - query.asset_url = document.querySelector('link[rel="canonical"]').href; - } catch (e) { - console.warn( - 'This page does not include a canonical link tag. Talk has inferred this asset_url from the window object. Query params have been stripped, which may cause a single thread to be present across multiple pages.' - ); - - if (!window.location.origin) { - window.location.origin = `${window.location.protocol}//${window.location.hostname}${window.location.port ? `:${window.location.port}` : ''}`; - } - - query.asset_url = window.location.origin + window.location.pathname; - } - } - - // Create the new Stream. - const stream = new Stream(el, opts.talk, query, opts); - - // Return the public interface for the stream. - return new StreamInterface(stream); +/** + * Render a Talk stream + * @param {HTMLElement} el - Element to render the stream in + * @param {Object} opts - Configuration options for talk + * @param {String} opts.talk - Talk base URL + * @param {String} [opts.title] - Title of Stream (rendered in iframe) + * @param {String} [opts.asset_url] - Asset URL + * @param {String} [opts.asset_id] - Asset ID + * @param {String} [opts.auth_token] - (optional) A jwt representing the session + * @return {Object} + * + * Example: + * ``` + * const embed = Talk.render(document.getElementById('talkStreamEmbed'), opts); + * + * // trigger a login with optional token. + * embed.login(token); + * + * // trigger a logout. + * embed.logout(); + * + * // listen to events (in this case all events). + * embed.on('**', function(value) { + * console.log(this.event, value); + * }); + * ``` + */ +Talk.render = (el, opts) => { + if (!el) { + throw new Error('Please provide Coral.Talk.render() the HTMLElement you want to render Talk in.'); } -} + if (typeof el !== 'object') { + throw new Error(`Coral.Talk.render() expected HTMLElement but got ${el} (${typeof el})`); + } + + opts = opts || {}; + + // TODO: infer this URL without explicit user input (if possible, may have to be added at build/render time of this script) + if (!opts.talk) { + throw new Error( + 'Coral.Talk.render() expects opts.talk as the Talk Base URL' + ); + } + + // Ensure el has an id, as pym can't directly accept the HTMLElement. + if (!el.id) { + el.id = `_${Math.random()}`; + } + + // Compose the query to send down to the Talk API so it knows what to load. + const query = {}; + + // Parse the url parameters to extract some of the information. + const urlParams = new URLSearchParams(window.location.search); + if (urlParams.get('commentId')) { + query.comment_id = urlParams.get('commentId'); + } + + // Extract the asset id from the options. + if (opts.asset_id) { + query.asset_id = opts.asset_id; + } + + // Extract the asset url. + if (opts.asset_url) { + query.asset_url = opts.asset_url; + } else if (!opts.asset_id) { + + // The asset url was not provided and the asset id was also not provided, + // we need to infer the asset url from details on the page. + + try { + query.asset_url = document.querySelector('link[rel="canonical"]').href; + } catch (e) { + console.warn( + 'This page does not include a canonical link tag. Talk has inferred this asset_url from the window object. Query params have been stripped, which may cause a single thread to be present across multiple pages.' + ); + + if (!window.location.origin) { + window.location.origin = `${window.location.protocol}//${window.location.hostname}${window.location.port ? `:${window.location.port}` : ''}`; + } + + query.asset_url = window.location.origin + window.location.pathname; + } + } + + // Create the new Stream. + const stream = new Stream(el, opts.talk, query, opts); + + // Return the public interface for the stream. + return new StreamInterface(stream); +}; + +export default Coral; diff --git a/client/coral-framework/loaders/plugins-loader.js b/client/coral-framework/loaders/plugins-loader.js index 7683dae8d..a9fed95ab 100644 --- a/client/coral-framework/loaders/plugins-loader.js +++ b/client/coral-framework/loaders/plugins-loader.js @@ -21,7 +21,7 @@ module.exports = function(source) { this.cacheable(); const config = this.exec(source, this.resourcePath); const plugins = getPluginList(config).map((plugin) => `{ - module: require('${plugin}/client').default, + module: require('${plugin}/client'), name: '${plugin}' }`); diff --git a/client/coral-framework/services/client.js b/client/coral-framework/services/client.js index dc5a67d03..52088ad79 100644 --- a/client/coral-framework/services/client.js +++ b/client/coral-framework/services/client.js @@ -1,4 +1,4 @@ -import ApolloClient, {IntrospectionFragmentMatcher, createNetworkInterface} from 'apollo-client'; +import ApolloClient, {addTypename, IntrospectionFragmentMatcher, createNetworkInterface} from 'apollo-client'; import {SubscriptionClient, addGraphQLSubscriptions} from 'subscriptions-transport-ws'; import MessageTypes from 'subscriptions-transport-ws/dist/message-types'; @@ -64,6 +64,7 @@ export function createClient(options = {}) { connectToDevTools: true, addTypename: true, fragmentMatcher: new IntrospectionFragmentMatcher({introspectionQueryResultData: introspectionData}), + queryTransformer: addTypename, dataIdFromObject: (result) => { if (result.id && result.__typename) { // eslint-disable-line no-underscore-dangle return `${result.__typename}_${result.id}`; // eslint-disable-line no-underscore-dangle diff --git a/client/talk-plugin-commentbox/index.js b/client/talk-plugin-commentbox/index.js index 0d94a840e..9f166caeb 100644 --- a/client/talk-plugin-commentbox/index.js +++ b/client/talk-plugin-commentbox/index.js @@ -1 +1,5 @@ -export {default as reducer} from './reducer'; +import reducer from './reducer'; + +export default { + reducer +}; diff --git a/client/talk-plugin-flags/helpers/flagReasons.js b/client/talk-plugin-flags/helpers/flagReasons.js index 52bddbb38..514c57398 100644 --- a/client/talk-plugin-flags/helpers/flagReasons.js +++ b/client/talk-plugin-flags/helpers/flagReasons.js @@ -1,14 +1,15 @@ -export const username = { - offensive: 'USERNAME_OFFENSIVE', - nolike: 'USERNAME_NOLIKE', - impersonating: 'USERNAME_IMPERSONATING', - spam: 'USERNAME_SPAM', - other: 'USERNAME_OTHER' -}; - -export const comment = { - offensive: 'COMMENT_OFFENSIVE', - spam: 'COMMENT_SPAM', - noagree: 'COMMENT_NOAGREE', - other: 'COMMENT_OTHER' +export default { + username: { + offensive: 'USERNAME_OFFENSIVE', + nolike: 'USERNAME_NOLIKE', + impersonating: 'USERNAME_IMPERSONATING', + spam: 'USERNAME_SPAM', + other: 'USERNAME_OTHER' + }, + comment: { + offensive: 'COMMENT_OFFENSIVE', + spam: 'COMMENT_SPAM', + noagree: 'COMMENT_NOAGREE', + other: 'COMMENT_OTHER' + } }; diff --git a/package.json b/package.json index f8c8c9731..52866238b 100644 --- a/package.json +++ b/package.json @@ -63,6 +63,7 @@ "babel-core": "^6.26.0", "babel-eslint": "^7.2.1", "babel-loader": "^7.1.2", + "babel-plugin-add-module-exports": "^0.2.1", "babel-plugin-syntax-dynamic-import": "^6.18.0", "babel-plugin-transform-async-to-generator": "^6.16.0", "babel-plugin-transform-class-properties": "^6.23.0", diff --git a/plugin-api/.babelrc b/plugin-api/.babelrc new file mode 100644 index 000000000..63b1c53de --- /dev/null +++ b/plugin-api/.babelrc @@ -0,0 +1,14 @@ +{ + "presets": [ + "es2015" + ], + "plugins": [ + "add-module-exports", + "transform-class-properties", + "transform-decorators-legacy", + "transform-object-assign", + "transform-object-rest-spread", + "transform-async-to-generator", + "transform-react-jsx" + ] +} diff --git a/plugins/talk-plugin-auth/client/.babelrc b/plugins/talk-plugin-auth/client/.babelrc new file mode 100644 index 000000000..60be246eb --- /dev/null +++ b/plugins/talk-plugin-auth/client/.babelrc @@ -0,0 +1,14 @@ +{ + "presets": [ + "es2015" + ], + "plugins": [ + "add-module-exports", + "transform-class-properties", + "transform-decorators-legacy", + "transform-object-assign", + "transform-object-rest-spread", + "transform-async-to-generator", + "transform-react-jsx" + ] +} \ No newline at end of file diff --git a/plugins/talk-plugin-author-menu/client/.babelrc b/plugins/talk-plugin-author-menu/client/.babelrc new file mode 100644 index 000000000..60be246eb --- /dev/null +++ b/plugins/talk-plugin-author-menu/client/.babelrc @@ -0,0 +1,14 @@ +{ + "presets": [ + "es2015" + ], + "plugins": [ + "add-module-exports", + "transform-class-properties", + "transform-decorators-legacy", + "transform-object-assign", + "transform-object-rest-spread", + "transform-async-to-generator", + "transform-react-jsx" + ] +} \ No newline at end of file diff --git a/plugins/talk-plugin-comment-content/client/.babelrc b/plugins/talk-plugin-comment-content/client/.babelrc new file mode 100644 index 000000000..60be246eb --- /dev/null +++ b/plugins/talk-plugin-comment-content/client/.babelrc @@ -0,0 +1,14 @@ +{ + "presets": [ + "es2015" + ], + "plugins": [ + "add-module-exports", + "transform-class-properties", + "transform-decorators-legacy", + "transform-object-assign", + "transform-object-rest-spread", + "transform-async-to-generator", + "transform-react-jsx" + ] +} \ No newline at end of file diff --git a/plugins/talk-plugin-featured-comments/client/.babelrc b/plugins/talk-plugin-featured-comments/client/.babelrc new file mode 100644 index 000000000..60be246eb --- /dev/null +++ b/plugins/talk-plugin-featured-comments/client/.babelrc @@ -0,0 +1,14 @@ +{ + "presets": [ + "es2015" + ], + "plugins": [ + "add-module-exports", + "transform-class-properties", + "transform-decorators-legacy", + "transform-object-assign", + "transform-object-rest-spread", + "transform-async-to-generator", + "transform-react-jsx" + ] +} \ No newline at end of file diff --git a/plugins/talk-plugin-featured-comments/client/components/.babelrc b/plugins/talk-plugin-featured-comments/client/components/.babelrc new file mode 100644 index 000000000..60be246eb --- /dev/null +++ b/plugins/talk-plugin-featured-comments/client/components/.babelrc @@ -0,0 +1,14 @@ +{ + "presets": [ + "es2015" + ], + "plugins": [ + "add-module-exports", + "transform-class-properties", + "transform-decorators-legacy", + "transform-object-assign", + "transform-object-rest-spread", + "transform-async-to-generator", + "transform-react-jsx" + ] +} \ No newline at end of file diff --git a/plugins/talk-plugin-featured-comments/client/components/ModTag.js b/plugins/talk-plugin-featured-comments/client/components/ModTag.js index 7dfd36f2d..52c051796 100644 --- a/plugins/talk-plugin-featured-comments/client/components/ModTag.js +++ b/plugins/talk-plugin-featured-comments/client/components/ModTag.js @@ -3,7 +3,7 @@ import cn from 'classnames'; import styles from './ModTag.css'; import {t} from 'plugin-api/beta/client/services'; import {Icon} from 'plugin-api/beta/client/components/ui'; -import {getErrorMessages} from 'plugin-api/beta/client/utils'; +import * as notification from 'coral-admin/src/services/notification'; export default class ModTag extends React.Component { constructor() { @@ -32,10 +32,10 @@ export default class ModTag extends React.Component { postTag = async () => { try { await this.props.postTag(); - this.props.notify('success', t('talk-plugin-featured-comments.notify_self_featured', this.props.comment.user.username)); + notification.success(t('talk-plugin-featured-comments.notify_self_featured', this.props.comment.user.username)); } catch(err) { - this.props.notify('error', getErrorMessages(err)); + notification.showMutationErrors(err); } } diff --git a/plugins/talk-plugin-featured-comments/client/components/TabPane.js b/plugins/talk-plugin-featured-comments/client/components/TabPane.js index 941f15402..2f5d0c7c2 100644 --- a/plugins/talk-plugin-featured-comments/client/components/TabPane.js +++ b/plugins/talk-plugin-featured-comments/client/components/TabPane.js @@ -1,7 +1,7 @@ import React from 'react'; import Comment from '../containers/Comment'; import LoadMore from './LoadMore'; -import {getErrorMessages} from 'plugin-api/beta/client/utils'; +import {forEachError} from 'plugin-api/beta/client/utils'; class TabPane extends React.Component { state = { @@ -16,7 +16,7 @@ class TabPane extends React.Component { }) .catch((error) => { this.setState({loadingState: 'error'}); - this.props.notify('error', getErrorMessages(error)); + forEachError(error, ({msg}) => {this.props.addNotification('error', msg);}); }); } diff --git a/plugins/talk-plugin-featured-comments/client/containers/ModTag.js b/plugins/talk-plugin-featured-comments/client/containers/ModTag.js index 88aee73f6..7081c7ec6 100644 --- a/plugins/talk-plugin-featured-comments/client/containers/ModTag.js +++ b/plugins/talk-plugin-featured-comments/client/containers/ModTag.js @@ -1,13 +1,6 @@ import ModTag from '../components/ModTag'; -import {withTags, connect} from 'plugin-api/beta/client/hocs'; -import {gql, compose} from 'react-apollo'; -import {bindActionCreators} from 'redux'; -import {notify} from 'plugin-api/beta/client/actions/notification'; - -const mapDispatchToProps = (dispatch) => - bindActionCreators({ - notify, - }, dispatch); +import {withTags} from 'plugin-api/beta/client/hocs'; +import {gql} from 'react-apollo'; const fragments = { comment: gql` @@ -18,10 +11,6 @@ const fragments = { } ` }; -const enhance = compose( - withTags('featured', {fragments}), - connect(null, mapDispatchToProps), -); -export default enhance(ModTag); +export default withTags('featured', {fragments})(ModTag); diff --git a/plugins/talk-plugin-featured-comments/client/containers/TabPane.js b/plugins/talk-plugin-featured-comments/client/containers/TabPane.js index 5f684b228..93ef402a9 100644 --- a/plugins/talk-plugin-featured-comments/client/containers/TabPane.js +++ b/plugins/talk-plugin-featured-comments/client/containers/TabPane.js @@ -4,7 +4,7 @@ import {compose, gql} from 'react-apollo'; import TabPane from '../components/TabPane'; import {withFragments, connect} from 'plugin-api/beta/client/hocs'; import Comment from '../containers/Comment'; -import {notify} from 'plugin-api/beta/client/actions/notification'; +import {addNotification} from 'plugin-api/beta/client/actions/notification'; import {viewComment} from 'coral-embed-stream/src/actions/stream'; import {appendNewNodes, getDefinitionName} from 'plugin-api/beta/client/utils'; import update from 'immutability-helper'; @@ -81,7 +81,7 @@ const LOAD_MORE_QUERY = gql` const mapDispatchToProps = (dispatch) => bindActionCreators({ viewComment, - notify, + addNotification, }, dispatch); const enhance = compose( diff --git a/plugins/talk-plugin-flag-details/client/.babelrc b/plugins/talk-plugin-flag-details/client/.babelrc new file mode 100644 index 000000000..60be246eb --- /dev/null +++ b/plugins/talk-plugin-flag-details/client/.babelrc @@ -0,0 +1,14 @@ +{ + "presets": [ + "es2015" + ], + "plugins": [ + "add-module-exports", + "transform-class-properties", + "transform-decorators-legacy", + "transform-object-assign", + "transform-object-rest-spread", + "transform-async-to-generator", + "transform-react-jsx" + ] +} \ No newline at end of file diff --git a/plugins/talk-plugin-ignore-user/client/.babelrc b/plugins/talk-plugin-ignore-user/client/.babelrc new file mode 100644 index 000000000..60be246eb --- /dev/null +++ b/plugins/talk-plugin-ignore-user/client/.babelrc @@ -0,0 +1,14 @@ +{ + "presets": [ + "es2015" + ], + "plugins": [ + "add-module-exports", + "transform-class-properties", + "transform-decorators-legacy", + "transform-object-assign", + "transform-object-rest-spread", + "transform-async-to-generator", + "transform-react-jsx" + ] +} \ No newline at end of file diff --git a/plugins/talk-plugin-like/client/.babelrc b/plugins/talk-plugin-like/client/.babelrc new file mode 100644 index 000000000..60be246eb --- /dev/null +++ b/plugins/talk-plugin-like/client/.babelrc @@ -0,0 +1,14 @@ +{ + "presets": [ + "es2015" + ], + "plugins": [ + "add-module-exports", + "transform-class-properties", + "transform-decorators-legacy", + "transform-object-assign", + "transform-object-rest-spread", + "transform-async-to-generator", + "transform-react-jsx" + ] +} \ No newline at end of file diff --git a/plugins/talk-plugin-love/client/.babelrc b/plugins/talk-plugin-love/client/.babelrc new file mode 100644 index 000000000..60be246eb --- /dev/null +++ b/plugins/talk-plugin-love/client/.babelrc @@ -0,0 +1,14 @@ +{ + "presets": [ + "es2015" + ], + "plugins": [ + "add-module-exports", + "transform-class-properties", + "transform-decorators-legacy", + "transform-object-assign", + "transform-object-rest-spread", + "transform-async-to-generator", + "transform-react-jsx" + ] +} \ No newline at end of file diff --git a/plugins/talk-plugin-member-since/client/.babelrc b/plugins/talk-plugin-member-since/client/.babelrc new file mode 100644 index 000000000..60be246eb --- /dev/null +++ b/plugins/talk-plugin-member-since/client/.babelrc @@ -0,0 +1,14 @@ +{ + "presets": [ + "es2015" + ], + "plugins": [ + "add-module-exports", + "transform-class-properties", + "transform-decorators-legacy", + "transform-object-assign", + "transform-object-rest-spread", + "transform-async-to-generator", + "transform-react-jsx" + ] +} \ No newline at end of file diff --git a/plugins/talk-plugin-moderation-actions/client/.babelrc b/plugins/talk-plugin-moderation-actions/client/.babelrc new file mode 100644 index 000000000..60be246eb --- /dev/null +++ b/plugins/talk-plugin-moderation-actions/client/.babelrc @@ -0,0 +1,14 @@ +{ + "presets": [ + "es2015" + ], + "plugins": [ + "add-module-exports", + "transform-class-properties", + "transform-decorators-legacy", + "transform-object-assign", + "transform-object-rest-spread", + "transform-async-to-generator", + "transform-react-jsx" + ] +} \ No newline at end of file diff --git a/plugins/talk-plugin-offtopic/client/.babelrc b/plugins/talk-plugin-offtopic/client/.babelrc new file mode 100644 index 000000000..60be246eb --- /dev/null +++ b/plugins/talk-plugin-offtopic/client/.babelrc @@ -0,0 +1,14 @@ +{ + "presets": [ + "es2015" + ], + "plugins": [ + "add-module-exports", + "transform-class-properties", + "transform-decorators-legacy", + "transform-object-assign", + "transform-object-rest-spread", + "transform-async-to-generator", + "transform-react-jsx" + ] +} \ No newline at end of file diff --git a/plugins/talk-plugin-permalink/client/.babelrc b/plugins/talk-plugin-permalink/client/.babelrc new file mode 100644 index 000000000..60be246eb --- /dev/null +++ b/plugins/talk-plugin-permalink/client/.babelrc @@ -0,0 +1,14 @@ +{ + "presets": [ + "es2015" + ], + "plugins": [ + "add-module-exports", + "transform-class-properties", + "transform-decorators-legacy", + "transform-object-assign", + "transform-object-rest-spread", + "transform-async-to-generator", + "transform-react-jsx" + ] +} \ No newline at end of file diff --git a/plugins/talk-plugin-remember-sort/client/.babelrc b/plugins/talk-plugin-remember-sort/client/.babelrc new file mode 100644 index 000000000..60be246eb --- /dev/null +++ b/plugins/talk-plugin-remember-sort/client/.babelrc @@ -0,0 +1,14 @@ +{ + "presets": [ + "es2015" + ], + "plugins": [ + "add-module-exports", + "transform-class-properties", + "transform-decorators-legacy", + "transform-object-assign", + "transform-object-rest-spread", + "transform-async-to-generator", + "transform-react-jsx" + ] +} \ No newline at end of file diff --git a/plugins/talk-plugin-respect/client/.babelrc b/plugins/talk-plugin-respect/client/.babelrc new file mode 100644 index 000000000..60be246eb --- /dev/null +++ b/plugins/talk-plugin-respect/client/.babelrc @@ -0,0 +1,14 @@ +{ + "presets": [ + "es2015" + ], + "plugins": [ + "add-module-exports", + "transform-class-properties", + "transform-decorators-legacy", + "transform-object-assign", + "transform-object-rest-spread", + "transform-async-to-generator", + "transform-react-jsx" + ] +} \ No newline at end of file diff --git a/plugins/talk-plugin-sort-most-liked/client/.babelrc b/plugins/talk-plugin-sort-most-liked/client/.babelrc new file mode 100644 index 000000000..60be246eb --- /dev/null +++ b/plugins/talk-plugin-sort-most-liked/client/.babelrc @@ -0,0 +1,14 @@ +{ + "presets": [ + "es2015" + ], + "plugins": [ + "add-module-exports", + "transform-class-properties", + "transform-decorators-legacy", + "transform-object-assign", + "transform-object-rest-spread", + "transform-async-to-generator", + "transform-react-jsx" + ] +} \ No newline at end of file diff --git a/plugins/talk-plugin-sort-most-loved/client/.babelrc b/plugins/talk-plugin-sort-most-loved/client/.babelrc new file mode 100644 index 000000000..60be246eb --- /dev/null +++ b/plugins/talk-plugin-sort-most-loved/client/.babelrc @@ -0,0 +1,14 @@ +{ + "presets": [ + "es2015" + ], + "plugins": [ + "add-module-exports", + "transform-class-properties", + "transform-decorators-legacy", + "transform-object-assign", + "transform-object-rest-spread", + "transform-async-to-generator", + "transform-react-jsx" + ] +} \ No newline at end of file diff --git a/plugins/talk-plugin-sort-most-replied/client/.babelrc b/plugins/talk-plugin-sort-most-replied/client/.babelrc new file mode 100644 index 000000000..60be246eb --- /dev/null +++ b/plugins/talk-plugin-sort-most-replied/client/.babelrc @@ -0,0 +1,14 @@ +{ + "presets": [ + "es2015" + ], + "plugins": [ + "add-module-exports", + "transform-class-properties", + "transform-decorators-legacy", + "transform-object-assign", + "transform-object-rest-spread", + "transform-async-to-generator", + "transform-react-jsx" + ] +} \ No newline at end of file diff --git a/plugins/talk-plugin-sort-most-respected/client/.babelrc b/plugins/talk-plugin-sort-most-respected/client/.babelrc new file mode 100644 index 000000000..60be246eb --- /dev/null +++ b/plugins/talk-plugin-sort-most-respected/client/.babelrc @@ -0,0 +1,14 @@ +{ + "presets": [ + "es2015" + ], + "plugins": [ + "add-module-exports", + "transform-class-properties", + "transform-decorators-legacy", + "transform-object-assign", + "transform-object-rest-spread", + "transform-async-to-generator", + "transform-react-jsx" + ] +} \ No newline at end of file diff --git a/plugins/talk-plugin-sort-newest/client/.babelrc b/plugins/talk-plugin-sort-newest/client/.babelrc new file mode 100644 index 000000000..60be246eb --- /dev/null +++ b/plugins/talk-plugin-sort-newest/client/.babelrc @@ -0,0 +1,14 @@ +{ + "presets": [ + "es2015" + ], + "plugins": [ + "add-module-exports", + "transform-class-properties", + "transform-decorators-legacy", + "transform-object-assign", + "transform-object-rest-spread", + "transform-async-to-generator", + "transform-react-jsx" + ] +} \ No newline at end of file diff --git a/plugins/talk-plugin-sort-oldest/client/.babelrc b/plugins/talk-plugin-sort-oldest/client/.babelrc new file mode 100644 index 000000000..60be246eb --- /dev/null +++ b/plugins/talk-plugin-sort-oldest/client/.babelrc @@ -0,0 +1,14 @@ +{ + "presets": [ + "es2015" + ], + "plugins": [ + "add-module-exports", + "transform-class-properties", + "transform-decorators-legacy", + "transform-object-assign", + "transform-object-rest-spread", + "transform-async-to-generator", + "transform-react-jsx" + ] +} \ No newline at end of file diff --git a/plugins/talk-plugin-toxic-comments/client/.babelrc b/plugins/talk-plugin-toxic-comments/client/.babelrc new file mode 100644 index 000000000..60be246eb --- /dev/null +++ b/plugins/talk-plugin-toxic-comments/client/.babelrc @@ -0,0 +1,14 @@ +{ + "presets": [ + "es2015" + ], + "plugins": [ + "add-module-exports", + "transform-class-properties", + "transform-decorators-legacy", + "transform-object-assign", + "transform-object-rest-spread", + "transform-async-to-generator", + "transform-react-jsx" + ] +} \ No newline at end of file diff --git a/plugins/talk-plugin-viewing-options/client/.babelrc b/plugins/talk-plugin-viewing-options/client/.babelrc new file mode 100644 index 000000000..60be246eb --- /dev/null +++ b/plugins/talk-plugin-viewing-options/client/.babelrc @@ -0,0 +1,14 @@ +{ + "presets": [ + "es2015" + ], + "plugins": [ + "add-module-exports", + "transform-class-properties", + "transform-decorators-legacy", + "transform-object-assign", + "transform-object-rest-spread", + "transform-async-to-generator", + "transform-react-jsx" + ] +} \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index 29d4a2605..bc012d33e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -572,6 +572,10 @@ babel-messages@^6.23.0: dependencies: babel-runtime "^6.22.0" +babel-plugin-add-module-exports@^0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/babel-plugin-add-module-exports/-/babel-plugin-add-module-exports-0.2.1.tgz#9ae9a1f4a8dc67f0cdec4f4aeda1e43a5ff65e25" + babel-plugin-check-es2015-constants@^6.22.0: version "6.22.0" resolved "https://registry.yarnpkg.com/babel-plugin-check-es2015-constants/-/babel-plugin-check-es2015-constants-6.22.0.tgz#35157b101426fd2ffd3da3f75c7d1e91835bbf8a" @@ -3176,7 +3180,11 @@ graceful-fs@^4.1.11, graceful-fs@^4.1.2, graceful-fs@^4.1.4, graceful-fs@^4.1.6, version "1.0.1" resolved "https://registry.yarnpkg.com/graceful-readlink/-/graceful-readlink-1.0.1.tgz#4cafad76bc62f02fa039b2f94e9a3dd3a391a725" -graphql-anywhere@^3.0.0, graphql-anywhere@^3.0.1, graphql-anywhere@^3.1.0: +graphql-anywhere@^3.0.0, graphql-anywhere@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/graphql-anywhere/-/graphql-anywhere-3.0.1.tgz#73531db861174c8f212eafb9f8e84944b38b4e5a" + +graphql-anywhere@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/graphql-anywhere/-/graphql-anywhere-3.1.0.tgz#3ea0d8e8646b5cee68035016a9a7557c15c21e96" From 074fbca23109688dbf5310d9774cb174177893c5 Mon Sep 17 00:00:00 2001 From: Wyatt Johnson Date: Tue, 3 Oct 2017 14:54:08 -0600 Subject: [PATCH 34/39] Revert "Revert "Es6 modules + tree shaking"" --- client/.babelrc => .babelrc | 5 +- bin/templates/plugin/client/.babelrc | 14 -- .../components/QuestionBoxBuilder.js | 14 +- client/coral-embed/src/index.js | 187 +++++++++--------- .../coral-framework/loaders/plugins-loader.js | 2 +- client/coral-framework/services/client.js | 3 +- client/talk-plugin-commentbox/index.js | 6 +- .../talk-plugin-flags/helpers/flagReasons.js | 27 ++- package.json | 1 - plugin-api/.babelrc | 14 -- plugins/talk-plugin-auth/client/.babelrc | 14 -- .../talk-plugin-author-menu/client/.babelrc | 14 -- .../client/.babelrc | 14 -- .../client/.babelrc | 14 -- .../client/components/.babelrc | 14 -- .../client/components/ModTag.js | 6 +- .../client/components/TabPane.js | 4 +- .../client/containers/ModTag.js | 17 +- .../client/containers/TabPane.js | 4 +- .../talk-plugin-flag-details/client/.babelrc | 14 -- .../talk-plugin-ignore-user/client/.babelrc | 14 -- plugins/talk-plugin-like/client/.babelrc | 14 -- plugins/talk-plugin-love/client/.babelrc | 14 -- .../talk-plugin-member-since/client/.babelrc | 14 -- .../client/.babelrc | 14 -- plugins/talk-plugin-offtopic/client/.babelrc | 14 -- plugins/talk-plugin-permalink/client/.babelrc | 14 -- .../talk-plugin-remember-sort/client/.babelrc | 14 -- plugins/talk-plugin-respect/client/.babelrc | 14 -- .../client/.babelrc | 14 -- .../client/.babelrc | 14 -- .../client/.babelrc | 14 -- .../client/.babelrc | 14 -- .../talk-plugin-sort-newest/client/.babelrc | 14 -- .../talk-plugin-sort-oldest/client/.babelrc | 14 -- .../client/.babelrc | 14 -- .../client/.babelrc | 14 -- yarn.lock | 10 +- 38 files changed, 139 insertions(+), 497 deletions(-) rename client/.babelrc => .babelrc (87%) delete mode 100644 bin/templates/plugin/client/.babelrc delete mode 100644 plugin-api/.babelrc delete mode 100644 plugins/talk-plugin-auth/client/.babelrc delete mode 100644 plugins/talk-plugin-author-menu/client/.babelrc delete mode 100644 plugins/talk-plugin-comment-content/client/.babelrc delete mode 100644 plugins/talk-plugin-featured-comments/client/.babelrc delete mode 100644 plugins/talk-plugin-featured-comments/client/components/.babelrc delete mode 100644 plugins/talk-plugin-flag-details/client/.babelrc delete mode 100644 plugins/talk-plugin-ignore-user/client/.babelrc delete mode 100644 plugins/talk-plugin-like/client/.babelrc delete mode 100644 plugins/talk-plugin-love/client/.babelrc delete mode 100644 plugins/talk-plugin-member-since/client/.babelrc delete mode 100644 plugins/talk-plugin-moderation-actions/client/.babelrc delete mode 100644 plugins/talk-plugin-offtopic/client/.babelrc delete mode 100644 plugins/talk-plugin-permalink/client/.babelrc delete mode 100644 plugins/talk-plugin-remember-sort/client/.babelrc delete mode 100644 plugins/talk-plugin-respect/client/.babelrc delete mode 100644 plugins/talk-plugin-sort-most-liked/client/.babelrc delete mode 100644 plugins/talk-plugin-sort-most-loved/client/.babelrc delete mode 100644 plugins/talk-plugin-sort-most-replied/client/.babelrc delete mode 100644 plugins/talk-plugin-sort-most-respected/client/.babelrc delete mode 100644 plugins/talk-plugin-sort-newest/client/.babelrc delete mode 100644 plugins/talk-plugin-sort-oldest/client/.babelrc delete mode 100644 plugins/talk-plugin-toxic-comments/client/.babelrc delete mode 100644 plugins/talk-plugin-viewing-options/client/.babelrc diff --git a/client/.babelrc b/.babelrc similarity index 87% rename from client/.babelrc rename to .babelrc index 2af1a3dad..3dcf42eb7 100644 --- a/client/.babelrc +++ b/.babelrc @@ -1,9 +1,8 @@ { "presets": [ - "es2015" + ["es2015", {modules: false}] ], "plugins": [ - "add-module-exports", "transform-class-properties", "transform-decorators-legacy", "transform-object-assign", @@ -12,4 +11,4 @@ "transform-react-jsx", "syntax-dynamic-import" ] -} \ No newline at end of file +} diff --git a/bin/templates/plugin/client/.babelrc b/bin/templates/plugin/client/.babelrc deleted file mode 100644 index 60be246eb..000000000 --- a/bin/templates/plugin/client/.babelrc +++ /dev/null @@ -1,14 +0,0 @@ -{ - "presets": [ - "es2015" - ], - "plugins": [ - "add-module-exports", - "transform-class-properties", - "transform-decorators-legacy", - "transform-object-assign", - "transform-object-rest-spread", - "transform-async-to-generator", - "transform-react-jsx" - ] -} \ No newline at end of file diff --git a/client/coral-configure/components/QuestionBoxBuilder.js b/client/coral-configure/components/QuestionBoxBuilder.js index 285df40ed..28dfc30b3 100644 --- a/client/coral-configure/components/QuestionBoxBuilder.js +++ b/client/coral-configure/components/QuestionBoxBuilder.js @@ -8,7 +8,7 @@ import styles from './QuestionBoxBuilder.css'; class QuestionBoxBuilder extends React.Component { constructor() { super(); - + this.state = { loading: true }; @@ -17,9 +17,9 @@ class QuestionBoxBuilder extends React.Component { componentWillMount() { this.loadEditor(); } - + async loadEditor() { - const MarkdownEditor = await import('coral-framework/components/MarkdownEditor'); + const {default: MarkdownEditor} = await import('coral-framework/components/MarkdownEditor'); return this.setState({ loading : false, @@ -79,17 +79,17 @@ class QuestionBoxBuilder extends React.Component { - handleChange({}, {questionBoxContent: value})} /> - +
    ); } diff --git a/client/coral-embed/src/index.js b/client/coral-embed/src/index.js index 34bee1797..f60a88439 100644 --- a/client/coral-embed/src/index.js +++ b/client/coral-embed/src/index.js @@ -2,101 +2,98 @@ import URLSearchParams from 'url-search-params'; import Stream from './Stream'; import StreamInterface from './StreamInterface'; -// This function should return value of window.Coral -const Coral = {}; -const Talk = (Coral.Talk = {}); +export class Talk { -/** - * Render a Talk stream - * @param {HTMLElement} el - Element to render the stream in - * @param {Object} opts - Configuration options for talk - * @param {String} opts.talk - Talk base URL - * @param {String} [opts.title] - Title of Stream (rendered in iframe) - * @param {String} [opts.asset_url] - Asset URL - * @param {String} [opts.asset_id] - Asset ID - * @param {String} [opts.auth_token] - (optional) A jwt representing the session - * @return {Object} - * - * Example: - * ``` - * const embed = Talk.render(document.getElementById('talkStreamEmbed'), opts); - * - * // trigger a login with optional token. - * embed.login(token); - * - * // trigger a logout. - * embed.logout(); - * - * // listen to events (in this case all events). - * embed.on('**', function(value) { - * console.log(this.event, value); - * }); - * ``` - */ -Talk.render = (el, opts) => { - if (!el) { - throw new Error('Please provide Coral.Talk.render() the HTMLElement you want to render Talk in.'); - } - if (typeof el !== 'object') { - throw new Error(`Coral.Talk.render() expected HTMLElement but got ${el} (${typeof el})`); - } - - opts = opts || {}; - - // TODO: infer this URL without explicit user input (if possible, may have to be added at build/render time of this script) - if (!opts.talk) { - throw new Error( - 'Coral.Talk.render() expects opts.talk as the Talk Base URL' - ); - } - - // Ensure el has an id, as pym can't directly accept the HTMLElement. - if (!el.id) { - el.id = `_${Math.random()}`; - } - - // Compose the query to send down to the Talk API so it knows what to load. - const query = {}; - - // Parse the url parameters to extract some of the information. - const urlParams = new URLSearchParams(window.location.search); - if (urlParams.get('commentId')) { - query.comment_id = urlParams.get('commentId'); - } - - // Extract the asset id from the options. - if (opts.asset_id) { - query.asset_id = opts.asset_id; - } - - // Extract the asset url. - if (opts.asset_url) { - query.asset_url = opts.asset_url; - } else if (!opts.asset_id) { - - // The asset url was not provided and the asset id was also not provided, - // we need to infer the asset url from details on the page. - - try { - query.asset_url = document.querySelector('link[rel="canonical"]').href; - } catch (e) { - console.warn( - 'This page does not include a canonical link tag. Talk has inferred this asset_url from the window object. Query params have been stripped, which may cause a single thread to be present across multiple pages.' - ); - - if (!window.location.origin) { - window.location.origin = `${window.location.protocol}//${window.location.hostname}${window.location.port ? `:${window.location.port}` : ''}`; - } - - query.asset_url = window.location.origin + window.location.pathname; + /** + * Render a Talk stream + * @param {HTMLElement} el - Element to render the stream in + * @param {Object} opts - Configuration options for talk + * @param {String} opts.talk - Talk base URL + * @param {String} [opts.title] - Title of Stream (rendered in iframe) + * @param {String} [opts.asset_url] - Asset URL + * @param {String} [opts.asset_id] - Asset ID + * @param {String} [opts.auth_token] - (optional) A jwt representing the session + * @return {Object} + * + * Example: + * ``` + * const embed = Talk.render(document.getElementById('talkStreamEmbed'), opts); + * + * // trigger a login with optional token. + * embed.login(token); + * + * // trigger a logout. + * embed.logout(); + * + * // listen to events (in this case all events). + * embed.on('**', function(value) { + * console.log(this.event, value); + * }); + * ``` + */ + static render(el, opts) { + if (!el) { + throw new Error('Please provide Coral.Talk.render() the HTMLElement you want to render Talk in.'); } + if (typeof el !== 'object') { + throw new Error(`Coral.Talk.render() expected HTMLElement but got ${el} (${typeof el})`); + } + + opts = opts || {}; + + // TODO: infer this URL without explicit user input (if possible, may have to be added at build/render time of this script) + if (!opts.talk) { + throw new Error( + 'Coral.Talk.render() expects opts.talk as the Talk Base URL' + ); + } + + // Ensure el has an id, as pym can't directly accept the HTMLElement. + if (!el.id) { + el.id = `_${Math.random()}`; + } + + // Compose the query to send down to the Talk API so it knows what to load. + const query = {}; + + // Parse the url parameters to extract some of the information. + const urlParams = new URLSearchParams(window.location.search); + if (urlParams.get('commentId')) { + query.comment_id = urlParams.get('commentId'); + } + + // Extract the asset id from the options. + if (opts.asset_id) { + query.asset_id = opts.asset_id; + } + + // Extract the asset url. + if (opts.asset_url) { + query.asset_url = opts.asset_url; + } else if (!opts.asset_id) { + + // The asset url was not provided and the asset id was also not provided, + // we need to infer the asset url from details on the page. + + try { + query.asset_url = document.querySelector('link[rel="canonical"]').href; + } catch (e) { + console.warn( + 'This page does not include a canonical link tag. Talk has inferred this asset_url from the window object. Query params have been stripped, which may cause a single thread to be present across multiple pages.' + ); + + if (!window.location.origin) { + window.location.origin = `${window.location.protocol}//${window.location.hostname}${window.location.port ? `:${window.location.port}` : ''}`; + } + + query.asset_url = window.location.origin + window.location.pathname; + } + } + + // Create the new Stream. + const stream = new Stream(el, opts.talk, query, opts); + + // Return the public interface for the stream. + return new StreamInterface(stream); } - - // Create the new Stream. - const stream = new Stream(el, opts.talk, query, opts); - - // Return the public interface for the stream. - return new StreamInterface(stream); -}; - -export default Coral; +} diff --git a/client/coral-framework/loaders/plugins-loader.js b/client/coral-framework/loaders/plugins-loader.js index a9fed95ab..7683dae8d 100644 --- a/client/coral-framework/loaders/plugins-loader.js +++ b/client/coral-framework/loaders/plugins-loader.js @@ -21,7 +21,7 @@ module.exports = function(source) { this.cacheable(); const config = this.exec(source, this.resourcePath); const plugins = getPluginList(config).map((plugin) => `{ - module: require('${plugin}/client'), + module: require('${plugin}/client').default, name: '${plugin}' }`); diff --git a/client/coral-framework/services/client.js b/client/coral-framework/services/client.js index 52088ad79..dc5a67d03 100644 --- a/client/coral-framework/services/client.js +++ b/client/coral-framework/services/client.js @@ -1,4 +1,4 @@ -import ApolloClient, {addTypename, IntrospectionFragmentMatcher, createNetworkInterface} from 'apollo-client'; +import ApolloClient, {IntrospectionFragmentMatcher, createNetworkInterface} from 'apollo-client'; import {SubscriptionClient, addGraphQLSubscriptions} from 'subscriptions-transport-ws'; import MessageTypes from 'subscriptions-transport-ws/dist/message-types'; @@ -64,7 +64,6 @@ export function createClient(options = {}) { connectToDevTools: true, addTypename: true, fragmentMatcher: new IntrospectionFragmentMatcher({introspectionQueryResultData: introspectionData}), - queryTransformer: addTypename, dataIdFromObject: (result) => { if (result.id && result.__typename) { // eslint-disable-line no-underscore-dangle return `${result.__typename}_${result.id}`; // eslint-disable-line no-underscore-dangle diff --git a/client/talk-plugin-commentbox/index.js b/client/talk-plugin-commentbox/index.js index 9f166caeb..0d94a840e 100644 --- a/client/talk-plugin-commentbox/index.js +++ b/client/talk-plugin-commentbox/index.js @@ -1,5 +1 @@ -import reducer from './reducer'; - -export default { - reducer -}; +export {default as reducer} from './reducer'; diff --git a/client/talk-plugin-flags/helpers/flagReasons.js b/client/talk-plugin-flags/helpers/flagReasons.js index 514c57398..52bddbb38 100644 --- a/client/talk-plugin-flags/helpers/flagReasons.js +++ b/client/talk-plugin-flags/helpers/flagReasons.js @@ -1,15 +1,14 @@ -export default { - username: { - offensive: 'USERNAME_OFFENSIVE', - nolike: 'USERNAME_NOLIKE', - impersonating: 'USERNAME_IMPERSONATING', - spam: 'USERNAME_SPAM', - other: 'USERNAME_OTHER' - }, - comment: { - offensive: 'COMMENT_OFFENSIVE', - spam: 'COMMENT_SPAM', - noagree: 'COMMENT_NOAGREE', - other: 'COMMENT_OTHER' - } +export const username = { + offensive: 'USERNAME_OFFENSIVE', + nolike: 'USERNAME_NOLIKE', + impersonating: 'USERNAME_IMPERSONATING', + spam: 'USERNAME_SPAM', + other: 'USERNAME_OTHER' +}; + +export const comment = { + offensive: 'COMMENT_OFFENSIVE', + spam: 'COMMENT_SPAM', + noagree: 'COMMENT_NOAGREE', + other: 'COMMENT_OTHER' }; diff --git a/package.json b/package.json index 52866238b..f8c8c9731 100644 --- a/package.json +++ b/package.json @@ -63,7 +63,6 @@ "babel-core": "^6.26.0", "babel-eslint": "^7.2.1", "babel-loader": "^7.1.2", - "babel-plugin-add-module-exports": "^0.2.1", "babel-plugin-syntax-dynamic-import": "^6.18.0", "babel-plugin-transform-async-to-generator": "^6.16.0", "babel-plugin-transform-class-properties": "^6.23.0", diff --git a/plugin-api/.babelrc b/plugin-api/.babelrc deleted file mode 100644 index 63b1c53de..000000000 --- a/plugin-api/.babelrc +++ /dev/null @@ -1,14 +0,0 @@ -{ - "presets": [ - "es2015" - ], - "plugins": [ - "add-module-exports", - "transform-class-properties", - "transform-decorators-legacy", - "transform-object-assign", - "transform-object-rest-spread", - "transform-async-to-generator", - "transform-react-jsx" - ] -} diff --git a/plugins/talk-plugin-auth/client/.babelrc b/plugins/talk-plugin-auth/client/.babelrc deleted file mode 100644 index 60be246eb..000000000 --- a/plugins/talk-plugin-auth/client/.babelrc +++ /dev/null @@ -1,14 +0,0 @@ -{ - "presets": [ - "es2015" - ], - "plugins": [ - "add-module-exports", - "transform-class-properties", - "transform-decorators-legacy", - "transform-object-assign", - "transform-object-rest-spread", - "transform-async-to-generator", - "transform-react-jsx" - ] -} \ No newline at end of file diff --git a/plugins/talk-plugin-author-menu/client/.babelrc b/plugins/talk-plugin-author-menu/client/.babelrc deleted file mode 100644 index 60be246eb..000000000 --- a/plugins/talk-plugin-author-menu/client/.babelrc +++ /dev/null @@ -1,14 +0,0 @@ -{ - "presets": [ - "es2015" - ], - "plugins": [ - "add-module-exports", - "transform-class-properties", - "transform-decorators-legacy", - "transform-object-assign", - "transform-object-rest-spread", - "transform-async-to-generator", - "transform-react-jsx" - ] -} \ No newline at end of file diff --git a/plugins/talk-plugin-comment-content/client/.babelrc b/plugins/talk-plugin-comment-content/client/.babelrc deleted file mode 100644 index 60be246eb..000000000 --- a/plugins/talk-plugin-comment-content/client/.babelrc +++ /dev/null @@ -1,14 +0,0 @@ -{ - "presets": [ - "es2015" - ], - "plugins": [ - "add-module-exports", - "transform-class-properties", - "transform-decorators-legacy", - "transform-object-assign", - "transform-object-rest-spread", - "transform-async-to-generator", - "transform-react-jsx" - ] -} \ No newline at end of file diff --git a/plugins/talk-plugin-featured-comments/client/.babelrc b/plugins/talk-plugin-featured-comments/client/.babelrc deleted file mode 100644 index 60be246eb..000000000 --- a/plugins/talk-plugin-featured-comments/client/.babelrc +++ /dev/null @@ -1,14 +0,0 @@ -{ - "presets": [ - "es2015" - ], - "plugins": [ - "add-module-exports", - "transform-class-properties", - "transform-decorators-legacy", - "transform-object-assign", - "transform-object-rest-spread", - "transform-async-to-generator", - "transform-react-jsx" - ] -} \ No newline at end of file diff --git a/plugins/talk-plugin-featured-comments/client/components/.babelrc b/plugins/talk-plugin-featured-comments/client/components/.babelrc deleted file mode 100644 index 60be246eb..000000000 --- a/plugins/talk-plugin-featured-comments/client/components/.babelrc +++ /dev/null @@ -1,14 +0,0 @@ -{ - "presets": [ - "es2015" - ], - "plugins": [ - "add-module-exports", - "transform-class-properties", - "transform-decorators-legacy", - "transform-object-assign", - "transform-object-rest-spread", - "transform-async-to-generator", - "transform-react-jsx" - ] -} \ No newline at end of file diff --git a/plugins/talk-plugin-featured-comments/client/components/ModTag.js b/plugins/talk-plugin-featured-comments/client/components/ModTag.js index 52c051796..7dfd36f2d 100644 --- a/plugins/talk-plugin-featured-comments/client/components/ModTag.js +++ b/plugins/talk-plugin-featured-comments/client/components/ModTag.js @@ -3,7 +3,7 @@ import cn from 'classnames'; import styles from './ModTag.css'; import {t} from 'plugin-api/beta/client/services'; import {Icon} from 'plugin-api/beta/client/components/ui'; -import * as notification from 'coral-admin/src/services/notification'; +import {getErrorMessages} from 'plugin-api/beta/client/utils'; export default class ModTag extends React.Component { constructor() { @@ -32,10 +32,10 @@ export default class ModTag extends React.Component { postTag = async () => { try { await this.props.postTag(); - notification.success(t('talk-plugin-featured-comments.notify_self_featured', this.props.comment.user.username)); + this.props.notify('success', t('talk-plugin-featured-comments.notify_self_featured', this.props.comment.user.username)); } catch(err) { - notification.showMutationErrors(err); + this.props.notify('error', getErrorMessages(err)); } } diff --git a/plugins/talk-plugin-featured-comments/client/components/TabPane.js b/plugins/talk-plugin-featured-comments/client/components/TabPane.js index 2f5d0c7c2..941f15402 100644 --- a/plugins/talk-plugin-featured-comments/client/components/TabPane.js +++ b/plugins/talk-plugin-featured-comments/client/components/TabPane.js @@ -1,7 +1,7 @@ import React from 'react'; import Comment from '../containers/Comment'; import LoadMore from './LoadMore'; -import {forEachError} from 'plugin-api/beta/client/utils'; +import {getErrorMessages} from 'plugin-api/beta/client/utils'; class TabPane extends React.Component { state = { @@ -16,7 +16,7 @@ class TabPane extends React.Component { }) .catch((error) => { this.setState({loadingState: 'error'}); - forEachError(error, ({msg}) => {this.props.addNotification('error', msg);}); + this.props.notify('error', getErrorMessages(error)); }); } diff --git a/plugins/talk-plugin-featured-comments/client/containers/ModTag.js b/plugins/talk-plugin-featured-comments/client/containers/ModTag.js index 7081c7ec6..88aee73f6 100644 --- a/plugins/talk-plugin-featured-comments/client/containers/ModTag.js +++ b/plugins/talk-plugin-featured-comments/client/containers/ModTag.js @@ -1,6 +1,13 @@ import ModTag from '../components/ModTag'; -import {withTags} from 'plugin-api/beta/client/hocs'; -import {gql} from 'react-apollo'; +import {withTags, connect} from 'plugin-api/beta/client/hocs'; +import {gql, compose} from 'react-apollo'; +import {bindActionCreators} from 'redux'; +import {notify} from 'plugin-api/beta/client/actions/notification'; + +const mapDispatchToProps = (dispatch) => + bindActionCreators({ + notify, + }, dispatch); const fragments = { comment: gql` @@ -11,6 +18,10 @@ const fragments = { } ` }; +const enhance = compose( + withTags('featured', {fragments}), + connect(null, mapDispatchToProps), +); -export default withTags('featured', {fragments})(ModTag); +export default enhance(ModTag); diff --git a/plugins/talk-plugin-featured-comments/client/containers/TabPane.js b/plugins/talk-plugin-featured-comments/client/containers/TabPane.js index 93ef402a9..5f684b228 100644 --- a/plugins/talk-plugin-featured-comments/client/containers/TabPane.js +++ b/plugins/talk-plugin-featured-comments/client/containers/TabPane.js @@ -4,7 +4,7 @@ import {compose, gql} from 'react-apollo'; import TabPane from '../components/TabPane'; import {withFragments, connect} from 'plugin-api/beta/client/hocs'; import Comment from '../containers/Comment'; -import {addNotification} from 'plugin-api/beta/client/actions/notification'; +import {notify} from 'plugin-api/beta/client/actions/notification'; import {viewComment} from 'coral-embed-stream/src/actions/stream'; import {appendNewNodes, getDefinitionName} from 'plugin-api/beta/client/utils'; import update from 'immutability-helper'; @@ -81,7 +81,7 @@ const LOAD_MORE_QUERY = gql` const mapDispatchToProps = (dispatch) => bindActionCreators({ viewComment, - addNotification, + notify, }, dispatch); const enhance = compose( diff --git a/plugins/talk-plugin-flag-details/client/.babelrc b/plugins/talk-plugin-flag-details/client/.babelrc deleted file mode 100644 index 60be246eb..000000000 --- a/plugins/talk-plugin-flag-details/client/.babelrc +++ /dev/null @@ -1,14 +0,0 @@ -{ - "presets": [ - "es2015" - ], - "plugins": [ - "add-module-exports", - "transform-class-properties", - "transform-decorators-legacy", - "transform-object-assign", - "transform-object-rest-spread", - "transform-async-to-generator", - "transform-react-jsx" - ] -} \ No newline at end of file diff --git a/plugins/talk-plugin-ignore-user/client/.babelrc b/plugins/talk-plugin-ignore-user/client/.babelrc deleted file mode 100644 index 60be246eb..000000000 --- a/plugins/talk-plugin-ignore-user/client/.babelrc +++ /dev/null @@ -1,14 +0,0 @@ -{ - "presets": [ - "es2015" - ], - "plugins": [ - "add-module-exports", - "transform-class-properties", - "transform-decorators-legacy", - "transform-object-assign", - "transform-object-rest-spread", - "transform-async-to-generator", - "transform-react-jsx" - ] -} \ No newline at end of file diff --git a/plugins/talk-plugin-like/client/.babelrc b/plugins/talk-plugin-like/client/.babelrc deleted file mode 100644 index 60be246eb..000000000 --- a/plugins/talk-plugin-like/client/.babelrc +++ /dev/null @@ -1,14 +0,0 @@ -{ - "presets": [ - "es2015" - ], - "plugins": [ - "add-module-exports", - "transform-class-properties", - "transform-decorators-legacy", - "transform-object-assign", - "transform-object-rest-spread", - "transform-async-to-generator", - "transform-react-jsx" - ] -} \ No newline at end of file diff --git a/plugins/talk-plugin-love/client/.babelrc b/plugins/talk-plugin-love/client/.babelrc deleted file mode 100644 index 60be246eb..000000000 --- a/plugins/talk-plugin-love/client/.babelrc +++ /dev/null @@ -1,14 +0,0 @@ -{ - "presets": [ - "es2015" - ], - "plugins": [ - "add-module-exports", - "transform-class-properties", - "transform-decorators-legacy", - "transform-object-assign", - "transform-object-rest-spread", - "transform-async-to-generator", - "transform-react-jsx" - ] -} \ No newline at end of file diff --git a/plugins/talk-plugin-member-since/client/.babelrc b/plugins/talk-plugin-member-since/client/.babelrc deleted file mode 100644 index 60be246eb..000000000 --- a/plugins/talk-plugin-member-since/client/.babelrc +++ /dev/null @@ -1,14 +0,0 @@ -{ - "presets": [ - "es2015" - ], - "plugins": [ - "add-module-exports", - "transform-class-properties", - "transform-decorators-legacy", - "transform-object-assign", - "transform-object-rest-spread", - "transform-async-to-generator", - "transform-react-jsx" - ] -} \ No newline at end of file diff --git a/plugins/talk-plugin-moderation-actions/client/.babelrc b/plugins/talk-plugin-moderation-actions/client/.babelrc deleted file mode 100644 index 60be246eb..000000000 --- a/plugins/talk-plugin-moderation-actions/client/.babelrc +++ /dev/null @@ -1,14 +0,0 @@ -{ - "presets": [ - "es2015" - ], - "plugins": [ - "add-module-exports", - "transform-class-properties", - "transform-decorators-legacy", - "transform-object-assign", - "transform-object-rest-spread", - "transform-async-to-generator", - "transform-react-jsx" - ] -} \ No newline at end of file diff --git a/plugins/talk-plugin-offtopic/client/.babelrc b/plugins/talk-plugin-offtopic/client/.babelrc deleted file mode 100644 index 60be246eb..000000000 --- a/plugins/talk-plugin-offtopic/client/.babelrc +++ /dev/null @@ -1,14 +0,0 @@ -{ - "presets": [ - "es2015" - ], - "plugins": [ - "add-module-exports", - "transform-class-properties", - "transform-decorators-legacy", - "transform-object-assign", - "transform-object-rest-spread", - "transform-async-to-generator", - "transform-react-jsx" - ] -} \ No newline at end of file diff --git a/plugins/talk-plugin-permalink/client/.babelrc b/plugins/talk-plugin-permalink/client/.babelrc deleted file mode 100644 index 60be246eb..000000000 --- a/plugins/talk-plugin-permalink/client/.babelrc +++ /dev/null @@ -1,14 +0,0 @@ -{ - "presets": [ - "es2015" - ], - "plugins": [ - "add-module-exports", - "transform-class-properties", - "transform-decorators-legacy", - "transform-object-assign", - "transform-object-rest-spread", - "transform-async-to-generator", - "transform-react-jsx" - ] -} \ No newline at end of file diff --git a/plugins/talk-plugin-remember-sort/client/.babelrc b/plugins/talk-plugin-remember-sort/client/.babelrc deleted file mode 100644 index 60be246eb..000000000 --- a/plugins/talk-plugin-remember-sort/client/.babelrc +++ /dev/null @@ -1,14 +0,0 @@ -{ - "presets": [ - "es2015" - ], - "plugins": [ - "add-module-exports", - "transform-class-properties", - "transform-decorators-legacy", - "transform-object-assign", - "transform-object-rest-spread", - "transform-async-to-generator", - "transform-react-jsx" - ] -} \ No newline at end of file diff --git a/plugins/talk-plugin-respect/client/.babelrc b/plugins/talk-plugin-respect/client/.babelrc deleted file mode 100644 index 60be246eb..000000000 --- a/plugins/talk-plugin-respect/client/.babelrc +++ /dev/null @@ -1,14 +0,0 @@ -{ - "presets": [ - "es2015" - ], - "plugins": [ - "add-module-exports", - "transform-class-properties", - "transform-decorators-legacy", - "transform-object-assign", - "transform-object-rest-spread", - "transform-async-to-generator", - "transform-react-jsx" - ] -} \ No newline at end of file diff --git a/plugins/talk-plugin-sort-most-liked/client/.babelrc b/plugins/talk-plugin-sort-most-liked/client/.babelrc deleted file mode 100644 index 60be246eb..000000000 --- a/plugins/talk-plugin-sort-most-liked/client/.babelrc +++ /dev/null @@ -1,14 +0,0 @@ -{ - "presets": [ - "es2015" - ], - "plugins": [ - "add-module-exports", - "transform-class-properties", - "transform-decorators-legacy", - "transform-object-assign", - "transform-object-rest-spread", - "transform-async-to-generator", - "transform-react-jsx" - ] -} \ No newline at end of file diff --git a/plugins/talk-plugin-sort-most-loved/client/.babelrc b/plugins/talk-plugin-sort-most-loved/client/.babelrc deleted file mode 100644 index 60be246eb..000000000 --- a/plugins/talk-plugin-sort-most-loved/client/.babelrc +++ /dev/null @@ -1,14 +0,0 @@ -{ - "presets": [ - "es2015" - ], - "plugins": [ - "add-module-exports", - "transform-class-properties", - "transform-decorators-legacy", - "transform-object-assign", - "transform-object-rest-spread", - "transform-async-to-generator", - "transform-react-jsx" - ] -} \ No newline at end of file diff --git a/plugins/talk-plugin-sort-most-replied/client/.babelrc b/plugins/talk-plugin-sort-most-replied/client/.babelrc deleted file mode 100644 index 60be246eb..000000000 --- a/plugins/talk-plugin-sort-most-replied/client/.babelrc +++ /dev/null @@ -1,14 +0,0 @@ -{ - "presets": [ - "es2015" - ], - "plugins": [ - "add-module-exports", - "transform-class-properties", - "transform-decorators-legacy", - "transform-object-assign", - "transform-object-rest-spread", - "transform-async-to-generator", - "transform-react-jsx" - ] -} \ No newline at end of file diff --git a/plugins/talk-plugin-sort-most-respected/client/.babelrc b/plugins/talk-plugin-sort-most-respected/client/.babelrc deleted file mode 100644 index 60be246eb..000000000 --- a/plugins/talk-plugin-sort-most-respected/client/.babelrc +++ /dev/null @@ -1,14 +0,0 @@ -{ - "presets": [ - "es2015" - ], - "plugins": [ - "add-module-exports", - "transform-class-properties", - "transform-decorators-legacy", - "transform-object-assign", - "transform-object-rest-spread", - "transform-async-to-generator", - "transform-react-jsx" - ] -} \ No newline at end of file diff --git a/plugins/talk-plugin-sort-newest/client/.babelrc b/plugins/talk-plugin-sort-newest/client/.babelrc deleted file mode 100644 index 60be246eb..000000000 --- a/plugins/talk-plugin-sort-newest/client/.babelrc +++ /dev/null @@ -1,14 +0,0 @@ -{ - "presets": [ - "es2015" - ], - "plugins": [ - "add-module-exports", - "transform-class-properties", - "transform-decorators-legacy", - "transform-object-assign", - "transform-object-rest-spread", - "transform-async-to-generator", - "transform-react-jsx" - ] -} \ No newline at end of file diff --git a/plugins/talk-plugin-sort-oldest/client/.babelrc b/plugins/talk-plugin-sort-oldest/client/.babelrc deleted file mode 100644 index 60be246eb..000000000 --- a/plugins/talk-plugin-sort-oldest/client/.babelrc +++ /dev/null @@ -1,14 +0,0 @@ -{ - "presets": [ - "es2015" - ], - "plugins": [ - "add-module-exports", - "transform-class-properties", - "transform-decorators-legacy", - "transform-object-assign", - "transform-object-rest-spread", - "transform-async-to-generator", - "transform-react-jsx" - ] -} \ No newline at end of file diff --git a/plugins/talk-plugin-toxic-comments/client/.babelrc b/plugins/talk-plugin-toxic-comments/client/.babelrc deleted file mode 100644 index 60be246eb..000000000 --- a/plugins/talk-plugin-toxic-comments/client/.babelrc +++ /dev/null @@ -1,14 +0,0 @@ -{ - "presets": [ - "es2015" - ], - "plugins": [ - "add-module-exports", - "transform-class-properties", - "transform-decorators-legacy", - "transform-object-assign", - "transform-object-rest-spread", - "transform-async-to-generator", - "transform-react-jsx" - ] -} \ No newline at end of file diff --git a/plugins/talk-plugin-viewing-options/client/.babelrc b/plugins/talk-plugin-viewing-options/client/.babelrc deleted file mode 100644 index 60be246eb..000000000 --- a/plugins/talk-plugin-viewing-options/client/.babelrc +++ /dev/null @@ -1,14 +0,0 @@ -{ - "presets": [ - "es2015" - ], - "plugins": [ - "add-module-exports", - "transform-class-properties", - "transform-decorators-legacy", - "transform-object-assign", - "transform-object-rest-spread", - "transform-async-to-generator", - "transform-react-jsx" - ] -} \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index bc012d33e..29d4a2605 100644 --- a/yarn.lock +++ b/yarn.lock @@ -572,10 +572,6 @@ babel-messages@^6.23.0: dependencies: babel-runtime "^6.22.0" -babel-plugin-add-module-exports@^0.2.1: - version "0.2.1" - resolved "https://registry.yarnpkg.com/babel-plugin-add-module-exports/-/babel-plugin-add-module-exports-0.2.1.tgz#9ae9a1f4a8dc67f0cdec4f4aeda1e43a5ff65e25" - babel-plugin-check-es2015-constants@^6.22.0: version "6.22.0" resolved "https://registry.yarnpkg.com/babel-plugin-check-es2015-constants/-/babel-plugin-check-es2015-constants-6.22.0.tgz#35157b101426fd2ffd3da3f75c7d1e91835bbf8a" @@ -3180,11 +3176,7 @@ graceful-fs@^4.1.11, graceful-fs@^4.1.2, graceful-fs@^4.1.4, graceful-fs@^4.1.6, version "1.0.1" resolved "https://registry.yarnpkg.com/graceful-readlink/-/graceful-readlink-1.0.1.tgz#4cafad76bc62f02fa039b2f94e9a3dd3a391a725" -graphql-anywhere@^3.0.0, graphql-anywhere@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/graphql-anywhere/-/graphql-anywhere-3.0.1.tgz#73531db861174c8f212eafb9f8e84944b38b4e5a" - -graphql-anywhere@^3.1.0: +graphql-anywhere@^3.0.0, graphql-anywhere@^3.0.1, graphql-anywhere@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/graphql-anywhere/-/graphql-anywhere-3.1.0.tgz#3ea0d8e8646b5cee68035016a9a7557c15c21e96" From d75257a832742624ebad6cdc7bb29d9a5850dd7d Mon Sep 17 00:00:00 2001 From: Wyatt Johnson Date: Tue, 3 Oct 2017 14:55:20 -0600 Subject: [PATCH 35/39] Revert "Revert "Remove .babelrc from plugin"" --- plugins/talk-plugin-subscriber/client/.babelrc | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 plugins/talk-plugin-subscriber/client/.babelrc diff --git a/plugins/talk-plugin-subscriber/client/.babelrc b/plugins/talk-plugin-subscriber/client/.babelrc deleted file mode 100644 index 60be246eb..000000000 --- a/plugins/talk-plugin-subscriber/client/.babelrc +++ /dev/null @@ -1,14 +0,0 @@ -{ - "presets": [ - "es2015" - ], - "plugins": [ - "add-module-exports", - "transform-class-properties", - "transform-decorators-legacy", - "transform-object-assign", - "transform-object-rest-spread", - "transform-async-to-generator", - "transform-react-jsx" - ] -} \ No newline at end of file From 5147ca6b86559cbaa9b985d98f19555fbd898899 Mon Sep 17 00:00:00 2001 From: Lance Ruegger Date: Wed, 4 Oct 2017 11:04:47 -0700 Subject: [PATCH 36/39] Add a max-width to the flag-reason text box to prevent cutoff --- client/coral-embed-stream/style/default.css | 1 + 1 file changed, 1 insertion(+) diff --git a/client/coral-embed-stream/style/default.css b/client/coral-embed-stream/style/default.css index a20c94d1a..0dcbf856e 100644 --- a/client/coral-embed-stream/style/default.css +++ b/client/coral-embed-stream/style/default.css @@ -270,6 +270,7 @@ button.comment__action-button[disabled], width: 75%; font-size: 16px; border: 1px solid #ccc; + max-width: calc(100% - 40px); } /* Close comments */ From 841ab53ea7cde647f69b2f47901fffec01483548 Mon Sep 17 00:00:00 2001 From: PepeFranco Date: Wed, 4 Oct 2017 15:42:02 -0500 Subject: [PATCH 37/39] Added env variable TALK_DEFAULT_LAN --- client/coral-framework/services/i18n.js | 2 +- webpack.config.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/client/coral-framework/services/i18n.js b/client/coral-framework/services/i18n.js index 1a4910b21..c25a58769 100644 --- a/client/coral-framework/services/i18n.js +++ b/client/coral-framework/services/i18n.js @@ -13,7 +13,7 @@ import pt_BR from '../../../locales/pt_BR.yml'; // Translations are happening at https://translate.lingohub.com/the-coral-project/dashboard -const defaultLanguage = 'en'; +const defaultLanguage = process.env.TALK_DEFAULT_LAN; const translations = {...en, ...es, ...fr, ...pt_BR}; let lang; diff --git a/webpack.config.js b/webpack.config.js index c555333bc..6e9917afc 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -111,7 +111,8 @@ const config = { new webpack.EnvironmentPlugin({ 'TALK_PLUGINS_JSON': '{}', 'TALK_THREADING_LEVEL': '3', - 'TALK_DEFAULT_STREAM_TAB': 'all' + 'TALK_DEFAULT_STREAM_TAB': 'all', + 'TALK_DEFAULT_LAN': 'en' }) ], resolveLoader: { From 8d6f79ab7944b7e16208ecff674924e2c18a41b3 Mon Sep 17 00:00:00 2001 From: PepeFranco Date: Wed, 4 Oct 2017 16:16:07 -0500 Subject: [PATCH 38/39] Fixed typo from LAN to LANG --- client/coral-framework/services/i18n.js | 2 +- webpack.config.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/client/coral-framework/services/i18n.js b/client/coral-framework/services/i18n.js index c25a58769..87e375853 100644 --- a/client/coral-framework/services/i18n.js +++ b/client/coral-framework/services/i18n.js @@ -13,7 +13,7 @@ import pt_BR from '../../../locales/pt_BR.yml'; // Translations are happening at https://translate.lingohub.com/the-coral-project/dashboard -const defaultLanguage = process.env.TALK_DEFAULT_LAN; +const defaultLanguage = process.env.TALK_DEFAULT_LANG; const translations = {...en, ...es, ...fr, ...pt_BR}; let lang; diff --git a/webpack.config.js b/webpack.config.js index 6e9917afc..d9c8ba4a0 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -112,7 +112,7 @@ const config = { 'TALK_PLUGINS_JSON': '{}', 'TALK_THREADING_LEVEL': '3', 'TALK_DEFAULT_STREAM_TAB': 'all', - 'TALK_DEFAULT_LAN': 'en' + 'TALK_DEFAULT_LANG': 'en' }) ], resolveLoader: { From 551ac9dd90a2b8be8a1649a1b1271d1f8ddbec59 Mon Sep 17 00:00:00 2001 From: Jose Franco Date: Wed, 4 Oct 2017 17:31:48 -0500 Subject: [PATCH 39/39] Update running-advanced-configuration.md --- docs/_docs/running-advanced-configuration.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/_docs/running-advanced-configuration.md b/docs/_docs/running-advanced-configuration.md index 5512f60cb..7db27fb1c 100644 --- a/docs/_docs/running-advanced-configuration.md +++ b/docs/_docs/running-advanced-configuration.md @@ -24,6 +24,10 @@ otherwise the application will fail to start. Configure the duration for which comment counts are cached for, parsed by [ms](https://www.npmjs.com/package/ms){:target="_blank"}. (Default `1hr`) +## TALK_DEFAULT_LANG + +Specify the default translation language. (Default `en`) + ## TALK_DEFAULT_STREAM_TAB Specify the default stream tab in the admin. (Default `all`) @@ -439,4 +443,4 @@ Could be read as: again, then they must have two of their comments approved in order to get added back to the queue. - At the moment of writing, behavior is not attached to the flagging - reliability, but it is recorded. \ No newline at end of file + reliability, but it is recorded.