diff --git a/webapp/components/admin_console/policy_settings.jsx b/webapp/components/admin_console/policy_settings.jsx
index 13101e828e..471d2d3361 100644
--- a/webapp/components/admin_console/policy_settings.jsx
+++ b/webapp/components/admin_console/policy_settings.jsx
@@ -34,6 +34,7 @@ export default class PolicySettings extends AdminSettings {
config.TeamSettings.RestrictPrivateChannelManagement = this.state.restrictPrivateChannelManagement;
config.TeamSettings.RestrictPublicChannelDeletion = this.state.restrictPublicChannelDeletion;
config.TeamSettings.RestrictPrivateChannelDeletion = this.state.restrictPrivateChannelDeletion;
+ config.TeamSettings.RestrictPrivateChannelManageMembers = this.state.restrictPrivateChannelManageMembers;
return config;
}
@@ -49,7 +50,8 @@ export default class PolicySettings extends AdminSettings {
restrictPublicChannelManagement: config.TeamSettings.RestrictPublicChannelManagement,
restrictPrivateChannelManagement: config.TeamSettings.RestrictPrivateChannelManagement,
restrictPublicChannelDeletion: config.TeamSettings.RestrictPublicChannelDeletion,
- restrictPrivateChannelDeletion: config.TeamSettings.RestrictPrivateChannelDeletion
+ restrictPrivateChannelDeletion: config.TeamSettings.RestrictPrivateChannelDeletion,
+ restrictPrivateChannelManageMembers: config.TeamSettings.RestrictPrivateChannelManageMembers
};
}
@@ -214,6 +216,29 @@ export default class PolicySettings extends AdminSettings {
/>
}
/>
+
+ }
+ value={this.state.restrictPrivateChannelManageMembers}
+ onChange={this.handleChange}
+ helpText={
+
+ }
+ />
);
- dropdownContents.push(
-
-
-
-
-
- );
+
+
+
+
+ );
- dropdownContents.push(
-
- this.setState({showMembersModal: true})}
+ dropdownContents.push(
+
-
-
-
- );
+ this.setState({showMembersModal: true})}
+ >
+
+
+
+ );
+ } else {
+ dropdownContents.push(
+
+ this.setState({showMembersModal: true})}
+ >
+
+
+
+ );
+ }
}
const deleteOption = (
diff --git a/webapp/components/channel_members_dropdown.jsx b/webapp/components/channel_members_dropdown.jsx
index 5ccdcd4c15..8c8c7dc3ab 100644
--- a/webapp/components/channel_members_dropdown.jsx
+++ b/webapp/components/channel_members_dropdown.jsx
@@ -9,6 +9,7 @@ import {removeUserFromChannel, makeUserChannelAdmin, makeUserChannelMember} from
import * as AsyncClient from 'utils/async_client.jsx';
import * as Utils from 'utils/utils.jsx';
+import {canManageMembers} from 'utils/channel_utils.jsx';
import React from 'react';
import {FormattedMessage} from 'react-intl';
@@ -91,8 +92,7 @@ export default class ChannelMembersDropdown extends React.Component {
// Checks if the current user has the power to remove this member from the channel.
canRemoveMember() {
- // TODO: This will be implemented as part of PLT-5047.
- return true;
+ return canManageMembers(this.props.channel, UserStore.isSystemAdminForCurrentUser(), TeamStore.isTeamAdminForCurrentTeam(), ChannelStore.isChannelAdminForCurrentChannel());
}
render() {
diff --git a/webapp/components/channel_members_modal.jsx b/webapp/components/channel_members_modal.jsx
index ec5423fe23..a82c620ca3 100644
--- a/webapp/components/channel_members_modal.jsx
+++ b/webapp/components/channel_members_modal.jsx
@@ -3,6 +3,12 @@
import MemberListChannel from './member_list_channel.jsx';
+import TeamStore from 'stores/team_store.jsx';
+import UserStore from 'stores/user_store.jsx';
+import ChannelStore from 'stores/channel_store.jsx';
+
+import {canManageMembers} from 'utils/channel_utils.jsx';
+
import React from 'react';
import {Modal} from 'react-bootstrap';
import {FormattedMessage} from 'react-intl';
@@ -24,6 +30,30 @@ export default class ChannelMembersModal extends React.Component {
}
render() {
+ const isSystemAdmin = UserStore.isSystemAdminForCurrentUser();
+ const isTeamAdmin = TeamStore.isTeamAdminForCurrentTeam();
+ const isChannelAdmin = ChannelStore.isChannelAdminForCurrentChannel();
+
+ let addMembersButton = null;
+ if (canManageMembers(this.state.channel, isSystemAdmin, isTeamAdmin, isChannelAdmin)) {
+ addMembersButton = (
+ {
+ this.props.showInviteModal();
+ this.onHide();
+ }}
+ >
+
+
+ );
+ }
+
return (
-
{
- this.props.showInviteModal();
- this.onHide();
- }}
- >
-
-
+ {addMembersButton}
{
@@ -156,7 +158,7 @@ export default class PopoverListMembers extends React.Component {
defaultMessage='Manage Members'
/>
);
- if (!isAdmin && ChannelStore.isDefault(this.props.channel)) {
+ if (!canManageMembers(this.props.channel, isSystemAdmin, isTeamAdmin, isChannelAdmin) && !ChannelStore.isDefault(this.props.channel)) {
membersName = (
this.setState({showTeamMembersModal: false})}
- isAdmin={isAdmin}
+ isAdmin={isTeamAdmin || isSystemAdmin}
/>
);
}
diff --git a/webapp/i18n/en.json b/webapp/i18n/en.json
index 65ca9d1d44..37207b2796 100755
--- a/webapp/i18n/en.json
+++ b/webapp/i18n/en.json
@@ -331,10 +331,12 @@
"admin.general.policy.restrictPrivateChannelCreationDescription": "Set policy on who can create private groups.",
"admin.general.policy.restrictPrivateChannelCreationTitle": "Enable private group creation for:",
"admin.general.policy.restrictPrivateChannelDeletionCommandLineToolLink": "command line tool",
- "admin.general.policy.restrictPrivateChannelDeletionDescription": "Set policy on who can delete private groups. Deleted groups can be recovered from the database using a {commandLineToolLink}.",
- "admin.general.policy.restrictPrivateChannelDeletionTitle": "Enable private group deletion for:",
- "admin.general.policy.restrictPrivateChannelManagementDescription": "Set policy on who can rename and set the header or purpose for private groups.",
- "admin.general.policy.restrictPrivateChannelManagementTitle": "Enable private group renaming for:",
+ "admin.general.policy.restrictPrivateChannelDeletionDescription": "Set policy on who can delete private channels. Deleted channels can be recovered from the database using a {commandLineToolLink}.",
+ "admin.general.policy.restrictPrivateChannelDeletionTitle": "Enable private channel deletion for:",
+ "admin.general.policy.restrictPrivateChannelManagementDescription": "Set policy on who can rename and set the header or purpose for private channels.",
+ "admin.general.policy.restrictPrivateChannelManagementTitle": "Enable private channel renaming for:",
+ "admin.general.policy.restrictPrivateChannelManageMembersDescription": "Set policy on who can add and remove members from private channels.",
+ "admin.general.policy.restrictPrivateChannelManageMembersTitle": "Enable managing of private channel members for:",
"admin.general.policy.restrictPublicChannelCreationDescription": "Set policy on who can create public channels.",
"admin.general.policy.restrictPublicChannelCreationTitle": "Enable public channel creation for:",
"admin.general.policy.restrictPublicChannelDeletionCommandLineToolLink": "command line tool",
diff --git a/webapp/utils/channel_utils.jsx b/webapp/utils/channel_utils.jsx
index d916ca2545..2930e58b60 100644
--- a/webapp/utils/channel_utils.jsx
+++ b/webapp/utils/channel_utils.jsx
@@ -208,6 +208,26 @@ export function showDeleteOption(channel, isAdmin, isSystemAdmin, isChannelAdmin
return true;
}
+export function canManageMembers(channel, isSystemAdmin, isTeamAdmin, isChannelAdmin) {
+ if (global.window.mm_license.IsLicensed !== 'true') {
+ return true;
+ }
+
+ if (channel.type === Constants.PRIVATE_CHANNEL) {
+ if (global.window.mm_config.RestrictPrivateChannelManageMembers === Constants.PERMISSIONS_SYSTEM_ADMIN && !isSystemAdmin) {
+ return false;
+ }
+ if (global.window.mm_config.RestrictPrivateChannelManageMembers === Constants.PERMISSIONS_TEAM_ADMIN && !isTeamAdmin && !isSystemAdmin) {
+ return false;
+ }
+ if (global.window.mm_config.RestrictPrivateChannelManageMembers === Constants.PERMISSIONS_CHANNEL_ADMIN && !isChannelAdmin && !isTeamAdmin && !isSystemAdmin) {
+ return false;
+ }
+ }
+
+ return true;
+}
+
export function buildGroupChannelName(channelId) {
const profiles = UserStore.getProfileListInChannel(channelId, true);
let displayName = '';