From 8dad90104d68624352c81be12abe16d10dfa2aa0 Mon Sep 17 00:00:00 2001 From: David Jay Date: Fri, 2 Dec 2016 12:26:31 -0500 Subject: [PATCH 1/3] Returning infobox data in stream. --- models/setting.js | 9 ++++----- routes/api/queue/index.js | 2 +- routes/api/stream/index.js | 4 ++-- tests/models/setting.js | 11 ++++++++--- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/models/setting.js b/models/setting.js index e23f654a7..bf5ac290a 100644 --- a/models/setting.js +++ b/models/setting.js @@ -38,12 +38,11 @@ SettingSchema.statics.getSettings = function () { }; /** - * Gets the moderation settings and sends it back + * Gets the settings visible to the public * @return {Promise} moderation the settings for how to moderate comments */ -SettingSchema.statics.getModerationSetting = function () { - console.log('Getting moderation setting'); - return this.findOne({id: '1'}).select('moderation'); +SettingSchema.statics.getPublicSettings = function () { + return this.findOne({id: '1'}).select('moderation infoBoxEnable infoBoxContent'); }; /** @@ -51,7 +50,7 @@ SettingSchema.statics.getModerationSetting = function () { * @return {Promise} content the content of the info Box */ SettingSchema.statics.getInfoBoxSetting = function () { - return this.findOne({id: '1'}).select('infoBoxEnable', 'infoBoxContent'); + return this.findOne({id: '1'}).select('infoBoxEnable infoBoxContent'); }; /** diff --git a/routes/api/queue/index.js b/routes/api/queue/index.js index 448149387..b38d1b763 100644 --- a/routes/api/queue/index.js +++ b/routes/api/queue/index.js @@ -16,7 +16,7 @@ const router = express.Router(); // Pre-moderation: New comments are shown in the moderator queues immediately. // Post-moderation: New comments do not appear in moderation queues unless they are flagged by other users. router.get('/comments/pending', (req, res, next) => { - Setting.getModerationSetting().then(({moderation}) => + Setting.getPublicSettings().then(({moderation}) => Comment.moderationQueue(moderation)) .then((comments) => { return Promise.all([ diff --git a/routes/api/stream/index.js b/routes/api/stream/index.js index ce8871ab8..4e8373999 100644 --- a/routes/api/stream/index.js +++ b/routes/api/stream/index.js @@ -26,8 +26,8 @@ router.get('/', (req, res, next) => { return asset; }), - // Get the moderation setting from the settings. - Setting.getModerationSetting() + // Get the public settings. + Setting.getPublicSettings() ]) .then(([asset, settings]) => { diff --git a/tests/models/setting.js b/tests/models/setting.js index 08a47d7a1..186a65245 100644 --- a/tests/models/setting.js +++ b/tests/models/setting.js @@ -4,7 +4,9 @@ const expect = require('chai').expect; describe('Setting: model', () => { beforeEach(() => { - const defaults = {id: 1}; + const defaults = { + id: 1 + }; return Setting.update({id: '1'}, {$setOnInsert: defaults}, {upsert: true}); }); @@ -35,10 +37,13 @@ describe('Setting: model', () => { }); }); - describe('#getModerationSetting', () => { + describe('#getPublicSettings', () => { it('should return the moderation settings', () => { - return Setting.getModerationSetting().then(({moderation}) => { + return Setting.getPublicSettings().then(({moderation, infoBoxEnable, infoBoxContent, wordlist}) => { expect(moderation).not.to.be.null; + expect(infoBoxEnable).not.to.be.null; + expect(infoBoxContent).not.to.be.null; + expect(wordlist).to.be.undefined; }); }); }); From b1d0f8443fcb73e75b7604242f2dcef1e15f583d Mon Sep 17 00:00:00 2001 From: David Jay Date: Fri, 2 Dec 2016 12:47:18 -0500 Subject: [PATCH 2/3] Updating infobox styling. --- client/coral-embed-stream/style/default.css | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/client/coral-embed-stream/style/default.css b/client/coral-embed-stream/style/default.css index b6fe672cc..21e40ce98 100644 --- a/client/coral-embed-stream/style/default.css +++ b/client/coral-embed-stream/style/default.css @@ -56,12 +56,14 @@ hr { /* Info Box Styles */ .coral-plugin-infobox-info { - position: fixed; top: 0; border: 0; background: rgb(105,105,105); color: white; - border-radius: 2px; + width: 100%; + text-align: center; + padding: 10px; + margin-bottom: 10px; font-weight: bold; display: block; } From 0eca9eeadc84d6443c0e42a0f11d6c923c138ade Mon Sep 17 00:00:00 2001 From: David Jay Date: Fri, 2 Dec 2016 15:45:26 -0500 Subject: [PATCH 3/3] Prompting login when a loggout out user likes or comments. --- client/coral-embed-stream/src/CommentStream.js | 7 ++++++- client/coral-plugin-flags/FlagButton.js | 3 ++- client/coral-plugin-likes/LikeButton.js | 3 ++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/client/coral-embed-stream/src/CommentStream.js b/client/coral-embed-stream/src/CommentStream.js index 26142a311..40ad72a41 100644 --- a/client/coral-embed-stream/src/CommentStream.js +++ b/client/coral-embed-stream/src/CommentStream.js @@ -28,7 +28,7 @@ import SuspendedAccount from '../../coral-framework/components/SuspendedAccount' const {addItem, updateItem, postItem, getStream, postAction, deleteAction, appendItemArray} = itemActions; const {addNotification, clearNotification} = notificationActions; -const {logout} = authActions; +const {logout, showSignInDialog} = authActions; class CommentStream extends Component { @@ -129,6 +129,7 @@ class CommentStream extends Component { addNotification={this.props.addNotification} id={commentId} like={actions[comment.like]} + showSignInDialog={this.props.showSignInDialog} postAction={this.props.postAction} deleteAction={this.props.deleteAction} addItem={this.props.addItem} @@ -143,6 +144,7 @@ class CommentStream extends Component { postAction={this.props.postAction} deleteAction={this.props.deleteAction} addItem={this.props.addItem} + showSignInDialog={this.props.showSignInDialog} updateItem={this.props.updateItem} currentUser={this.props.auth.user}/> @@ -189,6 +192,7 @@ class CommentStream extends Component { id={replyId} flag={this.props.items.actions[reply.flag]} postAction={this.props.postAction} + showSignInDialog={this.props.showSignInDialog} deleteAction={this.props.deleteAction} addItem={this.props.addItem} updateItem={this.props.updateItem} @@ -253,6 +257,7 @@ const mapDispatchToProps = (dispatch) => ({ getStream: (rootId) => dispatch(getStream(rootId)), addNotification: (type, text) => dispatch(addNotification(type, text)), clearNotification: () => dispatch(clearNotification()), + showSignInDialog: () => dispatch(showSignInDialog()), postAction: (item, action, user, itemType) => dispatch(postAction(item, action, user, itemType)), deleteAction: (item, action, user, itemType) => dispatch(deleteAction(item, action, user, itemType)), appendItemArray: (item, property, value, addToFront, itemType) => dispatch(appendItemArray(item, property, value, addToFront, itemType)), diff --git a/client/coral-plugin-flags/FlagButton.js b/client/coral-plugin-flags/FlagButton.js index cbb0fef63..f0ab1b22f 100644 --- a/client/coral-plugin-flags/FlagButton.js +++ b/client/coral-plugin-flags/FlagButton.js @@ -4,10 +4,11 @@ import translations from './translations.json'; const name = 'coral-plugin-flags'; -const FlagButton = ({flag, id, postAction, deleteAction, addItem, updateItem, addNotification, currentUser}) => { +const FlagButton = ({flag, id, postAction, deleteAction, addItem, showSignInDialog, updateItem, addNotification, currentUser}) => { const flagged = flag && flag.current_user; const onFlagClick = () => { if (!currentUser) { + showSignInDialog(); return; } if (!flagged) { diff --git a/client/coral-plugin-likes/LikeButton.js b/client/coral-plugin-likes/LikeButton.js index 07f27c426..b3d31fbf4 100644 --- a/client/coral-plugin-likes/LikeButton.js +++ b/client/coral-plugin-likes/LikeButton.js @@ -4,10 +4,11 @@ import translations from './translations.json'; const name = 'coral-plugin-flags'; -const LikeButton = ({like, id, postAction, deleteAction, addItem, updateItem, currentUser}) => { +const LikeButton = ({like, id, postAction, deleteAction, addItem, showSignInDialog, updateItem, currentUser}) => { const liked = like && like.current_user; const onLikeClick = () => { if (!currentUser) { + showSignInDialog(); return; } if (!liked) {