mirror of
https://github.com/flarum/core.git
synced 2025-10-12 07:24:27 +02:00
- All custom JS variables are now preloaded into the `app.data` object, rather than directly on the `app` object. This means that admin settings are available in `app.data.settings` rather than `app.settings`, etc. - Cleaner route handler generation - Renamed ConfigureClientView to ConfigureWebApp, though the former still exists and is deprecated - Partial fix for #881 (strips ?nojs=1 from URL if possible, so that refreshing will attempt to load JS version again)
26 lines
770 B
JavaScript
26 lines
770 B
JavaScript
import SelectDropdown from 'flarum/components/SelectDropdown';
|
|
import Button from 'flarum/components/Button';
|
|
import saveSettings from 'flarum/utils/saveSettings';
|
|
|
|
export default class SettingDropdown extends SelectDropdown {
|
|
static initProps(props) {
|
|
super.initProps(props);
|
|
|
|
props.className = 'SettingDropdown';
|
|
props.buttonClassName = 'Button Button--text';
|
|
props.caretIcon = 'caret-down';
|
|
props.defaultLabel = 'Custom';
|
|
|
|
props.children = props.options.map(({value, label}) => {
|
|
const active = app.data.settings[props.key] === value;
|
|
|
|
return Button.component({
|
|
children: label,
|
|
icon: active ? 'check' : true,
|
|
onclick: saveSettings.bind(this, {[props.key]: value}),
|
|
active
|
|
});
|
|
});
|
|
}
|
|
}
|