Merge branch 'fine_grained_moderation_privileges' into 'develop'
Add privileges Closes #1177 See merge request pleroma/pleroma-fe!1583
This commit is contained in:
commit
8a87d82b7b
@ -113,8 +113,7 @@ const ExtraButtons = {
|
|||||||
currentUser () { return this.$store.state.users.currentUser },
|
currentUser () { return this.$store.state.users.currentUser },
|
||||||
canDelete () {
|
canDelete () {
|
||||||
if (!this.currentUser) { return }
|
if (!this.currentUser) { return }
|
||||||
const superuser = this.currentUser.rights.moderator || this.currentUser.rights.admin
|
return this.currentUser.privileges.includes('messages_delete') || this.status.user.id === this.currentUser.id
|
||||||
return superuser || this.status.user.id === this.currentUser.id
|
|
||||||
},
|
},
|
||||||
ownStatus () {
|
ownStatus () {
|
||||||
return this.status.user.id === this.currentUser.id
|
return this.status.user.id === this.currentUser.id
|
||||||
|
@ -15,7 +15,7 @@ const Interactions = {
|
|||||||
return {
|
return {
|
||||||
allowFollowingMove: this.$store.state.users.currentUser.allow_following_move,
|
allowFollowingMove: this.$store.state.users.currentUser.allow_following_move,
|
||||||
filterMode: tabModeDict.mentions,
|
filterMode: tabModeDict.mentions,
|
||||||
canSeeReports: ['moderator', 'admin'].includes(this.$store.state.users.currentUser.role)
|
canSeeReports: this.$store.state.users.currentUser.privileges.includes('reports_manage_reports')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
@ -41,14 +41,26 @@ const ModerationTools = {
|
|||||||
tagsSet () {
|
tagsSet () {
|
||||||
return new Set(this.user.tags)
|
return new Set(this.user.tags)
|
||||||
},
|
},
|
||||||
hasTagPolicy () {
|
canGrantRole () {
|
||||||
return this.$store.state.instance.tagPolicyAvailable
|
return this.user.is_local && !this.user.deactivated && this.$store.state.users.currentUser.role === 'admin'
|
||||||
|
},
|
||||||
|
canChangeActivationState () {
|
||||||
|
return this.privileged('users_manage_activation_state')
|
||||||
|
},
|
||||||
|
canDeleteAccount () {
|
||||||
|
return this.privileged('users_delete')
|
||||||
|
},
|
||||||
|
canUseTagPolicy () {
|
||||||
|
return this.$store.state.instance.tagPolicyAvailable && this.privileged('users_manage_tags')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
hasTag (tagName) {
|
hasTag (tagName) {
|
||||||
return this.tagsSet.has(tagName)
|
return this.tagsSet.has(tagName)
|
||||||
},
|
},
|
||||||
|
privileged (privilege) {
|
||||||
|
return this.$store.state.users.currentUser.privileges.includes(privilege)
|
||||||
|
},
|
||||||
toggleTag (tag) {
|
toggleTag (tag) {
|
||||||
const store = this.$store
|
const store = this.$store
|
||||||
if (this.tagsSet.has(tag)) {
|
if (this.tagsSet.has(tag)) {
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
>
|
>
|
||||||
<template #content>
|
<template #content>
|
||||||
<div class="dropdown-menu">
|
<div class="dropdown-menu">
|
||||||
<span v-if="user.is_local">
|
<span v-if="canGrantRole">
|
||||||
<button
|
<button
|
||||||
class="button-default dropdown-item"
|
class="button-default dropdown-item"
|
||||||
@click="toggleRight("admin")"
|
@click="toggleRight("admin")"
|
||||||
@ -24,28 +24,31 @@
|
|||||||
{{ $t(!!user.rights.moderator ? 'user_card.admin_menu.revoke_moderator' : 'user_card.admin_menu.grant_moderator') }}
|
{{ $t(!!user.rights.moderator ? 'user_card.admin_menu.revoke_moderator' : 'user_card.admin_menu.grant_moderator') }}
|
||||||
</button>
|
</button>
|
||||||
<div
|
<div
|
||||||
|
v-if="canChangeActivationState || canDeleteAccount"
|
||||||
role="separator"
|
role="separator"
|
||||||
class="dropdown-divider"
|
class="dropdown-divider"
|
||||||
/>
|
/>
|
||||||
</span>
|
</span>
|
||||||
<button
|
<button
|
||||||
|
v-if="canChangeActivationState"
|
||||||
class="button-default dropdown-item"
|
class="button-default dropdown-item"
|
||||||
@click="toggleActivationStatus()"
|
@click="toggleActivationStatus()"
|
||||||
>
|
>
|
||||||
{{ $t(!!user.deactivated ? 'user_card.admin_menu.activate_account' : 'user_card.admin_menu.deactivate_account') }}
|
{{ $t(!!user.deactivated ? 'user_card.admin_menu.activate_account' : 'user_card.admin_menu.deactivate_account') }}
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
|
v-if="canDeleteAccount"
|
||||||
class="button-default dropdown-item"
|
class="button-default dropdown-item"
|
||||||
@click="deleteUserDialog(true)"
|
@click="deleteUserDialog(true)"
|
||||||
>
|
>
|
||||||
{{ $t('user_card.admin_menu.delete_account') }}
|
{{ $t('user_card.admin_menu.delete_account') }}
|
||||||
</button>
|
</button>
|
||||||
<div
|
<div
|
||||||
v-if="hasTagPolicy"
|
v-if="canUseTagPolicy"
|
||||||
role="separator"
|
role="separator"
|
||||||
class="dropdown-divider"
|
class="dropdown-divider"
|
||||||
/>
|
/>
|
||||||
<span v-if="hasTagPolicy">
|
<span v-if="canUseTagPolicy">
|
||||||
<button
|
<button
|
||||||
class="button-default dropdown-item"
|
class="button-default dropdown-item"
|
||||||
@click="toggleTag(tags.FORCE_NSFW)"
|
@click="toggleTag(tags.FORCE_NSFW)"
|
||||||
|
@ -125,6 +125,10 @@ export default {
|
|||||||
hideFollowersCount () {
|
hideFollowersCount () {
|
||||||
return this.isOtherUser && this.user.hide_followers_count
|
return this.isOtherUser && this.user.hide_followers_count
|
||||||
},
|
},
|
||||||
|
showModerationMenu () {
|
||||||
|
const privileges = this.loggedIn.privileges
|
||||||
|
return this.loggedIn.role === 'admin' || privileges.includes('users_manage_activation_state') || privileges.includes('users_delete') || privileges.includes('users_manage_tags')
|
||||||
|
},
|
||||||
...mapGetters(['mergedConfig'])
|
...mapGetters(['mergedConfig'])
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
|
@ -258,7 +258,7 @@
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<ModerationTools
|
<ModerationTools
|
||||||
v-if="loggedIn.role === "admin""
|
v-if="showModerationMenu"
|
||||||
:user="user"
|
:user="user"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
@ -124,6 +124,34 @@ export const parseUser = (data) => {
|
|||||||
} else {
|
} else {
|
||||||
output.role = 'member'
|
output.role = 'member'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (data.pleroma.privileges) {
|
||||||
|
output.privileges = data.pleroma.privileges
|
||||||
|
} else if (data.pleroma.is_admin) {
|
||||||
|
output.privileges = [
|
||||||
|
'users_read',
|
||||||
|
'users_manage_invites',
|
||||||
|
'users_manage_activation_state',
|
||||||
|
'users_manage_tags',
|
||||||
|
'users_manage_credentials',
|
||||||
|
'users_delete',
|
||||||
|
'messages_read',
|
||||||
|
'messages_delete',
|
||||||
|
'instances_delete',
|
||||||
|
'reports_manage_reports',
|
||||||
|
'moderation_log_read',
|
||||||
|
'announcements_manage_announcements',
|
||||||
|
'emoji_manage_emoji',
|
||||||
|
'statistics_read'
|
||||||
|
]
|
||||||
|
} else if (data.pleroma.is_moderator) {
|
||||||
|
output.privileges = [
|
||||||
|
'messages_delete',
|
||||||
|
'reports_manage_reports'
|
||||||
|
]
|
||||||
|
} else {
|
||||||
|
output.privileges = []
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.source) {
|
if (data.source) {
|
||||||
|
Loading…
Reference in New Issue
Block a user