Commit 596ff745 authored by Jesús Espino's avatar Jesús Espino Committed by George Goldberg
Browse files

Hide mapped roles in settings when license is active (#1261)

* Hide mapped roles in settings when license is active

* Clean up policy adapter
parent 73454e5d
......@@ -303,24 +303,25 @@ export class WebhookSettings extends AdminSettings {
onChange={this.handleChange}
setByEnv={this.isSetByEnv('ServiceSettings.EnableOAuthServiceProvider')}
/>
<BooleanSetting
id='enableOnlyAdminIntegrations'
label={
<FormattedMessage
id='admin.service.integrationAdmin'
defaultMessage='Restrict managing integrations to Admins:'
/>
}
helpText={
<FormattedMessage
id='admin.service.integrationAdminDesc'
defaultMessage='When true, webhooks and slash commands can only be created, edited and viewed by Team and System Admins, and OAuth 2.0 applications by System Admins. Integrations are available to all users after they have been created by the Admin.'
/>
}
value={this.state.enableOnlyAdminIntegrations}
onChange={this.handleChange}
setByEnv={false}
/>
{this.props.license.IsLicensed === 'false' &&
<BooleanSetting
id='enableOnlyAdminIntegrations'
label={
<FormattedMessage
id='admin.service.integrationAdmin'
defaultMessage='Restrict managing integrations to Admins:'
/>
}
helpText={
<FormattedMessage
id='admin.service.integrationAdminDesc'
defaultMessage='When true, webhooks and slash commands can only be created, edited and viewed by Team and System Admins, and OAuth 2.0 applications by System Admins. Integrations are available to all users after they have been created by the Admin.'
/>
}
value={this.state.enableOnlyAdminIntegrations}
onChange={this.handleChange}
setByEnv={false}
/>}
<BooleanSetting
id='enablePostUsernameOverride'
label={
......
......@@ -258,24 +258,25 @@ export class UsersAndTeamsSettings extends AdminSettings {
onChange={this.handleChange}
setByEnv={this.isSetByEnv('TeamSetting.EnableUserCreation')}
/>
<BooleanSetting
id='enableTeamCreation'
label={
<FormattedMessage
id='admin.team.teamCreationTitle'
defaultMessage='Enable Team Creation: '
/>
}
helpText={
<FormattedMessage
id='admin.team.teamCreationDescription'
defaultMessage='When false, only System Administrators can create teams.'
/>
}
value={this.state.enableTeamCreation}
onChange={this.handleChange}
setByEnv={false}
/>
{this.props.license.IsLicensed === 'false' &&
<BooleanSetting
id='enableTeamCreation'
label={
<FormattedMessage
id='admin.team.teamCreationTitle'
defaultMessage='Enable Team Creation: '
/>
}
helpText={
<FormattedMessage
id='admin.team.teamCreationDescription'
defaultMessage='When false, only System Administrators can create teams.'
/>
}
value={this.state.enableTeamCreation}
onChange={this.handleChange}
setByEnv={false}
/>}
<TextSetting
id='maxUsersPerTeam'
label={
......
This diff is collapsed.
......@@ -3,126 +3,7 @@
import {Permissions} from 'mattermost-redux/constants/index';
function teamMapping(permission) {
return {
all: [
{roleName: 'team_user', permission, shouldHave: true},
],
team_admin: [
{roleName: 'team_user', permission, shouldHave: false},
{roleName: 'team_admin', permission, shouldHave: true},
],
system_admin: [
{roleName: 'team_user', permission, shouldHave: false},
{roleName: 'team_admin', permission, shouldHave: false},
],
};
}
function channelMapping(permission) {
return {
all: [
{roleName: 'channel_user', permission, shouldHave: true},
],
channel_admin: [
{roleName: 'channel_user', permission, shouldHave: false},
{roleName: 'channel_admin', permission, shouldHave: true},
{roleName: 'team_admin', permission, shouldHave: true},
],
team_admin: [
{roleName: 'channel_user', permission, shouldHave: false},
{roleName: 'channel_admin', permission, shouldHave: false},
{roleName: 'team_admin', permission, shouldHave: true},
],
system_admin: [
{roleName: 'channel_user', permission, shouldHave: false},
{roleName: 'channel_admin', permission, shouldHave: false},
{roleName: 'team_admin', permission, shouldHave: false},
],
};
}
function channelTeamMixedMapping(permission) {
return {
all: [
{roleName: 'team_user', permission, shouldHave: true},
],
channel_admin: [
{roleName: 'team_user', permission, shouldHave: false},
{roleName: 'channel_admin', permission, shouldHave: true},
{roleName: 'team_admin', permission, shouldHave: true},
],
team_admin: [
{roleName: 'team_user', permission, shouldHave: false},
{roleName: 'channel_admin', permission, shouldHave: false},
{roleName: 'team_admin', permission, shouldHave: true},
],
system_admin: [
{roleName: 'team_user', permission, shouldHave: false},
{roleName: 'channel_admin', permission, shouldHave: false},
{roleName: 'team_admin', permission, shouldHave: false},
],
};
}
const MAPPING = {
restrictTeamInvite: {
all: [
{roleName: 'team_user', permission: Permissions.INVITE_USER, shouldHave: true},
{roleName: 'team_user', permission: Permissions.ADD_USER_TO_TEAM, shouldHave: true},
],
team_admin: [
{roleName: 'team_user', permission: Permissions.INVITE_USER, shouldHave: false},
{roleName: 'team_user', permission: Permissions.ADD_USER_TO_TEAM, shouldHave: false},
{roleName: 'team_admin', permission: Permissions.INVITE_USER, shouldHave: true},
{roleName: 'team_admin', permission: Permissions.ADD_USER_TO_TEAM, shouldHave: true},
],
system_admin: [
{roleName: 'team_user', permission: Permissions.INVITE_USER, shouldHave: false},
{roleName: 'team_user', permission: Permissions.ADD_USER_TO_TEAM, shouldHave: false},
{roleName: 'team_admin', permission: Permissions.INVITE_USER, shouldHave: false},
{roleName: 'team_admin', permission: Permissions.ADD_USER_TO_TEAM, shouldHave: false},
],
},
restrictPublicChannelCreation: {...teamMapping(Permissions.CREATE_PUBLIC_CHANNEL)},
restrictPrivateChannelCreation: {...teamMapping(Permissions.CREATE_PRIVATE_CHANNEL)},
restrictPrivateChannelManageMembers: {...channelMapping(Permissions.MANAGE_PRIVATE_CHANNEL_MEMBERS)},
restrictPublicChannelManagement: {...channelTeamMixedMapping(Permissions.MANAGE_PUBLIC_CHANNEL_PROPERTIES)},
restrictPublicChannelDeletion: {...channelTeamMixedMapping(Permissions.DELETE_PUBLIC_CHANNEL)},
restrictPrivateChannelManagement: {...channelTeamMixedMapping(Permissions.MANAGE_PRIVATE_CHANNEL_PROPERTIES)},
restrictPrivateChannelDeletion: {...channelTeamMixedMapping(Permissions.DELETE_PRIVATE_CHANNEL)},
allowEditPost: {
always: [
{roleName: 'channel_user', permission: Permissions.EDIT_POST, shouldHave: true},
{roleName: 'system_admin', permission: Permissions.EDIT_POST, shouldHave: true},
],
never: [
{roleName: 'channel_user', permission: Permissions.EDIT_POST, shouldHave: false},
{roleName: 'system_admin', permission: Permissions.EDIT_POST, shouldHave: false},
],
},
restrictPostDelete: {
all: [
{roleName: 'channel_user', permission: Permissions.DELETE_POST, shouldHave: true},
{roleName: 'team_admin', permission: Permissions.DELETE_POST, shouldHave: true},
{roleName: 'team_admin', permission: Permissions.DELETE_OTHERS_POSTS, shouldHave: true},
],
team_admin: [
{roleName: 'channel_user', permission: Permissions.DELETE_POST, shouldHave: false},
{roleName: 'team_admin', permission: Permissions.DELETE_POST, shouldHave: true},
{roleName: 'team_admin', permission: Permissions.DELETE_OTHERS_POSTS, shouldHave: true},
],
system_admin: [
{roleName: 'channel_user', permission: Permissions.DELETE_POST, shouldHave: false},
{roleName: 'team_admin', permission: Permissions.DELETE_POST, shouldHave: false},
{roleName: 'team_admin', permission: Permissions.DELETE_OTHERS_POSTS, shouldHave: false},
],
},
enableTeamCreation: {
true: [{roleName: 'system_user', permission: Permissions.CREATE_TEAM, shouldHave: true}],
false: [{roleName: 'system_user', permission: Permissions.CREATE_TEAM, shouldHave: false}],
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment