mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
PLT-2697 Fixing team admins (#2900)
* PLT-2697 Fixing team admins * Fixing eslint error * Fixing loc issues * Fixing func * Fixing func
This commit is contained in:
committed by
Christopher Speller
parent
4f799b980f
commit
6c75662b82
@@ -3,6 +3,7 @@
|
||||
|
||||
import AppDispatcher from '../dispatcher/app_dispatcher.jsx';
|
||||
import EventEmitter from 'events';
|
||||
import UserStore from 'stores/user_store.jsx';
|
||||
|
||||
import Constants from 'utils/constants.jsx';
|
||||
const ActionTypes = Constants.ActionTypes;
|
||||
@@ -148,6 +149,22 @@ class TeamStoreClass extends EventEmitter {
|
||||
getTeamListings() {
|
||||
return this.teamListings;
|
||||
}
|
||||
|
||||
isTeamAdminForCurrentTeam() {
|
||||
if (!Utils) {
|
||||
Utils = require('utils/utils.jsx'); //eslint-disable-line global-require
|
||||
}
|
||||
|
||||
const userId = UserStore.getCurrentId();
|
||||
var teamMembers = this.getTeamMembers();
|
||||
const teamMember = teamMembers.find((m) => m.user_id === userId && m.team_id === this.getCurrentId());
|
||||
|
||||
if (teamMember) {
|
||||
return Utils.isAdmin(teamMember.roles);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
var TeamStore = new TeamStoreClass();
|
||||
|
||||
@@ -13,6 +13,8 @@ const CHANGE_EVENT_SESSIONS = 'change_sessions';
|
||||
const CHANGE_EVENT_AUDITS = 'change_audits';
|
||||
const CHANGE_EVENT_STATUSES = 'change_statuses';
|
||||
|
||||
var Utils;
|
||||
|
||||
class UserStoreClass extends EventEmitter {
|
||||
constructor() {
|
||||
super();
|
||||
@@ -314,6 +316,20 @@ class UserStoreClass extends EventEmitter {
|
||||
setNoAccounts(noAccounts) {
|
||||
this.noAccounts = noAccounts;
|
||||
}
|
||||
|
||||
isSystemAdminForCurrentUser() {
|
||||
if (!Utils) {
|
||||
Utils = require('utils/utils.jsx'); //eslint-disable-line global-require
|
||||
}
|
||||
|
||||
var current = this.getCurrentUser();
|
||||
|
||||
if (current) {
|
||||
return Utils.isAdmin(current.roles);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
var UserStore = new UserStoreClass();
|
||||
|
||||
Reference in New Issue
Block a user