mirror of
https://github.com/wassname/talk.git
synced 2026-07-10 17:08:48 +08:00
Move slot config to index
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import RespectButton from './containers/RespectButton';
|
||||
export default {
|
||||
components: [RespectButton]
|
||||
slots: {
|
||||
'comment.detail': [RespectButton],
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user