Skip to content

Commit dce2549

Browse files
[1.x] [extensibility] refactor(core): improve extensibility of IndexPage (#4045)
* refactor(core): improve extensibility of `IndexPage` * refactor(core): refactor the extensibility refactor
1 parent 306d0bc commit dce2549

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

framework/core/js/src/forum/components/IndexPage.tsx

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,19 +60,31 @@ export default class IndexPage<CustomAttrs extends IIndexPageAttrs = IIndexPageA
6060
<nav className="IndexPage-nav sideNav">
6161
<ul>{listItems(this.sidebarItems().toArray())}</ul>
6262
</nav>
63-
<div className="IndexPage-results sideNavOffset">
64-
<div className="IndexPage-toolbar">
65-
<ul className="IndexPage-toolbar-view">{listItems(this.viewItems().toArray())}</ul>
66-
<ul className="IndexPage-toolbar-action">{listItems(this.actionItems().toArray())}</ul>
67-
</div>
68-
<DiscussionList state={app.discussions} />
69-
</div>
63+
<div className="IndexPage-results sideNavOffset">{this.contentItems().toArray()}</div>
7064
</div>
7165
</div>
7266
</div>
7367
);
7468
}
7569

70+
contentItems(): ItemList<Mithril.Children> {
71+
const items = new ItemList<Mithril.Children>();
72+
73+
items.add('toolbar', <div className="IndexPage-toolbar">{this.toolbarItems().toArray()}</div>, 100);
74+
items.add('discussionList', <DiscussionList state={app.discussions} />, 90);
75+
76+
return items;
77+
}
78+
79+
toolbarItems(): ItemList<Mithril.Children> {
80+
const items = new ItemList<Mithril.Children>();
81+
82+
items.add('view', <ul className="IndexPage-toolbar-view">{listItems(this.viewItems().toArray())}</ul>, 100);
83+
items.add('action', <ul className="IndexPage-toolbar-action">{listItems(this.actionItems().toArray())}</ul>, 90);
84+
85+
return items;
86+
}
87+
7688
setTitle() {
7789
app.setTitle(extractText(app.translator.trans('core.forum.index.meta_title_text')));
7890
app.setTitleCount(0);

0 commit comments

Comments
 (0)