From ce1491e830293891ce0b12bd2a203e6dab31bd9f Mon Sep 17 00:00:00 2001 From: Vinoth Kannan Date: Fri, 29 May 2020 00:47:28 +0530 Subject: [PATCH] UX: remove `in:unpinned` filter from advanced search page. (#9911) --- .../discourse/app/components/search-advanced-options.js | 3 +-- config/locales/client.en.yml | 1 - lib/search.rb | 8 -------- spec/components/search_spec.rb | 7 +------ test/javascripts/acceptance/search-test.js | 2 -- 5 files changed, 2 insertions(+), 19 deletions(-) diff --git a/app/assets/javascripts/discourse/app/components/search-advanced-options.js b/app/assets/javascripts/discourse/app/components/search-advanced-options.js index a2f6fcfd6ac..1be07440d57 100644 --- a/app/assets/javascripts/discourse/app/components/search-advanced-options.js +++ b/app/assets/javascripts/discourse/app/components/search-advanced-options.js @@ -21,7 +21,7 @@ const REGEXP_MIN_POST_COUNT_PREFIX = /^min_post_count:/gi; const REGEXP_POST_TIME_PREFIX = /^(before|after):/gi; const REGEXP_TAGS_REPLACE = /(^(tags?:|#(?=[a-z0-9\-]+::tag))|::tag\s?$)/gi; -const REGEXP_IN_MATCH = /^(in|with):(posted|created|watching|tracking|bookmarks|first|pinned|unpinned|wiki|unseen|image)/gi; +const REGEXP_IN_MATCH = /^(in|with):(posted|created|watching|tracking|bookmarks|first|pinned|wiki|unseen|image)/gi; const REGEXP_SPECIAL_IN_LIKES_MATCH = /^in:likes/gi; const REGEXP_SPECIAL_IN_TITLE_MATCH = /^in:title/gi; const REGEXP_SPECIAL_IN_PERSONAL_MATCH = /^in:personal/gi; @@ -51,7 +51,6 @@ export default Component.extend({ this.inOptionsForAll = [ { name: I18n.t("search.advanced.filters.first"), value: "first" }, { name: I18n.t("search.advanced.filters.pinned"), value: "pinned" }, - { name: I18n.t("search.advanced.filters.unpinned"), value: "unpinned" }, { name: I18n.t("search.advanced.filters.wiki"), value: "wiki" }, { name: I18n.t("search.advanced.filters.images"), value: "images" } ]; diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 1d2615fd6bf..3c85e215fbc 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -2005,7 +2005,6 @@ en: bookmarks: I bookmarked first: are the very first post pinned: are pinned - unpinned: are not pinned seen: I read unseen: I've not read wiki: are wiki diff --git a/lib/search.rb b/lib/search.rb index 8d76057fc93..fa0a0d769d1 100644 --- a/lib/search.rb +++ b/lib/search.rb @@ -354,14 +354,6 @@ class Search posts.where("topics.pinned_at IS NOT NULL") end - advanced_filter(/^in:unpinned$/) do |posts| - if @guardian.user - posts.where("topics.pinned_at IS NOT NULL AND topics.id IN ( - SELECT topic_id FROM topic_users WHERE user_id = ? AND cleared_pinned_at IS NOT NULL - )", @guardian.user.id) - end - end - advanced_filter(/^in:wiki$/) do |posts, match| posts.where(wiki: true) end diff --git a/spec/components/search_spec.rb b/spec/components/search_spec.rb index 599ea3c5aa5..1df963bbf99 100644 --- a/spec/components/search_spec.rb +++ b/spec/components/search_spec.rb @@ -946,7 +946,7 @@ describe Search do describe 'Advanced search' do - it 'supports pinned and unpinned' do + it 'supports pinned' do topic = Fabricate(:topic) Fabricate(:post, raw: 'hi this is a test 123 123', topic: topic) _post = Fabricate(:post, raw: 'boom boom shake the room', topic: topic) @@ -957,11 +957,6 @@ describe Search do guardian = Guardian.new(user) expect(Search.execute('boom in:pinned').posts.length).to eq(1) - expect(Search.execute('boom in:unpinned', guardian: guardian).posts.length).to eq(0) - - topic.clear_pin_for(user) - - expect(Search.execute('boom in:unpinned', guardian: guardian).posts.length).to eq(1) end it 'supports wiki' do diff --git a/test/javascripts/acceptance/search-test.js b/test/javascripts/acceptance/search-test.js index 018e3a08c7e..f252bdc5d87 100644 --- a/test/javascripts/acceptance/search-test.js +++ b/test/javascripts/acceptance/search-test.js @@ -135,7 +135,6 @@ QUnit.test("Right filters are shown to anonymous users", async assert => { assert.ok(inSelector.rowByValue("first").exists()); assert.ok(inSelector.rowByValue("pinned").exists()); - assert.ok(inSelector.rowByValue("unpinned").exists()); assert.ok(inSelector.rowByValue("wiki").exists()); assert.ok(inSelector.rowByValue("images").exists()); @@ -161,7 +160,6 @@ QUnit.test("Right filters are shown to logged-in users", async assert => { assert.ok(inSelector.rowByValue("first").exists()); assert.ok(inSelector.rowByValue("pinned").exists()); - assert.ok(inSelector.rowByValue("unpinned").exists()); assert.ok(inSelector.rowByValue("wiki").exists()); assert.ok(inSelector.rowByValue("images").exists());