Adding the ability for admins to revoke/reinstate chat privileges and block/unblock users from the profile page. (#10082)

* Adding the ability for admins to revoke/reinstate chat privileges and block/unblock users from the profile page.

fixes #10073

* Updating fix to dynamically load user blocked and chat revoked state for admins.

* Fixing pr according to comments.
This commit is contained in:
Travis
2018-03-24 09:18:52 -07:00
committed by Sabe Jones
parent b5872a9577
commit e4b13eecd1

View File

@@ -13,6 +13,22 @@ div
button.btn.btn-secondary.positive-icon(v-if='user._id !== this.userLoggedIn._id && userLoggedIn.inbox.blocks.indexOf(user._id) !== -1', button.btn.btn-secondary.positive-icon(v-if='user._id !== this.userLoggedIn._id && userLoggedIn.inbox.blocks.indexOf(user._id) !== -1',
@click="unblockUser()", v-b-tooltip.hover.right="$t('unblock')") @click="unblockUser()", v-b-tooltip.hover.right="$t('unblock')")
.svg-icon.positive-icon(v-html="icons.positive") .svg-icon.positive-icon(v-html="icons.positive")
button.btn.btn-secondary.positive-icon(v-if='this.userLoggedIn.contributor.admin && !adminToolsLoaded',
@click="loadAdminTools()", v-b-tooltip.hover.right="'Admin - Load Tools'")
.svg-icon.positive-icon(v-html="icons.edit")
span(v-if='this.userLoggedIn.contributor.admin && adminToolsLoaded')
button.btn.btn-secondary.positive-icon(v-if='!hero.flags || (hero.flags && !hero.flags.chatRevoked)',
@click="adminRevokeChat()", v-b-tooltip.hover.bottom="'Admin - Revoke Chat Privileges'")
.svg-icon.positive-icon(v-html="icons.megaphone")
button.btn.btn-secondary.positive-icon(v-if='hero.flags && hero.flags.chatRevoked',
@click="adminReinstateChat()", v-b-tooltip.hover.bottom="'Admin - Reinstate Chat Privileges'")
.svg-icon.positive-icon(v-html="icons.challenge")
button.btn.btn-secondary.positive-icon(v-if='!hero.auth.blocked',
@click="adminBlockUser()", v-b-tooltip.hover.right="'Admin - Block User'")
.svg-icon.positive-icon(v-html="icons.lock")
button.btn.btn-secondary.positive-icon(v-if='hero.auth.blocked',
@click="adminUnblockUser()", v-b-tooltip.hover.right="'Admin - Unblock User'")
.svg-icon.positive-icon(v-html="icons.member")
.row .row
.col-12 .col-12
member-details(:member="user") member-details(:member="user")
@@ -587,6 +603,11 @@ import gift from 'assets/svg/gift.svg';
import remove from 'assets/svg/remove.svg'; import remove from 'assets/svg/remove.svg';
import positive from 'assets/svg/positive.svg'; import positive from 'assets/svg/positive.svg';
import dots from 'assets/svg/dots.svg'; import dots from 'assets/svg/dots.svg';
import megaphone from 'assets/svg/broken-megaphone.svg';
import lock from 'assets/svg/lock.svg';
import challenge from 'assets/svg/challenge.svg';
import member from 'assets/svg/member-icon.svg';
import edit from 'assets/svg/edit.svg';
export default { export default {
directives: { directives: {
@@ -606,7 +627,13 @@ export default {
positive, positive,
gift, gift,
dots, dots,
megaphone,
challenge,
lock,
member,
edit,
}), }),
adminToolsLoaded: false,
userIdToMessage: '', userIdToMessage: '',
userReceivingGems: '', userReceivingGems: '',
editing: false, editing: false,
@@ -615,6 +642,7 @@ export default {
imageUrl: '', imageUrl: '',
blurb: '', blurb: '',
}, },
hero: {},
managerEmail: { managerEmail: {
hrefBlankCommunityManagerEmail: `<a href="mailto:${COMMUNITY_MANAGER_EMAIL}">${COMMUNITY_MANAGER_EMAIL}</a>`, hrefBlankCommunityManagerEmail: `<a href="mailto:${COMMUNITY_MANAGER_EMAIL}">${COMMUNITY_MANAGER_EMAIL}</a>`,
}, },
@@ -692,8 +720,11 @@ export default {
// Reset editing when user is changed. Move to watch or is this good? // Reset editing when user is changed. Move to watch or is this good?
this.editing = false; this.editing = false;
this.hero = {};
this.adminToolsLoaded = false;
let profileUser = this.$store.state.profileUser; let profileUser = this.$store.state.profileUser;
if (profileUser._id && profileUser._id !== this.userLoggedIn._id) { if (profileUser._id && profileUser._id !== this.userLoggedIn._id) {
user = profileUser; user = profileUser;
} }
@@ -709,6 +740,7 @@ export default {
// @TODO For some reason markdown doesn't seem to be handling numbers or maybe undefined? // @TODO For some reason markdown doesn't seem to be handling numbers or maybe undefined?
user.profile.blurb = user.profile.blurb ? `${user.profile.blurb}` : ''; user.profile.blurb = user.profile.blurb ? `${user.profile.blurb}` : '';
return user; return user;
}, },
incentivesProgress () { incentivesProgress () {
@@ -863,6 +895,36 @@ export default {
this.userReceivingGems = this.user; this.userReceivingGems = this.user;
this.$root.$emit('bv::show::modal', 'send-gems'); this.$root.$emit('bv::show::modal', 'send-gems');
}, },
adminRevokeChat () {
if (!this.hero.flags) {
this.hero.flags = {};
}
this.hero.flags.chatRevoked = true;
this.$store.dispatch('hall:updateHero', { heroDetails: this.hero });
},
adminReinstateChat () {
if (!this.hero.flags) {
this.hero.flags = {};
}
this.hero.flags.chatRevoked = false;
this.$store.dispatch('hall:updateHero', { heroDetails: this.hero });
},
adminBlockUser () {
this.hero.auth.blocked = true;
this.$store.dispatch('hall:updateHero', { heroDetails: this.hero });
},
adminUnblockUser () {
this.hero.auth.blocked = false;
this.$store.dispatch('hall:updateHero', { heroDetails: this.hero });
},
async loadAdminTools () {
this.hero = await this.$store.dispatch('hall:getHero', { uuid: this.user._id });
this.adminToolsLoaded = true;
},
}, },
}; };
</script> </script>