mirror of
https://github.com/flarum/core.git
synced 2025-08-13 11:54:32 +02:00
forum: remove 'controls' from user, moderation, and destructive controls in util
This commit is contained in:
@@ -43,7 +43,7 @@ export default class Discussion extends Model {
|
||||
*
|
||||
* @param id The ID of the post to remove.
|
||||
*/
|
||||
removePost(id: number) {
|
||||
removePost(id: string) {
|
||||
const relationships = this.data.relationships;
|
||||
const posts = relationships && relationships.posts;
|
||||
|
||||
@@ -88,7 +88,7 @@ export default class Discussion extends Model {
|
||||
* Get a list of all of the post IDs in this discussion.
|
||||
*/
|
||||
postIds(): string[] {
|
||||
const posts = this.data.relationships.posts;
|
||||
const posts = this.data.relationships?.posts;
|
||||
|
||||
return posts ? posts.data.map(link => link.id) : [];
|
||||
}
|
||||
|
@@ -21,7 +21,7 @@ export default {
|
||||
* be displayed
|
||||
* @public
|
||||
*/
|
||||
controls(discussion: Discussion, context): ItemList {
|
||||
controls(discussion: Discussion, context: any): ItemList {
|
||||
const items = new ItemList();
|
||||
|
||||
['user', 'moderation', 'destructive'].forEach(section => {
|
||||
@@ -83,7 +83,7 @@ export default {
|
||||
* be displayed.
|
||||
* @protected
|
||||
*/
|
||||
moderation(discussion): ItemList {
|
||||
moderation(discussion, context: any): ItemList {
|
||||
const items = new ItemList();
|
||||
|
||||
if (discussion.canRename()) {
|
||||
@@ -108,7 +108,7 @@ export default {
|
||||
* be displayed.
|
||||
* @protected
|
||||
*/
|
||||
destructive(discussion: Discussion): ItemList {
|
||||
destructive(discussion: Discussion, context: any): ItemList {
|
||||
const items = new ItemList();
|
||||
|
||||
if (!discussion.isHidden()) {
|
||||
|
@@ -15,16 +15,16 @@ export default {
|
||||
/**
|
||||
* Get a list of controls for a post.
|
||||
*
|
||||
* @param {Post} post
|
||||
* @param {*} context The parent component under which the controls menu will
|
||||
* @param post
|
||||
* @param context The parent component under which the controls menu will
|
||||
* be displayed.
|
||||
* @public
|
||||
*/
|
||||
controls(post: Post, context) {
|
||||
controls(post: Post, context: any) {
|
||||
const items = new ItemList();
|
||||
|
||||
['user', 'moderation', 'destructive'].forEach(section => {
|
||||
const controls = this[section + 'Controls'](post, context).toArray();
|
||||
const controls = this[section](post, context).toArray();
|
||||
|
||||
if (controls.length) {
|
||||
controls.forEach(item => items.add(item.itemName, item));
|
||||
@@ -38,24 +38,24 @@ export default {
|
||||
/**
|
||||
* Get controls for a post pertaining to the current user (e.g. report).
|
||||
*
|
||||
* @param {Post} post
|
||||
* @param {*} context The parent component under which the controls menu will
|
||||
* @param post
|
||||
* @param context The parent component under which the controls menu will
|
||||
* be displayed.
|
||||
* @protected
|
||||
*/
|
||||
userControls(post: Post, context) {
|
||||
user(post: Post, context: any) {
|
||||
return new ItemList();
|
||||
},
|
||||
|
||||
/**
|
||||
* Get controls for a post pertaining to moderation (e.g. edit).
|
||||
*
|
||||
* @param {Post} post
|
||||
* @param {*} context The parent component under which the controls menu will
|
||||
* @param post
|
||||
* @param context The parent component under which the controls menu will
|
||||
* be displayed.
|
||||
* @protected
|
||||
*/
|
||||
moderationControls(post: Post, context) {
|
||||
moderation(post: Post, context: any) {
|
||||
const items = new ItemList();
|
||||
|
||||
if (post.contentType() === 'comment' && post.canEdit()) {
|
||||
@@ -79,12 +79,12 @@ export default {
|
||||
/**
|
||||
* Get controls for a post that are destructive (e.g. delete).
|
||||
*
|
||||
* @param {Post} post
|
||||
* @param {*} context The parent component under which the controls menu will
|
||||
* @param post
|
||||
* @param context The parent component under which the controls menu will
|
||||
* be displayed.
|
||||
* @protected
|
||||
*/
|
||||
destructiveControls(post: Post, context) {
|
||||
destructive(post: Post, context: any) {
|
||||
const items = new ItemList();
|
||||
|
||||
if (post.contentType() === 'comment' && !post.isHidden()) {
|
||||
|
@@ -22,7 +22,7 @@ export default {
|
||||
const items = new ItemList();
|
||||
|
||||
['user', 'moderation', 'destructive'].forEach(section => {
|
||||
const controls = this[section + 'Controls'](user, context).toArray();
|
||||
const controls = this[section](user, context).toArray();
|
||||
if (controls.length) {
|
||||
controls.forEach(item => items.add(item.itemName, item));
|
||||
items.add(section + 'Separator', Separator.component());
|
||||
@@ -35,14 +35,14 @@ export default {
|
||||
/**
|
||||
* Get controls for a user pertaining to the current user (e.g. poke, follow).
|
||||
*/
|
||||
userControls(): ItemList {
|
||||
user(): ItemList {
|
||||
return new ItemList();
|
||||
},
|
||||
|
||||
/**
|
||||
* Get controls for a user pertaining to moderation (e.g. suspend, edit).
|
||||
*/
|
||||
moderationControls(user: User): ItemList {
|
||||
moderation(user: User): ItemList {
|
||||
const items = new ItemList();
|
||||
|
||||
if (user.canEdit()) {
|
||||
@@ -62,7 +62,7 @@ export default {
|
||||
/**
|
||||
* Get controls for a user which are destructive (e.g. delete).
|
||||
*/
|
||||
destructiveControls(user: User): ItemList {
|
||||
destructive(user: User): ItemList {
|
||||
const items = new ItemList();
|
||||
|
||||
if (user.id() !== '1' && user.canDelete()) {
|
||||
|
Reference in New Issue
Block a user