mirror of
https://github.com/discourse/discourse.git
synced 2024-11-24 00:37:06 +08:00
FIX: Hide delete button if user cannot delete and/or flag a post (#11045)
* FIX: Hide delete button if user cannot delete and/or flag a post * Move canFlag conditional
This commit is contained in:
parent
1698b34d2b
commit
35cfca1f3f
|
@ -258,6 +258,7 @@ export default function transformPost(
|
|||
postAtts.showFlagDelete =
|
||||
!postAtts.canDelete &&
|
||||
postAtts.yours &&
|
||||
postAtts.canFlag &&
|
||||
currentUser &&
|
||||
!currentUser.staff;
|
||||
} else {
|
||||
|
|
|
@ -309,10 +309,14 @@ widgetTest(
|
|||
this.set("args", {
|
||||
canDeleteTopic: false,
|
||||
showFlagDelete: true,
|
||||
canFlag: true,
|
||||
});
|
||||
},
|
||||
|
||||
test(assert) {
|
||||
async test(assert) {
|
||||
await click(".show-more-actions");
|
||||
|
||||
assert.equal(find("button.create-flag").length, 1, `button is displayed`);
|
||||
assert.equal(find("button.delete").length, 1, `button is displayed`);
|
||||
assert.equal(
|
||||
find("button.delete").attr("title"),
|
||||
|
@ -350,10 +354,11 @@ widgetTest("delete post button", {
|
|||
template:
|
||||
'{{mount-widget widget="post" args=args deletePost=(action "deletePost")}}',
|
||||
beforeEach() {
|
||||
this.set("args", { canDelete: true });
|
||||
this.set("args", { canDelete: true, canFlag: true });
|
||||
this.on("deletePost", () => (this.deletePostCalled = true));
|
||||
},
|
||||
async test(assert) {
|
||||
await click(".show-more-actions");
|
||||
await click("button.delete");
|
||||
assert.ok(this.deletePostCalled, "it triggered the delete action");
|
||||
},
|
||||
|
@ -369,6 +374,29 @@ widgetTest(`delete post button - can't delete`, {
|
|||
},
|
||||
});
|
||||
|
||||
widgetTest(`delete post button - can't delete, can't flag`, {
|
||||
template: '{{mount-widget widget="post" args=args}}',
|
||||
beforeEach() {
|
||||
this.set("args", {
|
||||
canDeleteTopic: false,
|
||||
showFlagDelete: false,
|
||||
canFlag: false,
|
||||
});
|
||||
},
|
||||
test(assert) {
|
||||
assert.equal(
|
||||
find("button.delete").length,
|
||||
0,
|
||||
`delete button is not displayed`
|
||||
);
|
||||
assert.equal(
|
||||
find("button.create-flag").length,
|
||||
0,
|
||||
`flag button is not displayed`
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
widgetTest("recover post button", {
|
||||
template:
|
||||
'{{mount-widget widget="post" args=args recoverPost=(action "recoverPost")}}',
|
||||
|
|
Loading…
Reference in New Issue
Block a user