diff --git a/client/coral-configure/containers/ConfigureStreamContainer.js b/client/coral-configure/containers/ConfigureStreamContainer.js
index f55176d9c..dbdb11265 100644
--- a/client/coral-configure/containers/ConfigureStreamContainer.js
+++ b/client/coral-configure/containers/ConfigureStreamContainer.js
@@ -3,7 +3,7 @@ import {connect} from 'react-redux';
import {compose} from 'react-apollo';
import {I18n} from '../../coral-framework';
-import {updateOpenStatus, updateConfiguration} from '../../coral-framework/actions/config';
+import {updateOpenStatus, updateConfiguration} from '../../coral-framework/actions/asset';
import CloseCommentsInfo from '../components/CloseCommentsInfo';
import ConfigureCommentStream from '../components/ConfigureCommentStream';
@@ -15,7 +15,7 @@ class ConfigureStreamContainer extends Component {
super(props);
this.state = {
- premod: props.asset.settings.moderation.toLowerCase() === 'pre',
+ premod: props.asset.settings.moderation === 'PRE',
premodLinks: false
};
@@ -59,7 +59,7 @@ class ConfigureStreamContainer extends Component {
render () {
const status = this.props.asset.closedAt === null ? 'open' : 'closed';
-
+ console.log('state premod', this.state.premod)
return (
({
- config: state.config.toJS(),
asset: state.asset.toJS()
});
diff --git a/client/coral-embed-stream/src/Embed.js b/client/coral-embed-stream/src/Embed.js
index 95c5e8834..94912949d 100644
--- a/client/coral-embed-stream/src/Embed.js
+++ b/client/coral-embed-stream/src/Embed.js
@@ -182,7 +182,6 @@ class Embed extends Component {
}
const mapStateToProps = state => ({
- config: state.config.toJS(),
items: state.items.toJS(),
notification: state.notification.toJS(),
auth: state.auth.toJS(),
diff --git a/client/coral-framework/actions/asset.js b/client/coral-framework/actions/asset.js
index 3d734e505..b8474857c 100644
--- a/client/coral-framework/actions/asset.js
+++ b/client/coral-framework/actions/asset.js
@@ -1,5 +1,50 @@
import * as actions from '../constants/asset';
+import coralApi from '../helpers/response';
+import {addNotification} from '../actions/notification';
+
+import I18n from 'coral-framework/modules/i18n/i18n';
+import translations from './../translations';
+const lang = new I18n(translations);
export const fetchAssetRequest = () => ({type: actions.FETCH_ASSET_REQUEST});
export const fetchAssetSuccess = asset => ({type: actions.FETCH_ASSET_SUCCESS, asset});
export const fetchAssetFailure = error => ({type: actions.FETCH_ASSET_FAILURE, error});
+
+const updateConfigRequest = () => ({type: actions.UPDATE_CONFIG_REQUEST});
+const updateConfigSuccess = config => ({type: actions.UPDATE_CONFIG_SUCCESS, config});
+const updateConfigFailure = () => ({type: actions.UPDATE_CONFIG_FAILURE});
+
+export const updateConfiguration = newConfig => (dispatch, getState) => {
+ const assetId = getState().asset.toJS().id;
+ dispatch(updateConfigRequest());
+ coralApi(`/assets/${assetId}/settings`, {method: 'PUT', body: newConfig})
+ .then(() => {
+ dispatch(addNotification('success', lang.t('successUpdateSettings')));
+ dispatch(updateConfigSuccess(newConfig));
+ })
+ .catch(error => dispatch(updateConfigFailure(error)));
+};
+
+export const updateOpenStream = closedBody => (dispatch, getState) => {
+ const assetId = getState().asset.toJS().id;
+ dispatch(updateConfigRequest());
+ coralApi(`/assets/${assetId}/status`, {method: 'PUT', body: closedBody})
+ .then(() => {
+ dispatch(addNotification('success', lang.t('successUpdateSettings')));
+ dispatch(updateConfigSuccess(closedBody));
+ })
+ .catch(error => dispatch(updateConfigFailure(error)));
+};
+
+const openStream = () => ({type: actions.OPEN_COMMENTS});
+const closeStream = () => ({type: actions.CLOSE_COMMENTS});
+
+export const updateOpenStatus = status => dispatch => {
+ if (status === 'open') {
+ dispatch(openStream());
+ dispatch(updateOpenStream({closedAt: null}));
+ } else {
+ dispatch(closeStream());
+ dispatch(updateOpenStream({closedAt: new Date().getTime()}));
+ }
+};
diff --git a/client/coral-framework/actions/config.js b/client/coral-framework/actions/config.js
deleted file mode 100644
index 6dfba6dce..000000000
--- a/client/coral-framework/actions/config.js
+++ /dev/null
@@ -1,46 +0,0 @@
-import coralApi from '../helpers/response';
-import * as actions from '../constants/config';
-import {addNotification} from '../actions/notification';
-
-import I18n from 'coral-framework/modules/i18n/i18n';
-import translations from './../translations';
-const lang = new I18n(translations);
-
-const updateConfigRequest = () => ({type: actions.UPDATE_CONFIG_REQUEST});
-const updateConfigSuccess = config => ({type: actions.UPDATE_CONFIG_SUCCESS, config});
-const updateConfigFailure = () => ({type: actions.UPDATE_CONFIG_FAILURE});
-
-export const updateConfiguration = newConfig => (dispatch, getState) => {
- const assetId = getState().asset.toJS().id;
- dispatch(updateConfigRequest());
- coralApi(`/assets/${assetId}/settings`, {method: 'PUT', body: newConfig})
- .then(() => {
- dispatch(addNotification('success', lang.t('successUpdateSettings')));
- dispatch(updateConfigSuccess(newConfig));
- })
- .catch(error => dispatch(updateConfigFailure(error)));
-};
-
-export const updateOpenStream = closedBody => (dispatch, getState) => {
- const assetId = getState().asset.toJS().id;
- dispatch(updateConfigRequest());
- coralApi(`/assets/${assetId}/status`, {method: 'PUT', body: closedBody})
- .then(() => {
- dispatch(addNotification('success', lang.t('successUpdateSettings')));
- dispatch(updateConfigSuccess(closedBody));
- })
- .catch(error => dispatch(updateConfigFailure(error)));
-};
-
-const openStream = () => ({type: actions.OPEN_COMMENTS});
-const closeStream = () => ({type: actions.CLOSE_COMMENTS});
-
-export const updateOpenStatus = status => dispatch => {
- if (status === 'open') {
- dispatch(openStream());
- dispatch(updateOpenStream({closedAt: null}));
- } else {
- dispatch(closeStream());
- dispatch(updateOpenStream({closedAt: new Date().getTime()}));
- }
-};
diff --git a/client/coral-framework/constants/asset.js b/client/coral-framework/constants/asset.js
index 31cedb5e9..bfeb98441 100644
--- a/client/coral-framework/constants/asset.js
+++ b/client/coral-framework/constants/asset.js
@@ -1,3 +1,13 @@
export const FETCH_ASSET_REQUEST = 'FETCH_ASSET_REQUEST';
export const FETCH_ASSET_FAILURE = 'FETCH_ASSET_FAILURE';
export const FETCH_ASSET_SUCCESS = 'FETCH_ASSET_SUCCESS';
+
+export const UPDATE_CONFIG_REQUEST = 'UPDATE_CONFIG_REQUEST';
+export const UPDATE_CONFIG_SUCCESS = 'UPDATE_CONFIG_SUCCESS';
+export const UPDATE_CONFIG_FAILURE = 'UPDATE_CONFIG_FAILURE';
+
+export const UPDATE_CONFIG = 'UPDATE_CONFIG';
+
+export const OPEN_COMMENTS = 'OPEN_COMMENTS';
+export const CLOSE_COMMENTS = 'CLOSE_COMMENTS';
+export const ADD_ITEM = 'ADD_ITEM';
diff --git a/client/coral-framework/index.js b/client/coral-framework/index.js
index 6ab7c6325..81a0dc1c2 100644
--- a/client/coral-framework/index.js
+++ b/client/coral-framework/index.js
@@ -4,7 +4,6 @@ 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';
import * as assetActions from './actions/asset';
export {
@@ -14,6 +13,5 @@ export {
I18n,
notificationActions,
authActions,
- configActions,
assetActions
};
diff --git a/client/coral-framework/reducers/asset.js b/client/coral-framework/reducers/asset.js
index 1c6341c02..f530f5a3d 100644
--- a/client/coral-framework/reducers/asset.js
+++ b/client/coral-framework/reducers/asset.js
@@ -5,7 +5,10 @@ const initialState = Map({
closedAt: null,
settings: null,
title: null,
- url: null
+ url: null,
+ features: Map({}),
+ status: 'open',
+ moderation: null
});
export default function asset (state = initialState, action) {
@@ -13,7 +16,19 @@ export default function asset (state = initialState, action) {
case actions.FETCH_ASSET_SUCCESS :
return state
.merge(action.asset);
- default :
+ case actions.UPDATE_CONFIG:
+ return state
+ .merge(action.config);
+ case actions.UPDATE_CONFIG_SUCCESS:
+ return state
+ .merge(action.config);
+ case actions.OPEN_COMMENTS:
+ return state
+ .set('status', 'open');
+ case actions.CLOSE_COMMENTS:
+ return state
+ .set('status', 'closed');
+ default:
return state;
}
}
diff --git a/client/coral-framework/reducers/config.js b/client/coral-framework/reducers/config.js
deleted file mode 100644
index 362608d6d..000000000
--- a/client/coral-framework/reducers/config.js
+++ /dev/null
@@ -1,29 +0,0 @@
-import {Map} from 'immutable';
-import * as actions from '../constants/config';
-
-const initialState = Map({
- features: Map({}),
- status: 'open',
- moderation: null
-});
-
-export default (state = initialState, action) => {
- switch(action.type) {
- case actions.UPDATE_CONFIG:
- return state
- .merge(Map(action.config));
- case actions.UPDATE_CONFIG_SUCCESS:
- return state
- .merge(Map(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 && action.item.closedAt && new Date(action.item.closedAt).getTime() <= new Date().getTime()) ? 'closed' : 'open') : state;
- default:
- return state;
- }
-};
diff --git a/client/coral-framework/reducers/index.js b/client/coral-framework/reducers/index.js
index b16b8c01a..8c1457bfe 100644
--- a/client/coral-framework/reducers/index.js
+++ b/client/coral-framework/reducers/index.js
@@ -2,7 +2,6 @@ import auth from './auth';
import user from './user';
import asset from './asset';
import items from './items';
-import config from './config';
import notification from './notification';
export default {
@@ -10,6 +9,5 @@ export default {
user,
asset,
items,
- config,
notification
};