FIX: Hide footer action button when user cannot assign (#319)

This commit is contained in:
Natalie Tay 2022-04-26 15:00:00 +08:00 committed by GitHub
parent 3a147fcb88
commit 21d89179ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 1 deletions

View File

@ -174,7 +174,11 @@ function registerTopicFooterButtons(api) {
},
displayed() {
return !this.site.mobileView && this.topic.isAssigned();
return (
this.get("currentUser.can_assign") &&
!this.site.mobileView &&
this.topic.isAssigned()
);
},
});

View File

@ -78,6 +78,7 @@ acceptance("Discourse Assign | Assigned topic", function (needs) {
assign_enabled: true,
tagging_enabled: true,
assigns_user_url_path: "/",
assigns_public: true,
});
assignCurrentUserToTopic(needs);
@ -123,6 +124,16 @@ acceptance("Discourse Assign | Assigned topic", function (needs) {
"shows reassign dropdown at the bottom of the topic"
);
});
test("User without assign ability cannot see footer button", async (assert) => {
updateCurrentUser({ can_assign: false, admin: false, moderator: false });
await visit("/t/assignment-topic/45");
assert.notOk(
exists("#topic-footer-dropdown-reassign"),
"does not show reassign dropdown at the bottom of the topic"
);
});
});
acceptance("Discourse Assign | Re-assign topic", function (needs) {