Skip to content

A platform for community discussion. Free, open, simple.

UX: Gate bulk "Delete Topics" on the delete capability, not staff (#42785)

Régis Hanola89f428bc2b9
diff --git a/frontend/discourse/app/components/bulk-select-topics-dropdown.gjs b/frontend/discourse/app/components/bulk-select-topics-dropdown.gjs
index 0f44aaf1ad9..e8d2397adca 100644
--- a/frontend/discourse/app/components/bulk-select-topics-dropdown.gjs
+++ b/frontend/discourse/app/components/bulk-select-topics-dropdown.gjs
@@ -189,7 +189,8 @@ export default class BulkSelectTopicsDropdown extends Component {
id: "delete-topics",
icon: "trash-can",
name: i18n("topic_bulk_actions.delete_topics.name"),
- visible: ({ currentUser }) => currentUser.staff,
+ visible: ({ currentUser }) =>
+ currentUser.can_delete_all_posts_and_topics,
},
];
diff --git a/frontend/discourse/tests/integration/components/bulk-select-topics-dropdown-test.gjs b/frontend/discourse/tests/integration/components/bulk-select-topics-dropdown-test.gjs
index c4fd5cfd370..f397d08a870 100644
--- a/frontend/discourse/tests/integration/components/bulk-select-topics-dropdown-test.gjs
+++ b/frontend/discourse/tests/integration/components/bulk-select-topics-dropdown-test.gjs
@@ -49,6 +49,7 @@ module("Integration | Component | BulkSelectTopicsDropdown", function (hooks) {
test("actions all topics can perform", async function (assert) {
this.currentUser.admin = true;
this.site.set("can_tag_topics", true);
+ this.currentUser.can_delete_all_posts_and_topics = true;
this.bulkSelectHelper = createBulkSelectHelper(this);
await render(
@@ -161,7 +162,7 @@ module("Integration | Component | BulkSelectTopicsDropdown", function (hooks) {
.doesNotExist();
});
- test("does not allow deleting topics if user is not staff", async function (assert) {
+ test("does not allow deleting topics if the user cannot delete all posts and topics", async function (assert) {
this.bulkSelectHelper = createBulkSelectHelper(this);
await render(
@@ -176,6 +177,22 @@ module("Integration | Component | BulkSelectTopicsDropdown", function (hooks) {
.doesNotExist();
});
+ test("allows deleting topics for a non-staff user who can delete all posts and topics", async function (assert) {
+ this.currentUser.can_delete_all_posts_and_topics = true;
+ this.bulkSelectHelper = createBulkSelectHelper(this);
+
+ await render(
+ <template>
+ <BulkSelectTopicsDropdown @bulkSelectHelper={{this.bulkSelectHelper}} />
+ </template>
+ );
+
+ await click(".bulk-select-topics-dropdown-trigger");
+ assert
+ .dom(".fk-d-menu__inner-content .dropdown-menu__item .delete-topics")
+ .exists();
+ });
+
test("does not allow unlisting or relisting PM topics", async function (assert) {
this.currentUser.admin = true;
this.bulkSelectHelper = createBulkSelectHelper(this, {
@@ -316,6 +333,7 @@ module("Integration | Component | BulkSelectTopicsDropdown", function (hooks) {
test("the delete description does not claim the deletion is permanent", async function (assert) {
this.currentUser.admin = true;
+ this.currentUser.can_delete_all_posts_and_topics = true;
this.bulkSelectHelper = createBulkSelectHelper(this);
await render(