From 08d672ed4655cda257ec0c44a78c6ce2648ea533 Mon Sep 17 00:00:00 2001 From: gaba Date: Tue, 15 Nov 2016 10:11:37 -0800 Subject: [PATCH] Changes model and add admin. --- .../coral-admin/src/containers/Configure.css | 6 +++++ .../coral-admin/src/containers/Configure.js | 24 ++++++++++++++++- .../coral-embed-stream/src/CommentStream.js | 4 +++ client/coral-embed-stream/style/default.css | 11 ++++++++ client/coral-plugin-infobox/InfoBox.js | 11 ++++++++ .../__tests__/infoBox.spec.js | 26 +++++++++++++++++++ models/setting.js | 12 ++++++++- tests/models/setting.js | 12 +++++++-- 8 files changed, 102 insertions(+), 4 deletions(-) create mode 100644 client/coral-plugin-infobox/InfoBox.js create mode 100644 client/coral-plugin-infobox/__tests__/infoBox.spec.js diff --git a/client/coral-admin/src/containers/Configure.css b/client/coral-admin/src/containers/Configure.css index 98cb0e254..c832e96c1 100644 --- a/client/coral-admin/src/containers/Configure.css +++ b/client/coral-admin/src/containers/Configure.css @@ -23,6 +23,12 @@ cursor: pointer; } +.configSettingInfoBox { + border: 1px solid #ccc; + border-radius: 4px; + margin-bottom: 10px; +} + .configSettingEmbed { border: 1px solid #ccc; border-radius: 4px; diff --git a/client/coral-admin/src/containers/Configure.js b/client/coral-admin/src/containers/Configure.js index 229c4e948..0dff4cf9a 100644 --- a/client/coral-admin/src/containers/Configure.js +++ b/client/coral-admin/src/containers/Configure.js @@ -7,7 +7,7 @@ import { ListItem, ListItemContent, ListItemAction, - //Textfield, + Textfield, Checkbox, Button, Icon @@ -36,6 +36,16 @@ class Configure extends React.Component { this.props.dispatch(updateSettings({moderation})); } + updateInfoBoxEnable () { + const infoboxEnable = this.props.settings.infoBoxEnable; + this.props.dispatch(updateSettings({infoboxEnable})); + } + + updateInfoBoxContent () { + const infoboxContent = this.props.settings.infoBoxContent; + this.props.dispatch(updateSettings({infoboxContent})); + } + saveSettings () { this.props.dispatch(saveSettingsToServer()); } @@ -50,6 +60,18 @@ class Configure extends React.Component { Enable pre-moderation + + + + + + {/* diff --git a/client/coral-embed-stream/src/CommentStream.js b/client/coral-embed-stream/src/CommentStream.js index bfccf7cfc..004f5b642 100644 --- a/client/coral-embed-stream/src/CommentStream.js +++ b/client/coral-embed-stream/src/CommentStream.js @@ -7,6 +7,7 @@ import { } from '../../coral-framework'; import {connect} from 'react-redux'; import CommentBox from '../../coral-plugin-commentbox/CommentBox'; +import InfoBox from '../../coral-plugin-infobox/InfoBox'; import Content from '../../coral-plugin-commentcontent/CommentContent'; import PubDate from '../../coral-plugin-pubdate/PubDate'; import Count from '../../coral-plugin-comment-count/CommentCount'; @@ -100,6 +101,9 @@ class CommentStream extends Component { rootItem ?
+ diff --git a/client/coral-embed-stream/style/default.css b/client/coral-embed-stream/style/default.css index e1c730bfc..08b1d8041 100644 --- a/client/coral-embed-stream/style/default.css +++ b/client/coral-embed-stream/style/default.css @@ -49,6 +49,17 @@ hr { font-weight: bold; } +/* Info Box Styles */ +.coral-plugin-infobox-info { + position: fixed; + bottom: 0; + border: 0; + background: rgb(105,105,105); + color: white; + border-radius: 2px; + font-weight: bold; +} + /* Comment Box Styles */ .coral-plugin-commentbox-container { display: flex; diff --git a/client/coral-plugin-infobox/InfoBox.js b/client/coral-plugin-infobox/InfoBox.js new file mode 100644 index 000000000..cae80df88 --- /dev/null +++ b/client/coral-plugin-infobox/InfoBox.js @@ -0,0 +1,11 @@ +import React from 'react'; +const packagename = 'coral-plugin-infobox'; + +const InfoBox = ({enable, content}) => +; + +export default InfoBox; diff --git a/client/coral-plugin-infobox/__tests__/infoBox.spec.js b/client/coral-plugin-infobox/__tests__/infoBox.spec.js new file mode 100644 index 000000000..b8b761489 --- /dev/null +++ b/client/coral-plugin-infobox/__tests__/infoBox.spec.js @@ -0,0 +1,26 @@ +import React from 'react'; +import {shallow} from 'enzyme'; +import {expect} from 'chai'; +import InfoBox from '../InfoBox'; + +describe('InfoBox', () => { + 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 InfoBox appropriately', () => { + expect(render.contains('
{ beforeEach(() => { - const defaults = {id: 1, moderation: 'pre'}; + const defaults = {id: 1}; return Setting.update({id: '1'}, {$setOnInsert: defaults}, {upsert: true}); }); @@ -18,13 +18,21 @@ describe('Setting: model', () => { expect(settings).to.have.property('moderation').and.to.equal('pre'); }); }); + it('should have two infoBox fields defined', () => { + return Setting.getSettings().then(settings => { + expect(settings).to.have.property('infoBoxEnable').and.to.equal(false); + expect(settings).to.have.property('infoBoxContent').and.to.equal(''); + }); + }); }); describe('#updateSettings()', () => { it('should update the settings with a passed object', () => { - const mockSettings = {moderation: 'post'}; + const mockSettings = {moderation: 'post', infoBoxEnable: true, infoBoxContent: 'yeah'}; return Setting.updateSettings(mockSettings).then(updatedSettings => { expect(updatedSettings).to.have.property('moderation').and.to.equal('post'); + expect(updatedSettings).to.have.property('infoBoxEnable', true); + expect(updatedSettings).to.have.property('infoBoxContent', 'yeah'); }); }); });