Commit 7039672c authored by Marcelo Rivera's avatar Marcelo Rivera

(feat): edit and delete comment permissions

No related merge requests found
Pipeline #85177929 failed with stages
in 7 minutes
......@@ -60,11 +60,7 @@
<ul class="m-comment__ribbon" [hidden]="!toggle.value" #toggle>
<li
class="m-commentRibbon__item"
*ngIf="
comment.owner_guid == session.getLoggedInUser()?.guid ||
session.isAdmin() ||
canEdit
"
*ngIf="checkEditPermissions()"
(click)="editing = !editing; toggle.value = false"
title="Edit"
i18n-title="@@M__ACTION__EDIT"
......@@ -82,12 +78,7 @@
</li>
<li
class="m-commentRibbon__item"
*ngIf="
comment.owner_guid == session.getLoggedInUser()?.guid ||
session.isAdmin() ||
parent.owner_guid == session.getLoggedInUser()?.guid ||
canDelete
"
*ngIf="checkDeletePermissions()"
(click)="delete(); toggle.value = false"
title="Delete"
i18n-title="@@M__ACTION__DELETE"
......
......@@ -32,6 +32,7 @@ import { FeaturesService } from '../../../services/features.service';
import { MindsVideoComponent } from '../../media/components/video/video.component';
import { MediaModalComponent } from '../../media/modal/modal.component';
import isMobile from '../../../helpers/is-mobile';
import { PermissionsService } from '../../../common/services/permissions.service';
@Component({
selector: 'm-comment',
......@@ -105,7 +106,8 @@ export class CommentComponentV2
private el: ElementRef,
private router: Router,
protected activityService: ActivityService,
protected featuresService: FeaturesService
protected featuresService: FeaturesService,
protected permissionsService: PermissionsService
) {}
ngOnInit() {
......@@ -380,4 +382,32 @@ export class CommentComponentV2
})
.present();
}
checkEditPermissions() {
if (this.featuresService.has('permissions')) {
return this.permissionsService.canInteract(this.comment, 'edit_comment');
}
return (
this.comment.owner_guid == this.session.getLoggedInUser().guid ||
this.session.isAdmin() ||
this.canEdit
);
}
checkDeletePermissions() {
if (this.featuresService.has('permissions')) {
return this.permissionsService.canInteract(
this.comment,
'delete_comment'
);
}
return (
this.comment.owner_guid == this.session.getLoggedInUser().guid ||
this.session.isAdmin() ||
this.parent.owner_guid == this.session.getLoggedInUser().guid ||
this.canDelete
);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment