diff --git a/js/admin/src/components/BasicsPage.js b/js/admin/src/components/BasicsPage.js
index c3654d6cc..eb1b49918 100644
--- a/js/admin/src/components/BasicsPage.js
+++ b/js/admin/src/components/BasicsPage.js
@@ -4,6 +4,7 @@ import Select from 'flarum/components/Select';
import Button from 'flarum/components/Button';
import Alert from 'flarum/components/Alert';
import saveConfig from 'flarum/utils/saveConfig';
+import ItemList from 'flarum/utils/ItemList';
export default class BasicsPage extends Component {
constructor(...args) {
@@ -72,18 +73,12 @@ export default class BasicsPage extends Component {
Choose the page which users will first see when they visit your forum. If entering a custom value, use the path relative to the forum root.
,
- ,
-
+ this.homePageItems().toArray().map(({path, label}) =>
+
+ )
]
})}
@@ -120,6 +115,24 @@ export default class BasicsPage extends Component {
return this.fields.some(key => this.values[key]() !== config[key]);
}
+ /**
+ * Build a list of options for the default homepage. Each option must be an
+ * object with `path` and `label` properties.
+ *
+ * @return {ItemList}
+ * @public
+ */
+ homePageItems() {
+ const items = new ItemList();
+
+ items.add('allDiscussions', {
+ path: '/all',
+ label: 'All Discussions'
+ });
+
+ return items;
+ }
+
onsubmit(e) {
e.preventDefault();
diff --git a/js/forum/src/initializers/boot.js b/js/forum/src/initializers/boot.js
index 3ba967930..ada9b0965 100644
--- a/js/forum/src/initializers/boot.js
+++ b/js/forum/src/initializers/boot.js
@@ -24,14 +24,15 @@ export default function boot(app) {
// able to click on the 'back' button to go home, regardless of which page
// they started on.
const defaultRoute = app.forum.attribute('defaultRoute');
+ let defaultAction = 'index';
for (const i in app.routes) {
- if (app.routes[i].path === defaultRoute) {
- app.routes[i].path = '/';
- app.history.push(i, '/');
- }
+ if (app.routes[i].path === defaultRoute) defaultAction = i;
}
+ app.routes[defaultAction].path = '/';
+ app.history.push(defaultAction, '/');
+
m.startComputation();
m.mount(document.getElementById('app-navigation'), Navigation.component({className: 'App-backControl', drawer: true}));
diff --git a/src/Forum/ForumServiceProvider.php b/src/Forum/ForumServiceProvider.php
index 0edd323e6..2b2bb9317 100644
--- a/src/Forum/ForumServiceProvider.php
+++ b/src/Forum/ForumServiceProvider.php
@@ -63,7 +63,7 @@ class ForumServiceProvider extends ServiceProvider
$routes->get(
'/all',
'flarum.forum.index',
- $this->action('Flarum\Forum\Actions\IndexAction')
+ $defaultAction = $this->action('Flarum\Forum\Actions\IndexAction')
);
$routes->get(
@@ -129,11 +129,16 @@ class ForumServiceProvider extends ServiceProvider
event(new RegisterForumRoutes($routes));
$settings = $this->app->make('Flarum\Core\Settings\SettingsRepository');
+ $defaultRoute = $settings->get('default_route');
+
+ if (isset($routes->getRouteData()[0]['GET'][$defaultRoute])) {
+ $defaultAction = $routes->getRouteData()[0]['GET'][$defaultRoute];
+ }
$routes->get(
'/',
'flarum.forum.default',
- $routes->getRouteData()[0]['GET'][$settings->get('default_route')]
+ $defaultAction
);
}