Use globally unique plugin ID for plugin cards with tabs (#1983)

Affects issues:
- Fixed #1982
This commit is contained in:
Emilia Dreamer 2021-07-06 20:08:21 +03:00 committed by GitHub
parent c4e5e3f1c7
commit d265d5b586
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 5 deletions

View File

@ -82,7 +82,8 @@ public class Contributors {
new Contributor("4drian3d", LANG), new Contributor("4drian3d", LANG),
new Contributor("\u6d1b\u4f0a", LANG), new Contributor("\u6d1b\u4f0a", LANG),
new Contributor("portlek", CODE), new Contributor("portlek", CODE),
new Contributor("mbax", CODE) new Contributor("mbax", CODE),
new Contributor("rymiel", CODE)
}; };
private Contributors() { private Contributors() {

View File

@ -26,9 +26,11 @@ import org.apache.commons.lang3.RegExUtils;
*/ */
public class TabsElement { public class TabsElement {
private final int pluginId;
private final Tab[] tabs; private final Tab[] tabs;
public TabsElement(Tab... tabs) { public TabsElement(int pluginId, Tab... tabs) {
this.pluginId = pluginId;
this.tabs = tabs; this.tabs = tabs;
} }
@ -45,7 +47,7 @@ public class TabsElement {
content.append("<div class=\"tab-content\">"); content.append("<div class=\"tab-content\">");
boolean first = true; boolean first = true;
for (Tab tab : tabs) { for (Tab tab : tabs) {
String id = tab.getId(); String id = tab.getId(pluginId);
String navHtml = tab.getNavHtml(); String navHtml = tab.getNavHtml();
String contentHtml = tab.getContentHtml(); String contentHtml = tab.getContentHtml();
@ -83,8 +85,8 @@ public class TabsElement {
return contentHtml; return contentHtml;
} }
public String getId() { public String getId(int pluginId) {
return "tab_" + RegExUtils.removeAll(title, "[^a-zA-Z0-9]*").toLowerCase(); return "tab_" + pluginId + "_" + RegExUtils.removeAll(title, "[^a-zA-Z0-9]*").toLowerCase();
} }
} }
} }

View File

@ -112,6 +112,7 @@ public class PlayerPluginTab implements Comparable<PlayerPluginTab> {
tabsElement = buildContentHtml(genericTabData); tabsElement = buildContentHtml(genericTabData);
} else { } else {
tabsElement = new TabsElement( tabsElement = new TabsElement(
datum.getPluginID(),
datum.getTabs().stream().map(this::wrapToTabElementTab).toArray(TabsElement.Tab[]::new) datum.getTabs().stream().map(this::wrapToTabElementTab).toArray(TabsElement.Tab[]::new)
).toHtmlFull(); ).toHtmlFull();
} }

View File

@ -112,6 +112,7 @@ public class ServerPluginTabs {
tabsElement = buildContentHtml(genericTabData); tabsElement = buildContentHtml(genericTabData);
} else { } else {
tabsElement = new TabsElement( tabsElement = new TabsElement(
datum.getPluginID(),
datum.getTabs().stream().map(this::wrapToTabElementTab).toArray(TabsElement.Tab[]::new) datum.getTabs().stream().map(this::wrapToTabElementTab).toArray(TabsElement.Tab[]::new)
).toHtmlFull(); ).toHtmlFull();
} }
@ -137,6 +138,7 @@ public class ServerPluginTabs {
tabsElement = buildContentHtml(genericTabData); tabsElement = buildContentHtml(genericTabData);
} else { } else {
tabsElement = new TabsElement( tabsElement = new TabsElement(
datum.getPluginID(),
datum.getTabs().stream().map(this::wrapToTabElementTab).toArray(TabsElement.Tab[]::new) datum.getTabs().stream().map(this::wrapToTabElementTab).toArray(TabsElement.Tab[]::new)
).toHtmlFull(); ).toHtmlFull();
} }