From 2a66dc5572d4545967005e6a046d9ae7e27ac21d Mon Sep 17 00:00:00 2001 From: David Sevilla Martin Date: Fri, 7 Feb 2020 09:35:44 -0500 Subject: [PATCH] forum: add DiscussionsUserPage component --- js/src/forum/Forum.ts | 3 ++- .../forum/components/DiscussionsUserPage.tsx | 27 +++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 js/src/forum/components/DiscussionsUserPage.tsx diff --git a/js/src/forum/Forum.ts b/js/src/forum/Forum.ts index 7c899c15f..60041cb67 100644 --- a/js/src/forum/Forum.ts +++ b/js/src/forum/Forum.ts @@ -9,6 +9,7 @@ import IndexPage from './components/IndexPage'; import DiscussionList from './components/DiscussionList'; import DiscussionPage from './components/DiscussionPage'; import PostsUserPage from './components/PostsUserPage'; +import DiscussionsUserPage from './components/DiscussionsUserPage'; import SettingsPage from './components/SettingsPage'; import CommentPost from './components/CommentPost'; @@ -26,7 +27,7 @@ export default class Forum extends Application { user: { path: '/u/:username', component: PostsUserPage }, 'user.posts': { path: '/u/:username', component: PostsUserPage }, - 'user.discussions': { path: '/u/:username/discussions', component: PostsUserPage }, + 'user.discussions': { path: '/u/:username/discussions', component: DiscussionsUserPage }, settings: { path: '/settings', component: SettingsPage }, diff --git a/js/src/forum/components/DiscussionsUserPage.tsx b/js/src/forum/components/DiscussionsUserPage.tsx new file mode 100644 index 000000000..97d2d31e3 --- /dev/null +++ b/js/src/forum/components/DiscussionsUserPage.tsx @@ -0,0 +1,27 @@ +import UserPage from './UserPage'; +import DiscussionList from './DiscussionList'; + +/** + * The `DiscussionsUserPage` component shows a discussion list inside of a user + * page. + */ +export default class DiscussionsUserPage extends UserPage { + oninit(vnode) { + super.oninit(vnode); + + this.loadUser(m.route.param('username')); + } + + content() { + return ( +
+ {DiscussionList.component({ + params: { + q: `author:${this.user.username()}`, + sort: 'newest', + }, + })} +
+ ); + } +}