From b16bdafc1ab6d0e34a4fe39f9228e0dc1b816c27 Mon Sep 17 00:00:00 2001 From: gaba Date: Mon, 13 Feb 2017 12:22:05 -0800 Subject: [PATCH 01/15] Adds plugin for question box. --- client/coral-embed-stream/src/Embed.js | 4 ++++ client/coral-plugin-questionbox/QuestionBox.js | 10 ++++++++++ models/setting.js | 8 ++++++++ 3 files changed, 22 insertions(+) create mode 100644 client/coral-plugin-questionbox/QuestionBox.js diff --git a/client/coral-embed-stream/src/Embed.js b/client/coral-embed-stream/src/Embed.js index 6cc783746..d33fbfce9 100644 --- a/client/coral-embed-stream/src/Embed.js +++ b/client/coral-embed-stream/src/Embed.js @@ -112,6 +112,10 @@ class Embed extends Component { content={asset.settings.infoBoxContent} enable={asset.settings.infoBoxEnable} /> + +
+ {content} +
; + +export default QuestionBox; diff --git a/models/setting.js b/models/setting.js index adbf60d83..4e5aa4476 100644 --- a/models/setting.js +++ b/models/setting.js @@ -28,6 +28,14 @@ const SettingSchema = new Schema({ type: String, default: '' }, + questionBoxEnable: { + type: Boolean, + default: false + }, + questionBoxContent: { + type: String, + default: '' + }, organizationName: { type: String }, From 5a2e4b708b8a047ff645dc3b5cbeacb9ff489508 Mon Sep 17 00:00:00 2001 From: gaba Date: Mon, 13 Feb 2017 13:48:03 -0800 Subject: [PATCH 02/15] Adds question box --- client/coral-embed-stream/src/Embed.js | 1 + 1 file changed, 1 insertion(+) diff --git a/client/coral-embed-stream/src/Embed.js b/client/coral-embed-stream/src/Embed.js index d33fbfce9..e8a7859af 100644 --- a/client/coral-embed-stream/src/Embed.js +++ b/client/coral-embed-stream/src/Embed.js @@ -16,6 +16,7 @@ import {Notification, notificationActions, authActions, assetActions, pym} from import Stream from './Stream'; import InfoBox from 'coral-plugin-infobox/InfoBox'; +import QuestionBox from 'coral-plugin-questionbox/QuestionBox'; import Count from 'coral-plugin-comment-count/CommentCount'; import CommentBox from 'coral-plugin-commentbox/CommentBox'; import UserBox from 'coral-sign-in/components/UserBox'; From 1b788b98c601ef9f4132bbbe304f211222b83238 Mon Sep 17 00:00:00 2001 From: gaba Date: Mon, 13 Feb 2017 14:12:32 -0800 Subject: [PATCH 03/15] Adds questionBox to the gl query --- client/coral-framework/graphql/queries/streamQuery.graphql | 2 ++ client/coral-plugin-stream/Stream.js | 2 +- graph/typeDefs.graphql | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/client/coral-framework/graphql/queries/streamQuery.graphql b/client/coral-framework/graphql/queries/streamQuery.graphql index 583a2db13..31e125d81 100644 --- a/client/coral-framework/graphql/queries/streamQuery.graphql +++ b/client/coral-framework/graphql/queries/streamQuery.graphql @@ -11,6 +11,8 @@ query AssetQuery($asset_url: String!) { moderation infoBoxEnable infoBoxContent + questionBoxEnable + questionBoxContent closeTimeout closedMessage charCountEnable diff --git a/client/coral-plugin-stream/Stream.js b/client/coral-plugin-stream/Stream.js index c62ef7081..2796f1247 100644 --- a/client/coral-plugin-stream/Stream.js +++ b/client/coral-plugin-stream/Stream.js @@ -51,7 +51,7 @@ class Stream extends Component { } } -// Initialize GraphQL queries or mutations with the `gql` tag +// Initialize GraphQL queries or mutations with the gql tag const StreamQuery = gql`fragment commentView on Comment { id body diff --git a/graph/typeDefs.graphql b/graph/typeDefs.graphql index ddffcd708..728cead8f 100644 --- a/graph/typeDefs.graphql +++ b/graph/typeDefs.graphql @@ -271,6 +271,8 @@ type Settings { infoBoxEnable: Boolean infoBoxContent: String + questionBoxEnable: Boolean + questionBoxContent: String closeTimeout: Int closedMessage: String charCountEnable: Boolean From 1d70ae0decb689240b870221acaa64ae064f90d8 Mon Sep 17 00:00:00 2001 From: gaba Date: Mon, 13 Feb 2017 14:31:56 -0800 Subject: [PATCH 04/15] Adds question enable checkbox. --- .../components/ConfigureCommentStream.js | 12 ++++++++++++ .../containers/ConfigureStreamContainer.js | 8 +++++++- client/coral-configure/translations.json | 8 ++++++-- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/client/coral-configure/components/ConfigureCommentStream.js b/client/coral-configure/components/ConfigureCommentStream.js index bf4ebe3e6..e986e8d0d 100644 --- a/client/coral-configure/components/ConfigureCommentStream.js +++ b/client/coral-configure/components/ConfigureCommentStream.js @@ -49,6 +49,18 @@ export default ({handleChange, handleApply, changed, ...props}) => ( */} +
  • + +
  • diff --git a/client/coral-configure/containers/ConfigureStreamContainer.js b/client/coral-configure/containers/ConfigureStreamContainer.js index dfe94de42..54dd31f4e 100644 --- a/client/coral-configure/containers/ConfigureStreamContainer.js +++ b/client/coral-configure/containers/ConfigureStreamContainer.js @@ -27,12 +27,14 @@ class ConfigureStreamContainer extends Component { e.preventDefault(); const {elements} = e.target; const premod = elements.premod.checked; + const questionBoxEnable = elements.qboxenable.checked; // const premodLinks = elements.premodLinks.checked; const {changed} = this.state; const newConfig = { - moderation: premod ? 'PRE' : 'POST' + moderation: premod ? 'PRE' : 'POST', + questionBoxEnable: questionBoxEnable }; if (changed) { @@ -66,6 +68,8 @@ class ConfigureStreamContainer extends Component { render () { const status = this.props.asset.closedAt === null ? 'open' : 'closed'; const premod = this.props.asset.settings.moderation === 'PRE'; + const questionBoxEnable = this.props.asset.settings.questionBoxEnable; + const questionBoxContent = this.props.asset.settings.questionBoxContent; return (
    @@ -75,6 +79,8 @@ class ConfigureStreamContainer extends Component { changed={this.state.changed} premodLinks={false} premod={premod} + questionBoxEnable={questionBoxEnable} + questionBoxContent={questionBoxContent} />

    {status === 'open' ? 'Close' : 'Open'} Comment Stream

    diff --git a/client/coral-configure/translations.json b/client/coral-configure/translations.json index 5aa7f72b6..fe1045662 100644 --- a/client/coral-configure/translations.json +++ b/client/coral-configure/translations.json @@ -7,7 +7,9 @@ "enablePremod": "Enable Premoderation", "enablePremodDescription": "Moderators must approve any comment before its published.", "enablePremodLinks": "Pre-Moderate Comments Containing Links", - "enablePremodLinksDescription": "Moderators must approve any comment containing a link before its published." + "enablePremodLinksDescription": "Moderators must approve any comment containing a link before its published.", + "enableQuestionBox": "Enable Question Box", + "enableQuestionBoxDescription": "Commenters will see the next question at the top of the comments stream." } }, "es": { @@ -18,7 +20,9 @@ "enablePremod": "Activar Pre Moderación", "enablePremodDescription": "Los Moderadores deben aprobar cualquier comentario antes de su publicación", "enablePremodLinks": "Pre-Moderar Commentarios que contienen Links", - "enablePremodLinksDescription": "Los Moderadores deben probar cualquier comentario que contengan links antes de su publicación." + "enablePremodLinksDescription": "Los Moderadores deben probar cualquier comentario que contengan links antes de su publicación.", + "enableQuestionBox": "Activar Caja de Pregunta", + "enableQuestionBoxDescription": "La siguiente pregunta estara en la parte de arriba del hilo de comentarios." } } } From d4109c8fcac50fd42bbe697f4a3fb9c153c7a2fe Mon Sep 17 00:00:00 2001 From: gaba Date: Mon, 13 Feb 2017 16:51:31 -0800 Subject: [PATCH 05/15] Adds textfield to coral-UI. --- .../components/ConfigureCommentStream.css | 14 ++++++++++++++ .../components/ConfigureCommentStream.js | 6 +++++- .../containers/ConfigureStreamContainer.js | 6 +++++- client/coral-configure/translations.json | 6 ++++-- client/coral-ui/components/TextField.js | 11 +++++++++++ 5 files changed, 39 insertions(+), 4 deletions(-) create mode 100644 client/coral-ui/components/TextField.js diff --git a/client/coral-configure/components/ConfigureCommentStream.css b/client/coral-configure/components/ConfigureCommentStream.css index 8526edc09..dfa860995 100644 --- a/client/coral-configure/components/ConfigureCommentStream.css +++ b/client/coral-configure/components/ConfigureCommentStream.css @@ -35,3 +35,17 @@ p { .wrapper { margin-bottom: 20px; } + +.configSettingQuestionBox { + min-height: 100px; + margin-bottom: 20px; + cursor: pointer; + width: auto; + height: auto; + text-align: left; + overflow: visible; +} + +.hidden { + display: none; +} diff --git a/client/coral-configure/components/ConfigureCommentStream.js b/client/coral-configure/components/ConfigureCommentStream.js index e986e8d0d..4298384e0 100644 --- a/client/coral-configure/components/ConfigureCommentStream.js +++ b/client/coral-configure/components/ConfigureCommentStream.js @@ -60,9 +60,13 @@ export default ({handleChange, handleApply, changed, ...props}) => ( title: lang.t('configureCommentStream.enableQuestionBox'), description: lang.t('configureCommentStream.enableQuestionBoxDescription') }} /> +
    +
    + Pepe +
    +
    - ); diff --git a/client/coral-configure/containers/ConfigureStreamContainer.js b/client/coral-configure/containers/ConfigureStreamContainer.js index 54dd31f4e..2f0b01800 100644 --- a/client/coral-configure/containers/ConfigureStreamContainer.js +++ b/client/coral-configure/containers/ConfigureStreamContainer.js @@ -28,13 +28,17 @@ class ConfigureStreamContainer extends Component { const {elements} = e.target; const premod = elements.premod.checked; const questionBoxEnable = elements.qboxenable.checked; + const questionBoxContent = ''; // elements.qboxcontent.value; + + console.log('debug ', questionBoxContent); // const premodLinks = elements.premodLinks.checked; const {changed} = this.state; const newConfig = { moderation: premod ? 'PRE' : 'POST', - questionBoxEnable: questionBoxEnable + questionBoxEnable, + questionBoxContent }; if (changed) { diff --git a/client/coral-configure/translations.json b/client/coral-configure/translations.json index fe1045662..bd45d6159 100644 --- a/client/coral-configure/translations.json +++ b/client/coral-configure/translations.json @@ -9,7 +9,8 @@ "enablePremodLinks": "Pre-Moderate Comments Containing Links", "enablePremodLinksDescription": "Moderators must approve any comment containing a link before its published.", "enableQuestionBox": "Enable Question Box", - "enableQuestionBoxDescription": "Commenters will see the next question at the top of the comments stream." + "enableQuestionBoxDescription": "Commenters will see a question at the top of the comments stream.", + "includeQuestionHere": "Include your question here." } }, "es": { @@ -22,7 +23,8 @@ "enablePremodLinks": "Pre-Moderar Commentarios que contienen Links", "enablePremodLinksDescription": "Los Moderadores deben probar cualquier comentario que contengan links antes de su publicación.", "enableQuestionBox": "Activar Caja de Pregunta", - "enableQuestionBoxDescription": "La siguiente pregunta estara en la parte de arriba del hilo de comentarios." + "enableQuestionBoxDescription": "Una pregunta estara en la parte de arriba del hilo de comentarios.", + "includeQuestionHere": "Escribir la pregunta aquí." } } } diff --git a/client/coral-ui/components/TextField.js b/client/coral-ui/components/TextField.js new file mode 100644 index 000000000..9cdddf5c8 --- /dev/null +++ b/client/coral-ui/components/TextField.js @@ -0,0 +1,11 @@ +import React from 'react'; +import {Textfield as TextFieldMDL} from 'react-mdl'; + +const TextField = ({onChange, label, rows}) => ( + +); + +export default TextField; From 00c2305ff73d38c7dc28c9fbc02754cb2937458d Mon Sep 17 00:00:00 2001 From: David Jay Date: Tue, 14 Feb 2017 18:29:59 -0500 Subject: [PATCH 06/15] Adding view more button to replies. --- client/coral-embed-stream/src/Comment.js | 13 +++++++++ client/coral-embed-stream/src/Embed.js | 1 + client/coral-embed-stream/src/LoadMore.js | 15 ++++++---- client/coral-embed-stream/src/Stream.js | 2 ++ client/coral-embed-stream/style/default.css | 10 +++++++ .../coral-framework/graphql/queries/index.js | 28 +++++++++++++++---- .../graphql/queries/loadMore.graphql | 1 + .../graphql/queries/streamQuery.graphql | 1 + 8 files changed, 60 insertions(+), 11 deletions(-) diff --git a/client/coral-embed-stream/src/Comment.js b/client/coral-embed-stream/src/Comment.js index 3bf787a9c..034c44f6a 100644 --- a/client/coral-embed-stream/src/Comment.js +++ b/client/coral-embed-stream/src/Comment.js @@ -17,6 +17,7 @@ import PubDate from 'coral-plugin-pubdate/PubDate'; import {ReplyBox, ReplyButton} from 'coral-plugin-replies'; import FlagComment from 'coral-plugin-flags/FlagComment'; import LikeButton from 'coral-plugin-likes/LikeButton'; +import LoadMore from 'coral-embed-stream/src/LoadMore'; import styles from './Comment.css'; @@ -89,6 +90,7 @@ class Comment extends React.Component { showSignInDialog, postLike, postFlag, + loadMore, setActiveReplyBox, activeReplyBox, deleteAction @@ -172,6 +174,17 @@ class Comment extends React.Component { comment={reply} />; }) } + { + comment.replies && +
    + comment.replies.length} + loadMore={loadMore}/> +
    + } ); } diff --git a/client/coral-embed-stream/src/Embed.js b/client/coral-embed-stream/src/Embed.js index e5eec37cb..d58107934 100644 --- a/client/coral-embed-stream/src/Embed.js +++ b/client/coral-embed-stream/src/Embed.js @@ -151,6 +151,7 @@ class Embed extends Component { currentUser={user} postLike={this.props.postLike} postFlag={this.props.postFlag} + loadMore={this.props.loadMore} deleteAction={this.props.deleteAction} showSignInDialog={this.props.showSignInDialog} comments={asset.comments} /> diff --git a/client/coral-embed-stream/src/LoadMore.js b/client/coral-embed-stream/src/LoadMore.js index e871af410..e07c1aa35 100644 --- a/client/coral-embed-stream/src/LoadMore.js +++ b/client/coral-embed-stream/src/LoadMore.js @@ -4,24 +4,29 @@ import translations from 'coral-framework/translations.json'; import {Button} from 'coral-ui'; const lang = new I18n(translations); -const loadMoreComments = (id, comments, loadMore) => { +const loadMoreComments = (id, comments, loadMore, parentId) => { if (!comments.length) { return; } + const cursor = parentId + ? comments[1].created_at + : comments[comments.length - 1].created_at; + loadMore({ limit: 10, - cursor: comments[comments.length - 1].created_at, + cursor, asset_id: id, - sort: 'REVERSE_CHRONOLOGICAL' + parent_id: parentId, + sort: parentId ? 'CHRONOLOGICAL' : 'REVERSE_CHRONOLOGICAL' }); }; -const LoadMore = ({id, comments, loadMore, moreComments}) => moreComments ? +const LoadMore = ({id, comments, loadMore, moreComments, parentId}) => moreComments ?