mirror of
https://github.com/wassname/talk.git
synced 2026-09-09 11:38:08 +08:00
Merge branch 'master' into fix-install
This commit is contained in:
@@ -35,12 +35,9 @@ class ExtendableTabPanelContainer extends React.Component {
|
||||
|
||||
createPluginTabFactory = (props = this.props) => el => {
|
||||
return (
|
||||
<ExtendableTab
|
||||
tabId={el.type.talkPluginName}
|
||||
key={el.type.talkPluginName}
|
||||
>
|
||||
<ExtendableTab tabId={el.key} key={el.key}>
|
||||
{React.cloneElement(el, {
|
||||
active: props.activeTab === el.type.talkPluginName,
|
||||
active: props.activeTab === el.key,
|
||||
})}
|
||||
</ExtendableTab>
|
||||
);
|
||||
@@ -59,7 +56,7 @@ class ExtendableTabPanelContainer extends React.Component {
|
||||
|
||||
createPluginTabPane(el) {
|
||||
return (
|
||||
<TabPane tabId={el.type.talkPluginName} key={el.type.talkPluginName}>
|
||||
<TabPane tabId={el.key} key={el.key}>
|
||||
{el}
|
||||
</TabPane>
|
||||
);
|
||||
|
||||
@@ -136,6 +136,7 @@ export function t(key, ...replacements) {
|
||||
replacements.forEach((str, i) => {
|
||||
translation = translation.replace(new RegExp(`\\{${i}\\}`, 'g'), str);
|
||||
});
|
||||
|
||||
return translation;
|
||||
} else {
|
||||
console.warn(`${lang}.${key} and en.${key} language key not set`);
|
||||
|
||||
@@ -173,11 +173,30 @@ class PluginsService {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* This adds a consistent keying for the slot elements.
|
||||
* It uses the plugin name as the key. If the same plugin inserts
|
||||
* multiple elements it will append `.${noOfOccurence}` to the
|
||||
* key starting with the second element.
|
||||
*/
|
||||
const getKey = (() => {
|
||||
const map = {};
|
||||
return component => {
|
||||
if (map[component.talkPluginName] === undefined) {
|
||||
map[component.talkPluginName] = 0;
|
||||
} else {
|
||||
map[component.talkPluginName]++;
|
||||
}
|
||||
const i = map[component.talkPluginName];
|
||||
return `${component.talkPluginName}${i > 0 ? `.${i}` : ''}`;
|
||||
};
|
||||
})();
|
||||
|
||||
return (size > 0 ? slots.slice(0, size) : slots)
|
||||
.map((component, i) => ({
|
||||
.map(component => ({
|
||||
component,
|
||||
disabled: isDisabled(component),
|
||||
key: i,
|
||||
key: getKey(component),
|
||||
}))
|
||||
.filter(o => !o.disabled)
|
||||
.map(({ component, key }) =>
|
||||
|
||||
Reference in New Issue
Block a user