FIX: Show perma-delete in menu without refresh (#14740)
It needed a page refresh because the post was not updated on the client side.
This commit is contained in:
parent
911f9b180a
commit
42f65b4c48
|
@ -53,7 +53,7 @@ export function transformBasicPost(post) {
|
||||||
created_at: post.created_at,
|
created_at: post.created_at,
|
||||||
updated_at: post.updated_at,
|
updated_at: post.updated_at,
|
||||||
canDelete: post.can_delete,
|
canDelete: post.can_delete,
|
||||||
canPermanentlyDelete: post.can_permanently_delete,
|
canPermanentlyDelete: false,
|
||||||
showFlagDelete: false,
|
showFlagDelete: false,
|
||||||
canRecover: post.can_recover,
|
canRecover: post.can_recover,
|
||||||
canEdit: post.can_edit,
|
canEdit: post.can_edit,
|
||||||
|
@ -264,7 +264,8 @@ export default function transformPost(
|
||||||
postAtts.canRecoverTopic = postAtts.isDeleted && details.can_recover;
|
postAtts.canRecoverTopic = postAtts.isDeleted && details.can_recover;
|
||||||
postAtts.canDeleteTopic = !postAtts.isDeleted && details.can_delete;
|
postAtts.canDeleteTopic = !postAtts.isDeleted && details.can_delete;
|
||||||
postAtts.expandablePost = topic.expandable_first_post;
|
postAtts.expandablePost = topic.expandable_first_post;
|
||||||
postAtts.canPermanentlyDeleteTopic = details.can_permanently_delete;
|
postAtts.canPermanentlyDelete =
|
||||||
|
postAtts.isDeleted && details.can_permanently_delete;
|
||||||
|
|
||||||
// Show a "Flag to delete" message if not staff and you can't
|
// Show a "Flag to delete" message if not staff and you can't
|
||||||
// otherwise delete it.
|
// otherwise delete it.
|
||||||
|
@ -281,6 +282,8 @@ export default function transformPost(
|
||||||
!post.deleted_at &&
|
!post.deleted_at &&
|
||||||
currentUser &&
|
currentUser &&
|
||||||
(currentUser.staff || !post.user_deleted);
|
(currentUser.staff || !post.user_deleted);
|
||||||
|
postAtts.canPermanentlyDelete =
|
||||||
|
postAtts.isDeleted && post.can_permanently_delete;
|
||||||
}
|
}
|
||||||
|
|
||||||
_additionalAttributes.forEach((a) => (postAtts[a] = post[a]));
|
_additionalAttributes.forEach((a) => (postAtts[a] = post[a]));
|
||||||
|
|
|
@ -208,6 +208,8 @@ const Post = RestModel.extend({
|
||||||
deleted_at: new Date(),
|
deleted_at: new Date(),
|
||||||
deleted_by: deletedBy,
|
deleted_by: deletedBy,
|
||||||
can_delete: false,
|
can_delete: false,
|
||||||
|
can_permanently_delete:
|
||||||
|
this.siteSettings.can_permanently_delete && deletedBy.admin,
|
||||||
can_recover: true,
|
can_recover: true,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
@ -219,6 +221,7 @@ const Post = RestModel.extend({
|
||||||
this.setProperties({
|
this.setProperties({
|
||||||
cooked: cooked,
|
cooked: cooked,
|
||||||
can_delete: false,
|
can_delete: false,
|
||||||
|
can_permanently_delete: false,
|
||||||
version: this.version + 1,
|
version: this.version + 1,
|
||||||
can_recover: true,
|
can_recover: true,
|
||||||
can_edit: false,
|
can_edit: false,
|
||||||
|
|
|
@ -451,6 +451,8 @@ const Topic = RestModel.extend({
|
||||||
deleted_by,
|
deleted_by,
|
||||||
"details.can_delete": false,
|
"details.can_delete": false,
|
||||||
"details.can_recover": true,
|
"details.can_recover": true,
|
||||||
|
"details.can_permanently_delete":
|
||||||
|
this.siteSettings.can_permanently_delete && deleted_by.admin,
|
||||||
});
|
});
|
||||||
if (!deleted_by.staff) {
|
if (!deleted_by.staff) {
|
||||||
DiscourseURL.redirectTo("/");
|
DiscourseURL.redirectTo("/");
|
||||||
|
|
|
@ -37,7 +37,7 @@ export function buildManageButtons(attrs, currentUser, siteSettings) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (attrs.canPermanentlyDelete || attrs.canPermanentlyDeleteTopic) {
|
if (attrs.canPermanentlyDelete) {
|
||||||
contents.push({
|
contents.push({
|
||||||
icon: "trash-alt",
|
icon: "trash-alt",
|
||||||
className: "popup-menu-button permanently-delete",
|
className: "popup-menu-button permanently-delete",
|
||||||
|
|
|
@ -656,7 +656,7 @@ discourseModule("Integration | Component | Widget | post", function (hooks) {
|
||||||
componentTest("permanently delete topic", {
|
componentTest("permanently delete topic", {
|
||||||
template: hbs`{{mount-widget widget="post" args=args permanentlyDeletePost=permanentlyDeletePost}}`,
|
template: hbs`{{mount-widget widget="post" args=args permanentlyDeletePost=permanentlyDeletePost}}`,
|
||||||
beforeEach() {
|
beforeEach() {
|
||||||
this.set("args", { canManage: true, canPermanentlyDeleteTopic: true });
|
this.set("args", { canManage: true, canPermanentlyDelete: true });
|
||||||
this.set("permanentlyDeletePost", () => (this.deleted = true));
|
this.set("permanentlyDeletePost", () => (this.deleted = true));
|
||||||
},
|
},
|
||||||
async test(assert) {
|
async test(assert) {
|
||||||
|
|
|
@ -1676,6 +1676,7 @@ security:
|
||||||
hidden: true
|
hidden: true
|
||||||
can_permanently_delete:
|
can_permanently_delete:
|
||||||
default: false
|
default: false
|
||||||
|
client: true
|
||||||
hidden: true
|
hidden: true
|
||||||
|
|
||||||
onebox:
|
onebox:
|
||||||
|
|
Loading…
Reference in New Issue