diff --git a/app/assets/javascripts/discourse/app/controllers/users.js b/app/assets/javascripts/discourse/app/controllers/users.js index 7201957ab36..98f16cb7d8a 100644 --- a/app/assets/javascripts/discourse/app/controllers/users.js +++ b/app/assets/javascripts/discourse/app/controllers/users.js @@ -9,7 +9,15 @@ import { observes } from "discourse-common/utils/decorators"; export default Controller.extend({ application: controller(), - queryParams: ["period", "order", "asc", "name", "group", "exclude_usernames"], + queryParams: [ + "period", + "order", + "asc", + "name", + "group", + "exclude_usernames", + "exclude_groups", + ], period: "weekly", order: "", asc: null, @@ -17,6 +25,7 @@ export default Controller.extend({ group: null, nameInput: null, exclude_usernames: null, + exclude_groups: null, isLoading: false, columns: null, groupOptions: null, diff --git a/app/assets/javascripts/discourse/app/routes/users.js b/app/assets/javascripts/discourse/app/routes/users.js index 77355b71dff..539021b4eb7 100644 --- a/app/assets/javascripts/discourse/app/routes/users.js +++ b/app/assets/javascripts/discourse/app/routes/users.js @@ -12,6 +12,7 @@ export default DiscourseRoute.extend({ asc: { refreshModel: true }, name: { refreshModel: false, replace: true }, group: { refreshModel: true }, + exclude_groups: { refreshModel: true }, exclude_usernames: { refreshModel: true }, }, @@ -28,6 +29,7 @@ export default DiscourseRoute.extend({ name: "", group: null, exclude_usernames: null, + exclude_groups: null, lastUpdatedAt: null, }); } diff --git a/app/assets/javascripts/discourse/tests/acceptance/users-test.js b/app/assets/javascripts/discourse/tests/acceptance/users-test.js index 2dfb845c5f0..cef5f5b7dbb 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/users-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/users-test.js @@ -6,6 +6,9 @@ import { } from "discourse/tests/helpers/qunit-helpers"; import { test } from "qunit"; import { click, triggerKeyEvent, visit } from "@ember/test-helpers"; +import pretender, { response } from "discourse/tests/helpers/create-pretender"; +import directoryFixtures from "discourse/tests/fixtures/directory-fixtures"; +import { cloneJSON } from "discourse-common/lib/object"; acceptance("User Directory", function () { test("Visit Page", async function (assert) { @@ -37,6 +40,24 @@ acceptance("User Directory", function () { ); }); + test("Visit With Group Exclusion", async function (assert) { + let queryParams; + + pretender.get("/directory_items", (request) => { + queryParams = request.queryParams; + + return response(cloneJSON(directoryFixtures["directory_items"])); + }); + + await visit("/u?exclude_groups=trust_level_0"); + + assert.strictEqual( + queryParams.exclude_groups, + "trust_level_0", + "includes the right query param in the API call" + ); + }); + test("Visit With Group Filter", async function (assert) { await visit("/u?group=trust_level_0"); assert.ok(