Move slot config to index

This commit is contained in:
Chi Vinh Le
2017-04-06 20:06:38 +07:00
parent 92146f326f
commit 025df1918d
3 changed files with 7 additions and 15 deletions
+4 -12
View File
@@ -3,12 +3,6 @@ import merge from 'lodash/merge';
import flatten from 'lodash/flatten';
import plugins from 'pluginsConfig';
const components = flatten(
plugins
.map(o => o.module.components)
.filter(o => o)
);
export const pluginReducers = merge(
...plugins
.filter(o => o.module.reducer)
@@ -19,11 +13,9 @@ export const pluginReducers = merge(
* Returns React Elements for given slot.
*/
export function getSlotElements(slot, props = {}) {
const components = flatten(plugins
.filter(o => o.module.slots[slot])
.map(o => o.module.slots[slot]));
return components
.map((component, i) => ({
component,
props: {...props, key: i},
}))
.filter(o => o.component.slot === slot)
.map(o => React.createElement(o.component, o.props));
.map((component, i) => React.createElement(component, {...props, key: i}));
}
@@ -10,8 +10,6 @@ const lang = new I18n(translations);
export default class RespectButton extends React.Component {
static slot = 'comment.detail';
handleClick = () => {
const {postRespect, showSignInDialog, deleteAction, commentId} = this.props;
const {me, comment} = this.props.data;
+3 -1
View File
@@ -1,4 +1,6 @@
import RespectButton from './containers/RespectButton';
export default {
components: [RespectButton]
slots: {
'comment.detail': [RespectButton],
}
};