Bye bye old code

This commit is contained in:
Chi Vinh Le
2018-02-26 22:38:43 +01:00
parent 0e2a49ef1f
commit 81026af3ee
8 changed files with 0 additions and 140 deletions
@@ -1,75 +0,0 @@
import * as actions from '../constants/asset';
import { notify } from 'coral-framework/actions/notification';
import t from 'coral-framework/services/i18n';
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 updateAssetSettingsRequest = () => ({
type: actions.UPDATE_ASSET_SETTINGS_REQUEST,
});
const updateAssetSettingsSuccess = settings => ({
type: actions.UPDATE_ASSET_SETTINGS_SUCCESS,
settings,
});
const updateAssetSettingsFailure = error => ({
type: actions.UPDATE_ASSET_SETTINGS_FAILURE,
error,
});
export const updateConfiguration = newConfig => (
dispatch,
getState,
{ rest }
) => {
const assetId = getState().asset.id;
dispatch(updateAssetSettingsRequest());
rest(`/assets/${assetId}/settings`, { method: 'PUT', body: newConfig })
.then(() => {
dispatch(notify('success', t('framework.success_update_settings')));
dispatch(updateAssetSettingsSuccess(newConfig));
})
.catch(error => {
console.error(error);
dispatch(updateAssetSettingsFailure(error));
});
};
export const updateOpenStream = closedBody => (
dispatch,
getState,
{ rest }
) => {
const assetId = getState().asset.id;
dispatch(fetchAssetRequest());
rest(`/assets/${assetId}/status`, { method: 'PUT', body: closedBody })
.then(() => {
dispatch(notify('success', t('framework.success_update_settings')));
dispatch(fetchAssetSuccess(closedBody));
})
.catch(error => {
console.error(error);
dispatch(fetchAssetFailure(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() }));
}
};
@@ -1,6 +0,0 @@
import { ADD_EXTERNAL_CONFIG } from '../constants/config';
export const addExternalConfig = config => ({
type: ADD_EXTERNAL_CONFIG,
config,
});
@@ -1,10 +0,0 @@
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_ASSET_SETTINGS_REQUEST = 'UPDATE_ASSET_SETTINGS_REQUEST';
export const UPDATE_ASSET_SETTINGS_SUCCESS = 'UPDATE_ASSET_SETTINGS_SUCCESS';
export const UPDATE_ASSET_SETTINGS_FAILURE = 'UPDATE_ASSET_SETTINGS_FAILURE';
export const OPEN_COMMENTS = 'OPEN_COMMENTS';
export const CLOSE_COMMENTS = 'CLOSE_COMMENTS';
@@ -1 +0,0 @@
export const ADD_EXTERNAL_CONFIG = 'ADD_EXTERNAL_CONFIG';
@@ -13,7 +13,6 @@ import {
hideSignInDialog,
} from '../actions/login';
import { updateStatus } from 'coral-framework/actions/auth';
import { fetchAssetSuccess } from '../actions/asset';
import {
getDefinitionName,
getSlotFragmentSpreads,
@@ -291,7 +290,6 @@ EmbedContainer.propTypes = {
activeTab: PropTypes.string,
parentUrl: PropTypes.string,
data: PropTypes.object,
fetchAssetSuccess: PropTypes.func,
showSignInDialog: PropTypes.bool,
signInDialogFocus: PropTypes.bool,
};
@@ -315,7 +313,6 @@ const mapDispatchToProps = dispatch =>
bindActionCreators(
{
setActiveTab,
fetchAssetSuccess,
notify,
focusSignInDialog,
blurSignInDialog,
@@ -1,28 +0,0 @@
import * as actions from '../constants/asset';
const initialState = {
closedAt: null,
settings: null,
title: null,
url: null,
features: {},
status: 'open',
moderation: null,
};
export default function asset(state = initialState, action) {
switch (action.type) {
case actions.FETCH_ASSET_SUCCESS:
return {
...state,
...action.asset,
};
case actions.UPDATE_ASSET_SETTINGS_SUCCESS:
return {
...state,
settings: action.settings,
};
default:
return state;
}
}
@@ -1,15 +0,0 @@
import { ADD_EXTERNAL_CONFIG } from '../constants/config';
const initialState = {};
export default function config(state = initialState, action) {
switch (action.type) {
case ADD_EXTERNAL_CONFIG:
return {
...state,
...action.config,
};
default:
return state;
}
}
@@ -1,5 +1,4 @@
import login from './login';
import asset from './asset';
import embed from './embed';
import configure from './configure';
import stream from './stream';
@@ -7,7 +6,6 @@ import profile from './profile';
export default {
login,
asset,
embed,
configure,
stream,