mirror of
https://github.com/flarum/framework.git
synced 2024-11-28 20:16:08 +08:00
feat: extract notification primaryControl items to an ItemList (#3204)
This commit is contained in:
parent
77264be5e3
commit
8fa7ffa175
|
@ -5,6 +5,7 @@ import Button from '../../common/components/Button';
|
|||
import Link from '../../common/components/Link';
|
||||
import LoadingIndicator from '../../common/components/LoadingIndicator';
|
||||
import Discussion from '../../common/models/Discussion';
|
||||
import ItemList from '../../common/utils/ItemList';
|
||||
|
||||
/**
|
||||
* The `NotificationList` component displays a list of the logged-in user's
|
||||
|
@ -19,14 +20,7 @@ export default class NotificationList extends Component {
|
|||
<div className="NotificationList-header">
|
||||
<h4 className="App-titleControl App-titleControl--text">{app.translator.trans('core.forum.notifications.title')}</h4>
|
||||
|
||||
<div className="App-primaryControl">
|
||||
<Button
|
||||
className="Button Button--link"
|
||||
icon="fas fa-check"
|
||||
title={app.translator.trans('core.forum.notifications.mark_all_as_read_tooltip')}
|
||||
onclick={state.markAllAsRead.bind(state)}
|
||||
/>
|
||||
</div>
|
||||
<div className="App-primaryControl">{this.controlItems().toArray()}</div>
|
||||
</div>
|
||||
|
||||
<div className="NotificationList-content">{this.content(state)}</div>
|
||||
|
@ -34,6 +28,24 @@ export default class NotificationList extends Component {
|
|||
);
|
||||
}
|
||||
|
||||
controlItems() {
|
||||
const items = new ItemList();
|
||||
const state = this.attrs.state;
|
||||
|
||||
items.add(
|
||||
'mark_all_as_read',
|
||||
<Button
|
||||
className="Button Button--link"
|
||||
icon="fas fa-check"
|
||||
title={app.translator.trans('core.forum.notifications.mark_all_as_read_tooltip')}
|
||||
onclick={state.markAllAsRead.bind(state)}
|
||||
/>,
|
||||
70
|
||||
);
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
content(state) {
|
||||
if (state.isLoading()) {
|
||||
return <LoadingIndicator className="LoadingIndicator--block" />;
|
||||
|
|
Loading…
Reference in New Issue
Block a user