mirror of
https://github.com/flarum/framework.git
synced 2024-12-02 23:23:52 +08:00
Make avatar edit menu extensible
This commit is contained in:
parent
82dc0cdd7b
commit
3fcf8f3da5
|
@ -1,6 +1,9 @@
|
|||
import Component from 'flarum/component';
|
||||
import avatar from 'flarum/helpers/avatar';
|
||||
import icon from 'flarum/helpers/icon';
|
||||
import listItems from 'flarum/helpers/list-items';
|
||||
import ItemList from 'flarum/utils/item-list';
|
||||
import ActionButton from 'flarum/components/action-button';
|
||||
import LoadingIndicator from 'flarum/components/loading-indicator';
|
||||
|
||||
export default class AvatarEditor extends Component {
|
||||
|
@ -20,13 +23,32 @@ export default class AvatarEditor extends Component {
|
|||
m('a.dropdown-toggle[href=javascript:;][data-toggle=dropdown]', {onclick: this.quickUpload.bind(this)}, [
|
||||
this.loading() ? LoadingIndicator.component() : icon('pencil icon')
|
||||
]),
|
||||
m('ul.dropdown-menu', [
|
||||
m('li', m('a[href=javascript:;]', {onclick: this.upload.bind(this)}, [icon('upload icon'), ' Upload'])),
|
||||
m('li', m('a[href=javascript:;]', {onclick: this.remove.bind(this)}, [icon('times icon'), ' Remove']))
|
||||
])
|
||||
m('ul.dropdown-menu', listItems(this.controlItems().toArray()))
|
||||
]);
|
||||
}
|
||||
|
||||
controlItems() {
|
||||
var items = new ItemList();
|
||||
|
||||
items.add('upload',
|
||||
ActionButton.component({
|
||||
icon: 'upload',
|
||||
label: 'Upload',
|
||||
onclick: this.upload.bind(this)
|
||||
})
|
||||
);
|
||||
|
||||
items.add('remove',
|
||||
ActionButton.component({
|
||||
icon: 'times',
|
||||
label: 'Remove',
|
||||
onclick: this.remove.bind(this)
|
||||
})
|
||||
);
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
quickUpload(e) {
|
||||
if (!this.props.user.avatarUrl()) {
|
||||
e.preventDefault();
|
||||
|
|
Loading…
Reference in New Issue
Block a user