Skip to content

Commit

Permalink
refactor(core): improve extensibility of IndexPage
Browse files Browse the repository at this point in the history
  • Loading branch information
DavideIadeluca committed Sep 17, 2024
1 parent b3366e4 commit 3f34802
Showing 1 changed file with 27 additions and 7 deletions.
34 changes: 27 additions & 7 deletions framework/core/js/src/forum/components/IndexPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,39 @@ export default class IndexPage<CustomAttrs extends IIndexPageAttrs = IIndexPageA
<nav className="IndexPage-nav sideNav">
<ul>{listItems(this.sidebarItems().toArray())}</ul>
</nav>
<div className="IndexPage-results sideNavOffset">
<div className="IndexPage-toolbar">
<ul className="IndexPage-toolbar-view">{listItems(this.viewItems().toArray())}</ul>
<ul className="IndexPage-toolbar-action">{listItems(this.actionItems().toArray())}</ul>
</div>
<DiscussionList state={app.discussions} />
</div>
<div className="IndexPage-results sideNavOffset">{this.contentItems().toArray()}</div>
</div>
</div>
</div>
);
}

contentItems(): ItemList<Mithril.Children> {
const items = new ItemList<Mithril.Children>();

items.add('toolbar', this.toolbarView(), 100);
items.add('discussionList', this.discussionListView(), 90);

return items;
}

toolbarView(): Mithril.Children {
return <div className="IndexPage-toolbar">{this.toolbarItems().toArray()}</div>;
}

discussionListView(): Mithril.Children {
return <DiscussionList state={app.discussions} />;
}

toolbarItems(): ItemList<Mithril.Children> {
const items = new ItemList<Mithril.Children>();

items.add('view', <ul className="IndexPage-toolbar-view">{listItems(this.viewItems().toArray())}</ul>, 100);
items.add('action', <ul className="IndexPage-toolbar-action">{listItems(this.actionItems().toArray())}</ul>, 90);

return items;
}

setTitle() {
app.setTitle(extractText(app.translator.trans('core.forum.index.meta_title_text')));
app.setTitleCount(0);
Expand Down

0 comments on commit 3f34802

Please sign in to comment.