fix some enable/disable nonsense
This commit is contained in:
parent
8f08610d9d
commit
3e59cb66b8
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -61,8 +61,9 @@ export default new class V2_PublicServers {
|
|||
addButton() {
|
||||
if (this.guildPatch) return;
|
||||
const GuildList = webpackModules.find(m => m.default && m.default.displayName == "NavigableGuilds");
|
||||
if (!GuildList) Utils.warn("PublicServer", "Can't find GuildList component");
|
||||
this.guildPatch = Utils.monkeyPatch(GuildList, "default", {after: this._appendButton});
|
||||
const GuildListOld = webpackModules.findByDisplayName("Guilds");
|
||||
if (!GuildList && !GuildListOld) Utils.warn("PublicServer", "Can't find GuildList component");
|
||||
this.guildPatch = Utils.monkeyPatch(GuildList ? GuildList : GuildListOld.prototype, GuildList ? "default" : "render", {after: this._appendButton});
|
||||
this._appendButton();
|
||||
}
|
||||
|
||||
|
|
|
@ -86,10 +86,8 @@ export default class V2C_PluginCard extends BDV2.reactComponent {
|
|||
}
|
||||
|
||||
get settingsComponent() {
|
||||
const name = this.getString(this.props.addon.name);
|
||||
|
||||
try { this.settingsPanel = this.props.addon.plugin.getSettingsPanel(); }
|
||||
catch (err) { Utils.err("Plugins", "Unable to get settings panel for " + this.props.addon.name + ".", err); }
|
||||
catch (err) { Utils.err("Plugins", "Unable to get settings panel for " + this.name + ".", err); }
|
||||
|
||||
return BDV2.react.createElement("div", {className: "bd-card bd-addon-card settings-open ui-switch-item", ref: "cardNode"},
|
||||
BDV2.react.createElement("div", {style: {"float": "right", "cursor": "pointer"}, onClick: () => {
|
||||
|
@ -98,8 +96,8 @@ export default class V2C_PluginCard extends BDV2.reactComponent {
|
|||
}},
|
||||
BDV2.react.createElement(XSvg, null)
|
||||
),
|
||||
typeof this.settingsPanel === "object" && BDV2.react.createElement("div", {id: `plugin-settings-${name}`, className: "plugin-settings", ref: "settingspanel"}),
|
||||
typeof this.settingsPanel !== "object" && BDV2.react.createElement("div", {id: `plugin-settings-${name}`, className: "plugin-settings", ref: "settingspanel", dangerouslySetInnerHTML: {__html: this.settingsPanel}})
|
||||
typeof this.settingsPanel === "object" && BDV2.react.createElement("div", {id: `plugin-settings-${this.name}`, className: "plugin-settings", ref: "settingspanel"}),
|
||||
typeof this.settingsPanel !== "object" && BDV2.react.createElement("div", {id: `plugin-settings-${this.name}`, className: "plugin-settings", ref: "settingspanel", dangerouslySetInnerHTML: {__html: this.settingsPanel}})
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -167,25 +165,26 @@ export default class V2C_PluginCard extends BDV2.reactComponent {
|
|||
}
|
||||
|
||||
onChange() {
|
||||
this.props.toggle && this.props.toggle(this.props.addon.plugin ? this.props.addon.plugin.getName() || this.props.addon.name : this.props.addon.name);
|
||||
this.props.toggle && this.props.toggle(this.name);
|
||||
this.setState({checked: !this.state.checked});
|
||||
}
|
||||
|
||||
edit() {this.props.edit(this.props.addon.name);}
|
||||
delete() {this.props.remove(this.props.addon.name);}
|
||||
reload() {this.props.reload(this.props.addon.name);}
|
||||
edit() {this.props.edit(this.name);}
|
||||
delete() {this.props.remove(this.name);}
|
||||
reload() {this.props.reload(this.name);}
|
||||
|
||||
get name() {return this.getString(this.props.addon.plugin ? this.props.addon.plugin.getName() : this.props.addon.name);}
|
||||
get author() {return this.getString(this.props.addon.plugin ? this.props.addon.plugin.getAuthor() : this.props.addon.author);}
|
||||
get description() {return this.getString(this.props.addon.plugin ? this.props.addon.plugin.getDescription() : this.props.addon.description);}
|
||||
get version() {return this.getString(this.props.addon.plugin ? this.props.addon.plugin.getVersion() : this.props.addon.version);}
|
||||
|
||||
render() {
|
||||
if (this.state.settings) return this.settingsComponent;
|
||||
const name = this.getString(this.props.addon.plugin ? this.props.addon.plugin.getName() || this.props.addon.name : this.props.addon.name);
|
||||
const author = this.getString(this.props.addon.plugin ? this.props.addon.plugin.getAuthor() : this.props.addon.author);
|
||||
const description = this.getString(this.props.addon.plugin ? this.props.addon.plugin.getDescription() : this.props.addon.description);
|
||||
const version = this.getString(this.props.addon.plugin ? this.props.addon.plugin.getVersion() : this.props.addon.version);
|
||||
const {authorId, authorLink} = this.props.addon;
|
||||
|
||||
return BDV2.react.createElement("div", {className: "bd-card bd-addon-card settings-closed ui-switch-item"},
|
||||
BDV2.react.createElement("div", {className: "bd-addon-header bda-header"},
|
||||
BDV2.react.createElement("div", {className: "bd-card-title bda-header-title"}, this.buildTitle(name, version, {name: author, id: authorId, link: authorLink})),
|
||||
BDV2.react.createElement("div", {className: "bd-card-title bda-header-title"}, this.buildTitle(this.name, this.version, {name: this.author, id: authorId, link: authorLink})),
|
||||
BDV2.react.createElement("div", {className: "bd-addon-controls bda-controls"},
|
||||
this.props.edit && this.makeButton("Edit", <EditIcon className="bd-icon" />, this.edit),
|
||||
this.props.remove && this.makeButton("Delete", <DeleteIcon className="bd-icon" />, this.delete),
|
||||
|
@ -194,7 +193,7 @@ export default class V2C_PluginCard extends BDV2.reactComponent {
|
|||
)
|
||||
),
|
||||
BDV2.react.createElement("div", {className: "bd-scroller-wrap bda-description-wrap scroller-wrap fade"},
|
||||
BDV2.react.createElement("div", {className: "bd-scroller bd-addon-description bda-description scroller"}, description)
|
||||
BDV2.react.createElement("div", {className: "bd-scroller bd-addon-description bda-description scroller"}, this.description)
|
||||
),
|
||||
this.footer
|
||||
);
|
||||
|
|
|
@ -90,8 +90,8 @@ export default class CardList extends BDV2.reactComponent {
|
|||
|
||||
getProps(addon) {
|
||||
return {
|
||||
key: addon.name,
|
||||
enabled: this.cookie[addon.name],
|
||||
key: this.getName(addon),
|
||||
enabled: this.cookie[this.getName(addon)],
|
||||
toggle: this.manager.toggle.bind(this.manager),
|
||||
//edit: this.edit.bind(this),
|
||||
remove: this.delete.bind(this),
|
||||
|
@ -120,10 +120,10 @@ export default class CardList extends BDV2.reactComponent {
|
|||
const addon = sortedAddons[a];
|
||||
if (this.state.query) {
|
||||
let matches = null;
|
||||
const name = this.getString(addon.plugin ? addon.plugin.getName() || addon.name : addon.name);
|
||||
const author = this.getString(addon.plugin ? addon.plugin.getAuthor() : addon.author);
|
||||
const description = this.getString(addon.plugin ? addon.plugin.getDescription() : addon.description);
|
||||
const version = this.getString(addon.plugin ? addon.plugin.getVersion() : addon.version);
|
||||
const name = this.getName(addon);
|
||||
const author = this.getAuthor(addon);
|
||||
const description = this.getDescription(addon);
|
||||
const version = this.getVersion(addon);
|
||||
if (name) matches = name.toLocaleLowerCase().includes(this.state.query);
|
||||
if (author) matches = matches || author.toLocaleLowerCase().includes(this.state.query);
|
||||
if (description) matches = matches || description.toLocaleLowerCase().includes(this.state.query);
|
||||
|
@ -136,6 +136,11 @@ export default class CardList extends BDV2.reactComponent {
|
|||
return rendered;
|
||||
}
|
||||
|
||||
getName(addon) {return this.getString(addon.plugin ? addon.plugin.getName() : addon.name);}
|
||||
getAuthor(addon) {return this.getString(addon.plugin ? addon.plugin.getAuthor() : addon.author);}
|
||||
getDescription(addon) {return this.getString(addon.plugin ? addon.plugin.getDescription() : addon.description);}
|
||||
getVersion(addon) {return this.getString(addon.plugin ? addon.plugin.getVersion() : addon.version);}
|
||||
|
||||
render() {
|
||||
const refreshIcon = <Tooltip color="black" position="top" text="Reload List">
|
||||
{(props) =>
|
||||
|
|
Loading…
Reference in New Issue