Update RepoControls.plugin.js

This commit is contained in:
Mirco Wittrien 2020-03-24 15:46:41 +01:00
parent 7ca1d8c822
commit 9725f7a462
1 changed files with 40 additions and 40 deletions

View File

@ -6,7 +6,7 @@ var RepoControls = (_ => {
return class RepoControls { return class RepoControls {
getName () {return "RepoControls";} getName () {return "RepoControls";}
getVersion () {return "1.3.7";} getVersion () {return "1.3.8";}
getAuthor () {return "DevilBro";} getAuthor () {return "DevilBro";}
@ -15,10 +15,9 @@ var RepoControls = (_ => {
constructor () { constructor () {
this.patchedModules = { this.patchedModules = {
after: { after: {
V2C_List: "render", V2C_ContentColumn: "render",
V2C_PluginCard: "render", V2C_PluginCard: "render",
V2C_ThemeCard: "render", V2C_ThemeCard: "render",
V2C_ContentColumn: "render"
} }
}; };
} }
@ -136,7 +135,7 @@ var RepoControls = (_ => {
processV2CThemeCard (e) { processV2CThemeCard (e) {
if (!e.instance.props.RCdata) return; if (!e.instance.props.RCdata) return;
let [children, index] = BDFDB.ReactUtils.findChildren(e.returnvalue, {props: [["className", "bda-controls"]]}); let [children, index] = BDFDB.ReactUtils.findChildren(e.returnvalue, {props: [["className", BDFDB.disCN._repocontrols]]});
if (index > -1) { if (index > -1) {
let settings = BDFDB.DataUtils.get(this, "settings"); let settings = BDFDB.DataUtils.get(this, "settings");
if (settings.addDeleteButton) children[index].props.children.unshift(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TooltipContainer, { if (settings.addDeleteButton) children[index].props.children.unshift(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TooltipContainer, {
@ -172,7 +171,7 @@ var RepoControls = (_ => {
} }
}) })
})); }));
this.highlightSearchKey(e); this.highlightsearchKey(e);
} }
} }
@ -231,50 +230,51 @@ var RepoControls = (_ => {
})); }));
} }
sortEntries (instance, parent, searchkey = parent.props.searchkey) { sortEntries (instance, parent, searchKey = parent.props.searchKey) {
if (instance) instance = BDFDB.ReactUtils.findOwner(instance, {key: ["plugin-list", "theme-list"]}); if (instance) instance = BDFDB.ReactUtils.findOwner(instance, {key: ["plugin-list", "theme-list"]});
let sortings = BDFDB.DataUtils.get(this, "sortings"); let sortings = BDFDB.DataUtils.get(this, "sortings");
parent.props.searchkey = (searchkey || "").toUpperCase(); parent.props.searchKey = (searchKey || "").toUpperCase();
if (!parent.props.entries) parent.props.entries = parent.props.children; if (!parent.props.entries) parent.props.entries = parent.props.children;
let entries = [].concat(parent.props.entries); let entries = [].concat(parent.props.entries);
for (let i in entries) { for (let i in entries) {
let entry = entries[i]; let entry = BDFDB.ReactUtils.findChild(entries[i], {props: ["plugin", "theme"], someProps: true});
if (!entry.props.RCdata) { if (entry) {
entry.props.RCdata = {}; if (!entry.props.RCdata) {
if (entry.props.plugin) { entry.props.RCdata = {};
["name", "author", "version", "description"].forEach(key => { if (entry.props.plugin) {
let funcname = "get" + key.charAt(0).toUpperCase() + key.slice(1); ["name", "author", "version", "description"].forEach(key => {
let value = typeof entry.props.plugin[funcname] == "function" ? entry.props.plugin[funcname]() : ""; let funcName = "get" + BDFDB.LibraryModules.StringUtils.upperCaseFirstChar(key);
if (value) entry.props.RCdata[key] = value.toUpperCase().trim(); let value = typeof entry.props.plugin[funcName] == "function" ? entry.props.plugin[funcName]() : "";
else entry.props.RCdata[key] = ""; entry.props.RCdata[key] = value && value.toUpperCase().trim() || "";
}); });
entry.props.RCdata.type = "plugin"; entry.props.RCdata.type = "plugin";
entry.props.RCdata.enabled = BDFDB.BDUtils.isPluginEnabled(entry.key) ? 1 : 2; entry.props.RCdata.enabled = BDFDB.BDUtils.isPluginEnabled(entry.key) ? 1 : 2;
let loadedPlugin = BDFDB.BDUtils.getPlugin(entry.key, false, true); let loadedPlugin = BDFDB.BDUtils.getPlugin(entry.key, false, true);
entry.props.RCdata.path = loadedPlugin && typeof loadedPlugin.filename == "string" && BDFDB.LibraryRequires.path.join(BDFDB.BDUtils.getPluginsFolder(), loadedPlugin.filename); entry.props.RCdata.path = loadedPlugin && typeof loadedPlugin.filename == "string" && BDFDB.LibraryRequires.path.join(BDFDB.BDUtils.getPluginsFolder(), loadedPlugin.filename);
}
else if (entry.props.theme) {
["name", "author", "version", "description"].forEach(key => {
entry.props.RCdata[key] = entry.props.theme[key] && entry.props.theme[key].toUpperCase().trim() || "";
});
entry.props.RCdata.type = "theme";
entry.props.RCdata.enabled = BDFDB.BDUtils.isThemeEnabled(entry.key) ? 1 : 2;
let loadedTheme = BDFDB.BDUtils.getTheme(entry.key, false);
entry.props.RCdata.path = loadedTheme && typeof loadedTheme.filename == "string" && BDFDB.LibraryRequires.path.join(BDFDB.BDUtils.getThemesFolder(), loadedTheme.filename);
}
let stats = entry.props.RCdata.path && BDFDB.LibraryRequires.fs.statSync(entry.props.RCdata.path);
entry.props.RCdata.adddate = stats && stats.atime.getTime();
entry.props.RCdata.moddate = stats && stats.mtime.getTime();
entry.props.RCdata.search = [entry.props.RCdata.name, entry.props.RCdata.author, entry.props.RCdata.description].filter(n => n).join(" ");
} }
else if (entry.props.theme) { entry.props.RCdata.searchKey = parent.props.searchKey;
["name", "author", "version", "description"].forEach(key => { if (parent.props.searchKey && entry.props.RCdata.search.indexOf(parent.props.searchKey) == -1) entries[i] = null;
if (entry.props.theme[key]) entry.props.RCdata[key] = entry.props.theme[key].toUpperCase().trim(); else entries[i].props.RCdata = entry.props.RCdata;
else entry.props.RCdata[key] = "";
});
entry.props.RCdata.type = "theme";
entry.props.RCdata.enabled = BDFDB.BDUtils.isThemeEnabled(entry.key) ? 1 : 2;
let loadedTheme = BDFDB.BDUtils.getTheme(entry.key, false);
entry.props.RCdata.path = loadedTheme && typeof loadedTheme.filename == "string" && BDFDB.LibraryRequires.path.join(BDFDB.BDUtils.getThemesFolder(), loadedTheme.filename);
}
let stats = entry.props.RCdata.path && BDFDB.LibraryRequires.fs.statSync(entry.props.RCdata.path);
entry.props.RCdata.adddate = stats && stats.atime.getTime();
entry.props.RCdata.moddate = stats && stats.mtime.getTime();
entry.props.RCdata.search = [entry.props.RCdata.name, entry.props.RCdata.author, entry.props.RCdata.description].filter(n => n).join(" ");
} }
entry.props.RCdata.searchkey = parent.props.searchkey;
if (parent.props.searchkey && entry.props.RCdata.search.indexOf(parent.props.searchkey) == -1) entries[i] = null;
} }
let order = sortings.order == "asc" ? -1 : 1; let order = sortings.order == "asc" ? -1 : 1;
@ -290,13 +290,13 @@ var RepoControls = (_ => {
} }
} }
highlightSearchKey (e) { highlightsearchKey (e) {
if (!e.instance.props.RCdata.searchkey) return; if (!e.instance.props.RCdata.searchKey) return;
[BDFDB.disCN._reponame, BDFDB.disCN._repoauthor, BDFDB.disCN._repodescription].forEach(className => { [BDFDB.disCN._reponame, BDFDB.disCN._repoauthor, BDFDB.disCN._repodescription].forEach(className => {
let [children, index] = BDFDB.ReactUtils.findChildren(e.returnvalue, {props: [["className", className]]}); let [children, index] = BDFDB.ReactUtils.findChildren(e.returnvalue, {props: [["className", className]]});
if (index > -1) { if (index > -1) {
let originalText = BDFDB.StringUtils.htmlEscape(children[index].props.children); let originalText = BDFDB.StringUtils.htmlEscape(children[index].props.children);
let highlightedText = BDFDB.StringUtils.highlight(originalText, e.instance.props.RCdata.searchkey); let highlightedText = BDFDB.StringUtils.highlight(originalText, e.instance.props.RCdata.searchKey);
if (highlightedText != originalText) children[index].props.children = BDFDB.ReactUtils.elementToReact(BDFDB.DOMUtils.create(highlightedText)); if (highlightedText != originalText) children[index].props.children = BDFDB.ReactUtils.elementToReact(BDFDB.DOMUtils.create(highlightedText));
} }
}); });