From 66c50547b4ef89969241a1f8d27bb4248ace6c07 Mon Sep 17 00:00:00 2001 From: Alan Guo Xiang Tan Date: Fri, 3 Mar 2023 09:46:21 +0800 Subject: [PATCH] DEV: Experimental /filter route to filter through topics (#20494) This commit introduces an experimental `/filter` route which allows a user to input a query string to filter through topics. Internal Ref: /t/92833 --- .../discourse/app/components/d-navigation.hbs | 43 +++++++++++----- .../discourse/app/components/d-navigation.js | 4 ++ .../app/controllers/discovery-sortable.js | 4 ++ .../dynamic-route-builders.js | 13 ++++- .../discourse/app/routes/app-route-map.js | 2 + .../discourse/app/routes/build-topic-route.js | 8 +++ .../stylesheets/common/components/_index.scss | 1 + .../common/components/topic-query-filter.scss | 10 ++++ app/controllers/list_controller.rb | 5 ++ config/locales/client.en.yml | 6 +++ config/routes.rb | 2 + config/site_settings.yml | 4 ++ lib/topic_query.rb | 38 ++++++-------- lib/topics_filter.rb | 51 +++++++++++++++++++ spec/lib/topics_filter_spec.rb | 49 ++++++++++++++++++ spec/requests/list_controller_spec.rb | 19 +++++++ spec/system/filtering_topics_spec.rb | 41 +++++++++++++++ .../page_objects/components/topic_list.rb | 18 ++++++- .../components/topic_query_filter.rb | 16 ++++++ 19 files changed, 297 insertions(+), 37 deletions(-) create mode 100644 app/assets/stylesheets/common/components/topic-query-filter.scss create mode 100644 lib/topics_filter.rb create mode 100644 spec/lib/topics_filter_spec.rb create mode 100644 spec/system/filtering_topics_spec.rb create mode 100644 spec/system/page_objects/components/topic_query_filter.rb diff --git a/app/assets/javascripts/discourse/app/components/d-navigation.hbs b/app/assets/javascripts/discourse/app/components/d-navigation.hbs index 9a33a368930..c328d2349f8 100644 --- a/app/assets/javascripts/discourse/app/components/d-navigation.hbs +++ b/app/assets/javascripts/discourse/app/components/d-navigation.hbs @@ -1,19 +1,36 @@ - +{{#if this.isQueryFilterMode}} +
+ -{{#unless this.additionalTags}} - {{! nav bar doesn't work with tag intersections }} - +
+{{else}} + -{{/unless}} + + {{#unless this.additionalTags}} + {{! nav bar doesn't work with tag intersections }} + + {{/unless}} +{{/if}}