mirror of
https://github.com/flarum/core.git
synced 2025-08-04 07:27:39 +02:00
feat: extract notification primaryControl items to an ItemList (#3204)
This commit is contained in:
@@ -5,6 +5,7 @@ import Button from '../../common/components/Button';
|
|||||||
import Link from '../../common/components/Link';
|
import Link from '../../common/components/Link';
|
||||||
import LoadingIndicator from '../../common/components/LoadingIndicator';
|
import LoadingIndicator from '../../common/components/LoadingIndicator';
|
||||||
import Discussion from '../../common/models/Discussion';
|
import Discussion from '../../common/models/Discussion';
|
||||||
|
import ItemList from '../../common/utils/ItemList';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The `NotificationList` component displays a list of the logged-in user's
|
* 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">
|
<div className="NotificationList-header">
|
||||||
<h4 className="App-titleControl App-titleControl--text">{app.translator.trans('core.forum.notifications.title')}</h4>
|
<h4 className="App-titleControl App-titleControl--text">{app.translator.trans('core.forum.notifications.title')}</h4>
|
||||||
|
|
||||||
<div className="App-primaryControl">
|
<div className="App-primaryControl">{this.controlItems().toArray()}</div>
|
||||||
<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>
|
</div>
|
||||||
|
|
||||||
<div className="NotificationList-content">{this.content(state)}</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) {
|
content(state) {
|
||||||
if (state.isLoading()) {
|
if (state.isLoading()) {
|
||||||
return <LoadingIndicator className="LoadingIndicator--block" />;
|
return <LoadingIndicator className="LoadingIndicator--block" />;
|
||||||
|
Reference in New Issue
Block a user