FEATURE: add a param to exclude users by groups on the users directory page (#23067)
This commit is contained in:
parent
fb36af7799
commit
918be1dd63
|
@ -9,7 +9,15 @@ import { observes } from "discourse-common/utils/decorators";
|
||||||
|
|
||||||
export default Controller.extend({
|
export default Controller.extend({
|
||||||
application: controller(),
|
application: controller(),
|
||||||
queryParams: ["period", "order", "asc", "name", "group", "exclude_usernames"],
|
queryParams: [
|
||||||
|
"period",
|
||||||
|
"order",
|
||||||
|
"asc",
|
||||||
|
"name",
|
||||||
|
"group",
|
||||||
|
"exclude_usernames",
|
||||||
|
"exclude_groups",
|
||||||
|
],
|
||||||
period: "weekly",
|
period: "weekly",
|
||||||
order: "",
|
order: "",
|
||||||
asc: null,
|
asc: null,
|
||||||
|
@ -17,6 +25,7 @@ export default Controller.extend({
|
||||||
group: null,
|
group: null,
|
||||||
nameInput: null,
|
nameInput: null,
|
||||||
exclude_usernames: null,
|
exclude_usernames: null,
|
||||||
|
exclude_groups: null,
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
columns: null,
|
columns: null,
|
||||||
groupOptions: null,
|
groupOptions: null,
|
||||||
|
|
|
@ -12,6 +12,7 @@ export default DiscourseRoute.extend({
|
||||||
asc: { refreshModel: true },
|
asc: { refreshModel: true },
|
||||||
name: { refreshModel: false, replace: true },
|
name: { refreshModel: false, replace: true },
|
||||||
group: { refreshModel: true },
|
group: { refreshModel: true },
|
||||||
|
exclude_groups: { refreshModel: true },
|
||||||
exclude_usernames: { refreshModel: true },
|
exclude_usernames: { refreshModel: true },
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -28,6 +29,7 @@ export default DiscourseRoute.extend({
|
||||||
name: "",
|
name: "",
|
||||||
group: null,
|
group: null,
|
||||||
exclude_usernames: null,
|
exclude_usernames: null,
|
||||||
|
exclude_groups: null,
|
||||||
lastUpdatedAt: null,
|
lastUpdatedAt: null,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,9 @@ import {
|
||||||
} from "discourse/tests/helpers/qunit-helpers";
|
} from "discourse/tests/helpers/qunit-helpers";
|
||||||
import { test } from "qunit";
|
import { test } from "qunit";
|
||||||
import { click, triggerKeyEvent, visit } from "@ember/test-helpers";
|
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 () {
|
acceptance("User Directory", function () {
|
||||||
test("Visit Page", async function (assert) {
|
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) {
|
test("Visit With Group Filter", async function (assert) {
|
||||||
await visit("/u?group=trust_level_0");
|
await visit("/u?group=trust_level_0");
|
||||||
assert.ok(
|
assert.ok(
|
||||||
|
|
Loading…
Reference in New Issue