Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Extract primaryControl items to an ItemList #3204

Merged
merged 1 commit into from
Dec 14, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 20 additions & 8 deletions js/src/forum/components/NotificationList.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -19,21 +20,32 @@ 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>
</div>
);
}

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" />;
Expand Down