PLT-4202 fix javascript error manage OAuth2 apps (#4039)
* PLT-4202 fix javascript error manage OAuth2 apps * Fix unit tests
Этот коммит содержится в:
коммит произвёл
Christopher Speller
родитель
4e3d465210
Коммит
33e20b874e
@@ -102,6 +102,7 @@ func getOAuthApps(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
if HasPermissionToContext(c, model.PERMISSION_MANAGE_SYSTEM_WIDE_OAUTH) {
|
if HasPermissionToContext(c, model.PERMISSION_MANAGE_SYSTEM_WIDE_OAUTH) {
|
||||||
ochan = Srv.Store.OAuth().GetApps()
|
ochan = Srv.Store.OAuth().GetApps()
|
||||||
} else {
|
} else {
|
||||||
|
c.Err = nil
|
||||||
ochan = Srv.Store.OAuth().GetAppByUser(c.Session.UserId)
|
ochan = Srv.Store.OAuth().GetAppByUser(c.Session.UserId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -156,8 +156,8 @@ func TestGetOAuthAppsByUser(t *testing.T) {
|
|||||||
|
|
||||||
utils.Cfg.ServiceSettings.EnableOAuthServiceProvider = true
|
utils.Cfg.ServiceSettings.EnableOAuthServiceProvider = true
|
||||||
|
|
||||||
if _, err := Client.GetOAuthAppsByUser(); err == nil {
|
if _, err := Client.GetOAuthAppsByUser(); err != nil {
|
||||||
t.Fatal("Should have failed. only admin is permitted")
|
t.Fatal("Should have passed.")
|
||||||
}
|
}
|
||||||
|
|
||||||
*utils.Cfg.ServiceSettings.EnableOnlyAdminIntegrations = false
|
*utils.Cfg.ServiceSettings.EnableOnlyAdminIntegrations = false
|
||||||
|
|||||||
@@ -311,6 +311,7 @@ func InitalizeRoles() {
|
|||||||
[]string{
|
[]string{
|
||||||
PERMISSION_CREATE_DIRECT_CHANNEL.Id,
|
PERMISSION_CREATE_DIRECT_CHANNEL.Id,
|
||||||
PERMISSION_PERMANENT_DELETE_USER.Id,
|
PERMISSION_PERMANENT_DELETE_USER.Id,
|
||||||
|
PERMISSION_MANAGE_OAUTH.Id,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
BuiltInRoles[ROLE_SYSTEM_USER.Id] = ROLE_SYSTEM_USER
|
BuiltInRoles[ROLE_SYSTEM_USER.Id] = ROLE_SYSTEM_USER
|
||||||
|
|||||||
@@ -71,6 +71,17 @@ export default class InstalledOAuthApps extends React.Component {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const isSystemAdmin = UserStore.isSystemAdminForCurrentUser();
|
||||||
|
const config = global.mm_config;
|
||||||
|
const integrationsEnabled = (config.EnableOAuthServiceProvider === 'true' && (isSystemAdmin || config.EnableOnlyAdminIntegrations !== 'true'));
|
||||||
|
let props;
|
||||||
|
if (integrationsEnabled) {
|
||||||
|
props = {
|
||||||
|
addLink: '/' + this.props.team.name + '/integrations/oauth2-apps/add',
|
||||||
|
addText: localizeMessage('installed_oauth_apps.add', 'Add OAuth 2.0 Application')
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<BackstageList
|
<BackstageList
|
||||||
header={
|
header={
|
||||||
@@ -99,13 +110,6 @@ export default class InstalledOAuthApps extends React.Component {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
addText={
|
|
||||||
<FormattedMessage
|
|
||||||
id='installed_oauth_apps.add'
|
|
||||||
defaultMessage='Add OAuth 2.0 Application'
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
addLink={'/' + this.props.team.name + '/integrations/oauth2-apps/add'}
|
|
||||||
emptyText={
|
emptyText={
|
||||||
<FormattedMessage
|
<FormattedMessage
|
||||||
id='installed_oauth_apps.empty'
|
id='installed_oauth_apps.empty'
|
||||||
@@ -114,6 +118,7 @@ export default class InstalledOAuthApps extends React.Component {
|
|||||||
}
|
}
|
||||||
searchPlaceholder={localizeMessage('installed_oauth_apps.search', 'Search OAuth 2.0 Applications')}
|
searchPlaceholder={localizeMessage('installed_oauth_apps.search', 'Search OAuth 2.0 Applications')}
|
||||||
loading={this.state.loading}
|
loading={this.state.loading}
|
||||||
|
{...props}
|
||||||
>
|
>
|
||||||
{oauthApps}
|
{oauthApps}
|
||||||
</BackstageList>
|
</BackstageList>
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user