From dfd880d4b30891a8a8fc6bb7f50e5182a4dd4b4e Mon Sep 17 00:00:00 2001 From: Mehak Nasir Date: Tue, 8 Nov 2022 15:12:38 +0500 Subject: [PATCH] feat: add unresponded posts filter --- src/discussions/posts/PostsView.test.jsx | 2 +- src/discussions/posts/data/thunks.js | 3 +++ .../posts/post-filter-bar/PostFilterBar.jsx | 10 ++++++++++ src/discussions/posts/post-filter-bar/messages.js | 2 +- 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/discussions/posts/PostsView.test.jsx b/src/discussions/posts/PostsView.test.jsx index 85357b5e..b7e62538 100644 --- a/src/discussions/posts/PostsView.test.jsx +++ b/src/discussions/posts/PostsView.test.jsx @@ -197,7 +197,7 @@ describe('PostsView', () => { // 5 status filters: any, unread, following, reported, unanswered // 3 sort: activity, comments, likes // 2 cohort: all groups, 1 api mock response cohort - expect(screen.queryAllByRole('radio')).toHaveLength(13); + expect(screen.queryAllByRole('radio')).toHaveLength(14); }); test('test that the cohorts filter works', async () => { diff --git a/src/discussions/posts/data/thunks.js b/src/discussions/posts/data/thunks.js index 9599d3c6..04269def 100644 --- a/src/discussions/posts/data/thunks.js +++ b/src/discussions/posts/data/thunks.js @@ -120,6 +120,9 @@ export function fetchThreads(courseId, { if (filters.status === PostsStatusFilter.UNANSWERED) { options.view = 'unanswered'; } + if (filters.status === PostsStatusFilter.UNRESPONDED) { + options.view = 'unresponded'; + } if (filters.status === PostsStatusFilter.REPORTED) { options.flagged = true; } diff --git a/src/discussions/posts/post-filter-bar/PostFilterBar.jsx b/src/discussions/posts/post-filter-bar/PostFilterBar.jsx index 8e2f7639..fca4f881 100644 --- a/src/discussions/posts/post-filter-bar/PostFilterBar.jsx +++ b/src/discussions/posts/post-filter-bar/PostFilterBar.jsx @@ -95,6 +95,10 @@ function PostFilterBar({ // You can't filter discussions by unanswered so switch type to questions dispatch(setPostsTypeFilter(ThreadType.QUESTION)); } + if (value === PostsStatusFilter.UNRESPONDED && currentType !== ThreadType.DISCUSSION) { + // You can't filter questions by not responded so switch type to discussion + dispatch(setPostsTypeFilter(ThreadType.DISCUSSION)); + } } if (name === 'sort') { dispatch(setSortedBy(value)); @@ -200,6 +204,12 @@ function PostFilterBar({ value={PostsStatusFilter.UNANSWERED} selected={currentFilters.status} /> +