2019-06-08 08:35:43 +02:00
|
|
|
import {Config} from "data";
|
2019-06-09 22:30:33 +02:00
|
|
|
import {React} from "modules";
|
|
|
|
|
2019-06-08 08:35:43 +02:00
|
|
|
import PluginCard from "./plugincard";
|
2019-06-09 04:24:05 +02:00
|
|
|
import ThemeCard from "./themecard";
|
2019-06-04 16:21:07 +02:00
|
|
|
|
2019-06-08 08:35:43 +02:00
|
|
|
import SettingsGroup from "../settings/group";
|
2019-06-06 06:28:43 +02:00
|
|
|
import SettingsTitle from "./title";
|
2019-05-28 23:27:25 +02:00
|
|
|
|
2019-05-28 20:19:48 +02:00
|
|
|
export default class V2_SettingsPanel {
|
|
|
|
|
2019-06-09 22:30:33 +02:00
|
|
|
static buildSettingsPanel(title, config, state, onChange, button = null) {
|
2019-06-08 08:35:43 +02:00
|
|
|
config.forEach(section => {
|
|
|
|
section.settings.forEach(item => item.value = state[section.id][item.id]);
|
|
|
|
});
|
2019-06-09 22:30:33 +02:00
|
|
|
return this.getSettingsPanel(title, config, onChange, button);
|
2019-05-28 20:19:48 +02:00
|
|
|
}
|
|
|
|
|
2019-06-09 22:30:33 +02:00
|
|
|
static getSettingsPanel(title, groups, onChange, button = null) {
|
|
|
|
return [React.createElement(SettingsTitle, {text: title, button: button}), groups.map(section => {
|
2019-06-08 08:35:43 +02:00
|
|
|
return React.createElement(SettingsGroup, Object.assign({}, section, {onChange}));
|
2019-06-06 06:28:43 +02:00
|
|
|
})];
|
2019-06-05 06:30:24 +02:00
|
|
|
}
|
|
|
|
|
2019-06-09 22:30:33 +02:00
|
|
|
static getPluginsPanel(plugins, folder) {
|
|
|
|
const titleComponent = React.createElement(SettingsTitle, {text: "Plugins", button: {title: "Open Plugin Folder", onClick: () => { require("electron").shell.openItem(folder); }}});
|
2019-06-08 08:35:43 +02:00
|
|
|
const cards = plugins.sort((a, b) => a.name.toLowerCase().localeCompare(b.name.toLowerCase())).map(plugin =>
|
|
|
|
React.createElement(PluginCard, {key: plugin.id, content: plugin})
|
|
|
|
);
|
2019-06-09 04:24:05 +02:00
|
|
|
return [titleComponent, React.createElement("ul", {className: "bda-slist"}, ...cards)];
|
|
|
|
}
|
|
|
|
|
2019-06-09 22:30:33 +02:00
|
|
|
static getThemesPanel(themes, folder) {
|
|
|
|
const titleComponent = React.createElement(SettingsTitle, {text: "Themes", button: {title: "Open Theme Folder", onClick: () => { require("electron").shell.openItem(folder); }}});
|
2019-06-09 04:24:05 +02:00
|
|
|
const cards = themes.sort((a, b) => a.name.toLowerCase().localeCompare(b.name.toLowerCase())).map(theme =>
|
|
|
|
React.createElement(ThemeCard, {key: theme.id, content: theme})
|
|
|
|
);
|
|
|
|
return [titleComponent, React.createElement("ul", {className: "bda-slist"}, ...cards)];
|
2019-05-31 07:53:11 +02:00
|
|
|
}
|
|
|
|
|
2019-06-08 08:35:43 +02:00
|
|
|
static get attribution() {
|
2019-06-04 16:21:07 +02:00
|
|
|
return React.createElement(
|
|
|
|
"div",
|
|
|
|
{style: {fontSize: "12px", fontWeight: "600", color: "#72767d", padding: "2px 10px"}},
|
|
|
|
`BBD v${Config.bbdVersion} by `,
|
|
|
|
React.createElement(
|
|
|
|
"a",
|
|
|
|
{href: "https://github.com/rauenzi/", target: "_blank"},
|
|
|
|
"Zerebos"
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
2019-05-28 20:19:48 +02:00
|
|
|
}
|