mirror of
https://github.com/flarum/framework.git
synced 2025-02-03 04:54:17 +08:00
Use SettingsModal component
This commit is contained in:
parent
2b99f051e4
commit
d5cc7494b0
|
@ -1,16 +1,6 @@
|
||||||
import Modal from 'flarum/components/Modal';
|
import SettingsModal from 'flarum/components/SettingsModal';
|
||||||
import Button from 'flarum/components/Button';
|
|
||||||
import saveConfig from 'flarum/utils/saveConfig';
|
|
||||||
|
|
||||||
export default class PusherSettingsModal extends Modal {
|
|
||||||
constructor(...args) {
|
|
||||||
super(...args);
|
|
||||||
|
|
||||||
this.appId = m.prop(app.config['pusher.app_id'] || '');
|
|
||||||
this.appKey = m.prop(app.config['pusher.app_key'] || '');
|
|
||||||
this.appSecret = m.prop(app.config['pusher.app_secret'] || '');
|
|
||||||
}
|
|
||||||
|
|
||||||
|
export default class PusherSettingsModal extends SettingsModal {
|
||||||
className() {
|
className() {
|
||||||
return 'PusherSettingsModal Modal--small';
|
return 'PusherSettingsModal Modal--small';
|
||||||
}
|
}
|
||||||
|
@ -19,53 +9,22 @@ export default class PusherSettingsModal extends Modal {
|
||||||
return 'Pusher Settings';
|
return 'Pusher Settings';
|
||||||
}
|
}
|
||||||
|
|
||||||
content() {
|
form() {
|
||||||
return (
|
return [
|
||||||
<div className="Modal-body">
|
<div className="Form-group">
|
||||||
<div className="Form">
|
<label>App ID</label>
|
||||||
<div className="Form-group">
|
<input className="FormControl" bidi={this.setting('pusher.app_id')}/>
|
||||||
<label>App ID</label>
|
</div>,
|
||||||
<input className="FormControl" value={this.appId()} oninput={m.withAttr('value', this.appId)}/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="Form-group">
|
<div className="Form-group">
|
||||||
<label>App Key</label>
|
<label>App Key</label>
|
||||||
<input className="FormControl" value={this.appKey()} oninput={m.withAttr('value', this.appKey)}/>
|
<input className="FormControl" bidi={this.setting('pusher.app_key')}/>
|
||||||
</div>
|
</div>,
|
||||||
|
|
||||||
<div className="Form-group">
|
<div className="Form-group">
|
||||||
<label>App Secret</label>
|
<label>App Secret</label>
|
||||||
<input className="FormControl" value={this.appSecret()} oninput={m.withAttr('value', this.appSecret)}/>
|
<input className="FormControl" bidi={this.setting('pusher.app_secret')}/>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="Form-group">
|
|
||||||
{Button.component({
|
|
||||||
type: 'submit',
|
|
||||||
className: 'Button Button--primary PusherSettingsModal-save',
|
|
||||||
loading: this.loading,
|
|
||||||
children: 'Save Changes'
|
|
||||||
})}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
];
|
||||||
}
|
|
||||||
|
|
||||||
onsubmit(e) {
|
|
||||||
e.preventDefault();
|
|
||||||
|
|
||||||
this.loading = true;
|
|
||||||
|
|
||||||
saveConfig({
|
|
||||||
'pusher.app_id': this.appId(),
|
|
||||||
'pusher.app_key': this.appKey(),
|
|
||||||
'pusher.app_secret': this.appSecret()
|
|
||||||
}).then(
|
|
||||||
() => this.hide(),
|
|
||||||
() => {
|
|
||||||
this.loading = false;
|
|
||||||
m.redraw();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user