PLT-4007 Fix OAuth: Javascript error when team admin accesses the OAuth 2.0 menu (#3887)

Этот коммит содержится в:
enahum
2016-08-30 23:05:23 -03:00
коммит произвёл Joram Wilander
родитель 1326ab66a1
Коммит db660bdf9c
3 изменённых файлов: 10 добавлений и 5 удалений

Просмотреть файл

@@ -40,6 +40,7 @@ export default class BackstageSidebar extends React.Component {
renderIntegrations() {
const config = window.mm_config;
const isSystemAdmin = Utils.isSystemAdmin(this.props.user.roles);
if (config.EnableIncomingWebhooks !== 'true' &&
config.EnableOutgoingWebhooks !== 'true' &&
config.EnableCommands !== 'true' &&
@@ -48,7 +49,7 @@ export default class BackstageSidebar extends React.Component {
}
if (config.EnableOnlyAdminIntegrations !== 'false' &&
!Utils.isSystemAdmin(this.props.user.roles) &&
!isSystemAdmin &&
!TeamStore.isTeamAdmin(this.props.user.id, this.props.team.id)) {
return null;
}
@@ -99,7 +100,7 @@ export default class BackstageSidebar extends React.Component {
}
let oauthApps = null;
if (config.EnableOAuthServiceProvider === 'true') {
if (config.EnableOAuthServiceProvider === 'true' && (isSystemAdmin || config.EnableOnlyAdminIntegrations !== 'true')) {
oauthApps = (
<BackstageSection
name='oauth2-apps'

Просмотреть файл

@@ -11,16 +11,20 @@ import OutgoingWebhookIcon from 'images/outgoing_webhook.jpg';
import SlashCommandIcon from 'images/slash_command_icon.jpg';
import OAuthIcon from 'images/oauth_icon.png';
import * as Utils from 'utils/utils.jsx';
export default class Integrations extends React.Component {
static get propTypes() {
return {
team: React.propTypes.object.isRequired
team: React.propTypes.object.isRequired,
user: React.PropTypes.object.isRequired
};
}
render() {
const options = [];
const config = window.mm_config;
const isSystemAdmin = Utils.isSystemAdmin(this.props.user.roles);
if (config.EnableIncomingWebhooks === 'true') {
options.push(
@@ -88,7 +92,7 @@ export default class Integrations extends React.Component {
);
}
if (config.EnableOAuthServiceProvider === 'true') {
if (config.EnableOAuthServiceProvider === 'true' && (isSystemAdmin || config.EnableOnlyAdminIntegrations !== 'true')) {
options.push(
<IntegrationOption
key='oauth2Apps'

Просмотреть файл

@@ -205,7 +205,7 @@ export default class NavbarDropdown extends React.Component {
config.EnableIncomingWebhooks === 'true' ||
config.EnableOutgoingWebhooks === 'true' ||
config.EnableCommands === 'true' ||
config.EnableOAuthServiceProvider === 'true';
(config.EnableOAuthServiceProvider === 'true' && (isSystemAdmin || config.EnableOnlyAdminIntegrations !== 'true'));
if (integrationsEnabled && (isAdmin || config.EnableOnlyAdminIntegrations !== 'true')) {
integrationsLink = (
<li>