mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 09:17:08 +08:00
FIX: Don't display staff-only options to non-staff in group member bulk menu (#19907)
In the group member bulk edit menu we are displaying staff-only options to non-staff. The requests are blocked by the back-end, so there is no harm other than to the user experience. Notably the individual user edit menu is correctly filtering out unavailable options. This change brings the bulk edit menu in line with that.
This commit is contained in:
parent
019ec74076
commit
90d452ab6c
|
@ -39,6 +39,7 @@ export default DropdownSelectBoxComponent.extend({
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.currentUser.staff) {
|
||||||
if (this.bulkSelection.some((m) => !m.primary)) {
|
if (this.bulkSelection.some((m) => !m.primary)) {
|
||||||
items.push({
|
items.push({
|
||||||
id: "setPrimary",
|
id: "setPrimary",
|
||||||
|
@ -56,6 +57,7 @@ export default DropdownSelectBoxComponent.extend({
|
||||||
icon: "id-card",
|
icon: "id-card",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return items;
|
return items;
|
||||||
}),
|
}),
|
||||||
|
|
|
@ -72,10 +72,9 @@ acceptance("Group Members", function (needs) {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("Shows bulk actions", async function (assert) {
|
test("Shows bulk actions as an admin user", async function (assert) {
|
||||||
await visit("/g/discourse");
|
await visit("/g/discourse");
|
||||||
|
|
||||||
assert.ok(exists("button.bulk-select"));
|
|
||||||
await click("button.bulk-select");
|
await click("button.bulk-select");
|
||||||
|
|
||||||
await click(queryAll("input.bulk-select")[0]);
|
await click(queryAll("input.bulk-select")[0]);
|
||||||
|
@ -83,7 +82,50 @@ acceptance("Group Members", function (needs) {
|
||||||
|
|
||||||
const memberDropdown = selectKit(".bulk-group-member-dropdown");
|
const memberDropdown = selectKit(".bulk-group-member-dropdown");
|
||||||
await memberDropdown.expand();
|
await memberDropdown.expand();
|
||||||
await memberDropdown.selectRowByValue("makeOwners");
|
|
||||||
|
assert.ok(
|
||||||
|
exists('[data-value="removeMembers"]'),
|
||||||
|
"it includes remove member option"
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.ok(
|
||||||
|
exists('[data-value="makeOwners"]'),
|
||||||
|
"it includes make owners option"
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.ok(
|
||||||
|
exists('[data-value="setPrimary"]'),
|
||||||
|
"it includes set primary option"
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("Shows bulk actions as a group owner", async function (assert) {
|
||||||
|
updateCurrentUser({ moderator: false, admin: false });
|
||||||
|
|
||||||
|
await visit("/g/discourse");
|
||||||
|
|
||||||
|
await click("button.bulk-select");
|
||||||
|
|
||||||
|
await click(queryAll("input.bulk-select")[0]);
|
||||||
|
await click(queryAll("input.bulk-select")[1]);
|
||||||
|
|
||||||
|
const memberDropdown = selectKit(".bulk-group-member-dropdown");
|
||||||
|
await memberDropdown.expand();
|
||||||
|
|
||||||
|
assert.ok(
|
||||||
|
exists('[data-value="removeMembers"]'),
|
||||||
|
"it includes remove member option"
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.ok(
|
||||||
|
exists('[data-value="makeOwners"]'),
|
||||||
|
"it includes make owners option"
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.notOk(
|
||||||
|
exists('[data-value="setPrimary"]'),
|
||||||
|
"it does not include set primary (staff only) option"
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("Bulk actions - Menu, Select all and Clear all buttons", async function (assert) {
|
test("Bulk actions - Menu, Select all and Clear all buttons", async function (assert) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user