diff --git a/framework/core/js/src/forum/components/DiscussionPage.js b/framework/core/js/src/forum/components/DiscussionPage.js
index 45944046e..cffc15ee6 100644
--- a/framework/core/js/src/forum/components/DiscussionPage.js
+++ b/framework/core/js/src/forum/components/DiscussionPage.js
@@ -69,36 +69,88 @@ export default class DiscussionPage extends Page {
}
view() {
- const discussion = this.discussion;
-
return (
-
- {discussion ? (
- [
- DiscussionHero.component({ discussion }),
-
-
-
- {PostStream.component({
- discussion,
- stream: this.stream,
- onPositionChange: this.positionChanged.bind(this),
- })}
-
-
,
- ]
- ) : (
-
- )}
-
+
{this.discussion ? this.pageContent().toArray() : this.loadingItems().toArray()}
);
}
+ /**
+ * List of components shown while the discussion is loading.
+ *
+ * @returns {ItemList}
+ */
+ loadingItems() {
+ const items = new ItemList();
+
+ items.add('spinner', , 100);
+
+ return items;
+ }
+
+ /**
+ * Function that renders the `sidebarItems` ItemList.
+ *
+ * @returns {import('mithril').Children}
+ */
+ sidebar() {
+ return (
+
+ );
+ }
+
+ /**
+ * Renders the discussion's hero.
+ *
+ * @returns {import('mithril').Children}
+ */
+ hero() {
+ return ;
+ }
+
+ /**
+ * List of items rendered as the main page content.
+ *
+ * @returns {ItemList}
+ */
+ pageContent() {
+ const items = new ItemList();
+
+ items.add('hero', this.hero(), 100);
+ items.add('main', {this.mainContent().toArray()}
, 10);
+
+ return items;
+ }
+
+ /**
+ * List of items rendered inside the main page content container.
+ *
+ * @returns {ItemList}
+ */
+ mainContent() {
+ const items = new ItemList();
+
+ items.add('sidebar', this.sidebar(), 100);
+
+ items.add(
+ 'poststream',
+
+ {PostStream.component({
+ discussion,
+ stream: this.stream,
+ onPositionChange: this.positionChanged.bind(this),
+ })}
+
,
+ 10
+ );
+
+ return items;
+ }
+
/**
* Load the discussion from the API or use the preloaded one.
*/