PLT-4007 Fix OAuth: Javascript error when team admin accesses the OAuth 2.0 menu (#3887)
Этот коммит содержится в:
коммит произвёл
Joram Wilander
родитель
1326ab66a1
Коммит
db660bdf9c
@@ -40,6 +40,7 @@ export default class BackstageSidebar extends React.Component {
|
|||||||
|
|
||||||
renderIntegrations() {
|
renderIntegrations() {
|
||||||
const config = window.mm_config;
|
const config = window.mm_config;
|
||||||
|
const isSystemAdmin = Utils.isSystemAdmin(this.props.user.roles);
|
||||||
if (config.EnableIncomingWebhooks !== 'true' &&
|
if (config.EnableIncomingWebhooks !== 'true' &&
|
||||||
config.EnableOutgoingWebhooks !== 'true' &&
|
config.EnableOutgoingWebhooks !== 'true' &&
|
||||||
config.EnableCommands !== 'true' &&
|
config.EnableCommands !== 'true' &&
|
||||||
@@ -48,7 +49,7 @@ export default class BackstageSidebar extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (config.EnableOnlyAdminIntegrations !== 'false' &&
|
if (config.EnableOnlyAdminIntegrations !== 'false' &&
|
||||||
!Utils.isSystemAdmin(this.props.user.roles) &&
|
!isSystemAdmin &&
|
||||||
!TeamStore.isTeamAdmin(this.props.user.id, this.props.team.id)) {
|
!TeamStore.isTeamAdmin(this.props.user.id, this.props.team.id)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -99,7 +100,7 @@ export default class BackstageSidebar extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let oauthApps = null;
|
let oauthApps = null;
|
||||||
if (config.EnableOAuthServiceProvider === 'true') {
|
if (config.EnableOAuthServiceProvider === 'true' && (isSystemAdmin || config.EnableOnlyAdminIntegrations !== 'true')) {
|
||||||
oauthApps = (
|
oauthApps = (
|
||||||
<BackstageSection
|
<BackstageSection
|
||||||
name='oauth2-apps'
|
name='oauth2-apps'
|
||||||
|
|||||||
@@ -11,16 +11,20 @@ import OutgoingWebhookIcon from 'images/outgoing_webhook.jpg';
|
|||||||
import SlashCommandIcon from 'images/slash_command_icon.jpg';
|
import SlashCommandIcon from 'images/slash_command_icon.jpg';
|
||||||
import OAuthIcon from 'images/oauth_icon.png';
|
import OAuthIcon from 'images/oauth_icon.png';
|
||||||
|
|
||||||
|
import * as Utils from 'utils/utils.jsx';
|
||||||
|
|
||||||
export default class Integrations extends React.Component {
|
export default class Integrations extends React.Component {
|
||||||
static get propTypes() {
|
static get propTypes() {
|
||||||
return {
|
return {
|
||||||
team: React.propTypes.object.isRequired
|
team: React.propTypes.object.isRequired,
|
||||||
|
user: React.PropTypes.object.isRequired
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const options = [];
|
const options = [];
|
||||||
const config = window.mm_config;
|
const config = window.mm_config;
|
||||||
|
const isSystemAdmin = Utils.isSystemAdmin(this.props.user.roles);
|
||||||
|
|
||||||
if (config.EnableIncomingWebhooks === 'true') {
|
if (config.EnableIncomingWebhooks === 'true') {
|
||||||
options.push(
|
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(
|
options.push(
|
||||||
<IntegrationOption
|
<IntegrationOption
|
||||||
key='oauth2Apps'
|
key='oauth2Apps'
|
||||||
|
|||||||
@@ -205,7 +205,7 @@ export default class NavbarDropdown extends React.Component {
|
|||||||
config.EnableIncomingWebhooks === 'true' ||
|
config.EnableIncomingWebhooks === 'true' ||
|
||||||
config.EnableOutgoingWebhooks === 'true' ||
|
config.EnableOutgoingWebhooks === 'true' ||
|
||||||
config.EnableCommands === 'true' ||
|
config.EnableCommands === 'true' ||
|
||||||
config.EnableOAuthServiceProvider === 'true';
|
(config.EnableOAuthServiceProvider === 'true' && (isSystemAdmin || config.EnableOnlyAdminIntegrations !== 'true'));
|
||||||
if (integrationsEnabled && (isAdmin || config.EnableOnlyAdminIntegrations !== 'true')) {
|
if (integrationsEnabled && (isAdmin || config.EnableOnlyAdminIntegrations !== 'true')) {
|
||||||
integrationsLink = (
|
integrationsLink = (
|
||||||
<li>
|
<li>
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user