BetterDiscordApp-rauenzi/src/ui/settings/addonlist.jsx

29 lines
1.3 KiB
React
Raw Normal View History

2019-06-26 21:23:07 +02:00
import {React, Settings, Strings} from "modules";
import SettingsTitle from "./title";
import PluginCard from "./plugincard";
import ThemeCard from "./themecard";
import ReloadIcon from "../icons/reload";
2019-06-27 22:18:40 +02:00
export default class AddonList extends React.Component {
reload() {
if (this.props.refreshList) this.props.refreshList();
this.forceUpdate();
}
render() {
2019-06-27 22:18:40 +02:00
const {title, folder, addonList, addonState, onChange, reload} = this.props;
2019-06-25 22:36:34 +02:00
const showReloadIcon = !Settings.get("settings", "addons", "autoReload");
2019-06-26 21:23:07 +02:00
const button = folder ? {title: Strings.Addons.openFolder.format({type: title}), onClick: () => {require("electron").shell.openItem(folder);}} : null;
return [
2019-06-15 04:11:19 +02:00
<SettingsTitle key="title" text={title} button={button} otherChildren={showReloadIcon && <ReloadIcon className="bd-reload" onClick={this.reload.bind(this)} />} />,
2019-06-27 22:18:40 +02:00
<ul key="addonList" className={"bd-slist"}>
{addonList.sort((a, b) => a.name.toLowerCase().localeCompare(b.name.toLowerCase())).map(addon => {
const CardType = addon.type ? PluginCard : ThemeCard;
return <CardType showReloadIcon={showReloadIcon} key={addon.id} enabled={addonState[addon.id]} addon={addon} onChange={onChange} reload={reload} />;
})}
</ul>
];
}
}