@@ -90,135 +100,145 @@ class CommentStream extends Component {
Settings
+ Configure Stream
- {loggedIn && }
+ {loggedIn && }
{/* Add to the restricted param a boolean if the user is suspended*/}
}>
-
+ This comment stream is currently open. By closing this comment stream,
+ no new comments may be submitted and all previous comments will still
+ be displayed.
+
+
+
+ ) : (
+
+
+ This comment stream is currently closed. By opening this comment stream,
+ new comments may be submitted and displayed
+
+
+
+ )
+);
diff --git a/client/coral-framework/index.js b/client/coral-framework/index.js
index 7b721badc..9a679d969 100644
--- a/client/coral-framework/index.js
+++ b/client/coral-framework/index.js
@@ -4,6 +4,7 @@ import * as itemActions from './actions/items';
import I18n from './modules/i18n/i18n';
import * as notificationActions from './actions/notification';
import * as authActions from './actions/auth';
+import * as configActions from './actions/config';
export {
Notification,
@@ -12,4 +13,5 @@ export {
I18n,
notificationActions,
authActions,
+ configActions
};
diff --git a/client/coral-framework/reducers/config.js b/client/coral-framework/reducers/config.js
index 6521d92a3..9620f5b97 100644
--- a/client/coral-framework/reducers/config.js
+++ b/client/coral-framework/reducers/config.js
@@ -1,19 +1,30 @@
/* @flow */
import {Map} from 'immutable';
-import * as actions from '../actions/items';
+import * as actions from '../actions/config';
const initialState = Map({
- features: Map({})
+ features: Map({}),
+ status: 'open'
});
export default (state = initialState, action) => {
switch(action.type) {
-
// Override config if worked
case actions.UPDATE_SETTINGS:
return action.config;
+ case actions.OPEN_COMMENTS:
+ return state.set('status', 'open');
+
+ case actions.CLOSE_COMMENTS:
+ return state.set('status', 'closed');
+
+ case actions.ADD_ITEM:
+ return action.item_type === 'assets' ?
+ state.set('status', action.item.status)
+ : state;
+
default:
return state;
}
diff --git a/models/asset.js b/models/asset.js
index 00251985a..165ebbc6c 100644
--- a/models/asset.js
+++ b/models/asset.js
@@ -34,7 +34,11 @@ const AssetSchema = new Schema({
subsection: String,
author: String,
publication_date: Date,
- modified_date: Date
+ modified_date: Date,
+ status: {
+ type: String,
+ default: 'open'
+ }
}, {
versionKey: false,
timestamps: {
diff --git a/routes/api/asset/index.js b/routes/api/asset/index.js
index 96b83a969..05926bc15 100644
--- a/routes/api/asset/index.js
+++ b/routes/api/asset/index.js
@@ -96,4 +96,12 @@ router.put('/:asset_id/settings', (req, res, next) => {
});
+router.put('/:asset_id/status', (req, res, next) => {
+ // Update the asset status
+ Asset
+ .update({id: req.params.asset_id}, {status: req.query.status})
+ .then(() => res.status(204).end())
+ .catch((err) => next(err));
+});
+
module.exports = router;