Skip to content

Commit

Permalink
Rename permissions gates to change perm with permissions (mattermost#833
Browse files Browse the repository at this point in the history
)
  • Loading branch information
jespino committed Feb 19, 2018
1 parent 5fe4771 commit b4681e9
Show file tree
Hide file tree
Showing 41 changed files with 340 additions and 340 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ export default class SystemUsersDropdown extends React.Component {
let revokeSessions;
if (showRevokeSessions) {
revokeSessions = (
<SystemPermissionGate perms={[Permissions.REVOKE_USER_ACCESS_TOKEN]}>
<SystemPermissionGate permissions={[Permissions.REVOKE_USER_ACCESS_TOKEN]}>
<li role='presentation'>
<a
id='revokeSessions'
Expand Down
4 changes: 2 additions & 2 deletions components/announcement_bar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@

import {connect} from 'react-redux';
import {getCurrentUserId} from 'mattermost-redux/selectors/entities/users';
import {haveISystemPerm} from 'mattermost-redux/selectors/entities/roles';
import {haveISystemPermission} from 'mattermost-redux/selectors/entities/roles';
import {Permissions} from 'mattermost-redux/constants';
import {getConfig, getLicense} from 'mattermost-redux/selectors/entities/general';

import AnnouncementBar from './announcement_bar.jsx';

function mapStateToProps(state) {
const canViewSystemErrors = haveISystemPerm(state, {perm: Permissions.MANAGE_SYSTEM});
const canViewSystemErrors = haveISystemPermission(state, {permission: Permissions.MANAGE_SYSTEM});
const license = getLicense(state);
const config = getConfig(state);

Expand Down
10 changes: 5 additions & 5 deletions components/backstage/components/backstage_sidebar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export default class BackstageSidebar extends React.Component {
if (this.props.enableIncomingWebhooks) {
incomingWebhooks = (
<TeamPermissionGate
perms={[Permissions.MANAGE_WEBHOOKS]}
permissions={[Permissions.MANAGE_WEBHOOKS]}
teamId={this.props.team.id}
>
<BackstageSection
Expand All @@ -82,7 +82,7 @@ export default class BackstageSidebar extends React.Component {
if (this.props.enableOutgoingWebhooks) {
outgoingWebhooks = (
<TeamPermissionGate
perms={[Permissions.MANAGE_WEBHOOKS]}
permissions={[Permissions.MANAGE_WEBHOOKS]}
teamId={this.props.team.id}
>
<BackstageSection
Expand All @@ -103,7 +103,7 @@ export default class BackstageSidebar extends React.Component {
if (this.props.enableCommands) {
commands = (
<TeamPermissionGate
perms={[Permissions.MANAGE_SLASH_COMMANDS]}
permissions={[Permissions.MANAGE_SLASH_COMMANDS]}
teamId={this.props.team.id}
>
<BackstageSection
Expand All @@ -123,7 +123,7 @@ export default class BackstageSidebar extends React.Component {
let oauthApps = null;
if (this.props.enableOAuthServiceProvider) {
oauthApps = (
<SystemPermissionGate perms={[Permissions.MANAGE_OAUTH]}>
<SystemPermissionGate permissions={[Permissions.MANAGE_OAUTH]}>
<BackstageSection
name='oauth2-apps'
parentLink={'/' + this.props.team.name + '/integrations'}
Expand All @@ -140,7 +140,7 @@ export default class BackstageSidebar extends React.Component {

return (
<TeamPermissionGate
perms={[Permissions.MANAGE_WEBHOOKS, Permissions.MANAGE_SLASH_COMMANDS, Permissions.MANAGE_OAUTH]}
permissions={[Permissions.MANAGE_WEBHOOKS, Permissions.MANAGE_SLASH_COMMANDS, Permissions.MANAGE_OAUTH]}
teamId={this.props.team.id}
>
<BackstageCategory
Expand Down
22 changes: 11 additions & 11 deletions components/channel_header/channel_header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -581,8 +581,8 @@ export default class ChannelHeader extends React.Component {
<ChannelPermissionGate
channelId={channel.id}
teamId={teamId}
perms={[isPrivate ? Permissions.MANAGE_PRIVATE_CHANNEL_MEMBERS : Permissions.MANAGE_PUBLIC_CHANNEL_MEMBERS]}
key='add_members_perm'
permissions={[isPrivate ? Permissions.MANAGE_PRIVATE_CHANNEL_MEMBERS : Permissions.MANAGE_PUBLIC_CHANNEL_MEMBERS]}
key='add_members_permission'
>
<li
key='add_members'
Expand All @@ -608,8 +608,8 @@ export default class ChannelHeader extends React.Component {
<ChannelPermissionGate
channelId={channel.id}
teamId={teamId}
perms={[isPrivate ? Permissions.MANAGE_PRIVATE_CHANNEL_MEMBERS : Permissions.MANAGE_PUBLIC_CHANNEL_MEMBERS]}
key='manage_members_perm'
permissions={[isPrivate ? Permissions.MANAGE_PRIVATE_CHANNEL_MEMBERS : Permissions.MANAGE_PUBLIC_CHANNEL_MEMBERS]}
key='manage_members_permission'
>
<li
key='manage_members'
Expand All @@ -634,9 +634,9 @@ export default class ChannelHeader extends React.Component {
<ChannelPermissionGate
channelId={channel.id}
teamId={teamId}
perms={[isPrivate ? Permissions.MANAGE_PRIVATE_CHANNEL_MEMBERS : Permissions.MANAGE_PUBLIC_CHANNEL_MEMBERS]}
permissions={[isPrivate ? Permissions.MANAGE_PRIVATE_CHANNEL_MEMBERS : Permissions.MANAGE_PUBLIC_CHANNEL_MEMBERS]}
invert={true}
key='view_members_perm'
key='view_members_permission'
>
<li
key='view_members'
Expand All @@ -662,8 +662,8 @@ export default class ChannelHeader extends React.Component {
<ChannelPermissionGate
channelId={channel.id}
teamId={teamId}
perms={[isPrivate ? Permissions.MANAGE_PRIVATE_CHANNEL_PROPERTIES : Permissions.MANAGE_PUBLIC_CHANNEL_PROPERTIES]}
key='set_channel_info_perm'
permissions={[isPrivate ? Permissions.MANAGE_PRIVATE_CHANNEL_PROPERTIES : Permissions.MANAGE_PUBLIC_CHANNEL_PROPERTIES]}
key='set_channel_info_permission'
>
<li
key='divider-2'
Expand Down Expand Up @@ -728,8 +728,8 @@ export default class ChannelHeader extends React.Component {
<ChannelPermissionGate
channelId={channel.id}
teamId={teamId}
perms={[isPrivate ? Permissions.DELETE_PRIVATE_CHANNEL : Permissions.DELETE_PUBLIC_CHANNEL]}
key='delete_channel_perm'
permissions={[isPrivate ? Permissions.DELETE_PRIVATE_CHANNEL : Permissions.DELETE_PUBLIC_CHANNEL]}
key='delete_channel_permission'
>
<li
key='delete_channel'
Expand Down Expand Up @@ -861,7 +861,7 @@ export default class ChannelHeader extends React.Component {
<ChannelPermissionGate
channelId={channel.id}
teamId={teamId}
perms={[isPrivate ? Permissions.MANAGE_PRIVATE_CHANNEL_PROPERTIES : Permissions.MANAGE_PUBLIC_CHANNEL_PROPERTIES]}
permissions={[isPrivate ? Permissions.MANAGE_PRIVATE_CHANNEL_PROPERTIES : Permissions.MANAGE_PUBLIC_CHANNEL_PROPERTIES]}
>
<button
className='style--none'
Expand Down
6 changes: 3 additions & 3 deletions components/channel_members_dropdown/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@
import {connect} from 'react-redux';
import {bindActionCreators} from 'redux';
import {getChannelStats} from 'mattermost-redux/actions/channels';
import {haveIChannelPerm} from 'mattermost-redux/selectors/entities/roles';
import {haveIChannelPermission} from 'mattermost-redux/selectors/entities/roles';
import {getLicense} from 'mattermost-redux/selectors/entities/general';

import {canManageMembers} from 'utils/channel_utils.jsx';

import ChannelMembersDropdown from './channel_members_dropdown.jsx';

function mapStateToProps(state, ownProps) {
const canChangeMemberRoles = haveIChannelPerm(
const canChangeMemberRoles = haveIChannelPermission(
state,
{
channel: ownProps.channel.id,
team: ownProps.channel.team_id,
perm: Permissions.MANAGE_CHANNEL_ROLES
permission: Permissions.MANAGE_CHANNEL_ROLES
}
);
const license = getLicense(state);
Expand Down
2 changes: 1 addition & 1 deletion components/integrations/abstract_oauth_app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ export default class AbstractOAuthApp extends React.PureComponent {
}

const trusted = (
<SystemPermissionGate perms={[Permissions.MANAGE_OAUTH]}>
<SystemPermissionGate permissions={[Permissions.MANAGE_OAUTH]}>
<div className='form-group'>
<label
className='control-label col-sm-4'
Expand Down
4 changes: 2 additions & 2 deletions components/integrations/installed_commands/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
import {connect} from 'react-redux';
import {bindActionCreators} from 'redux';
import {deleteCommand, regenCommandToken} from 'mattermost-redux/actions/integrations';
import {haveITeamPerm} from 'mattermost-redux/selectors/entities/roles';
import {haveITeamPermission} from 'mattermost-redux/selectors/entities/roles';
import {Permissions} from 'mattermost-redux/constants';

import InstalledCommands from './installed_commands.jsx';

function mapStateToProps(state, ownProps) {
const canManageOthersSlashCommands = haveITeamPerm(state, {team: ownProps.team.id, perm: Permissions.MANAGE_OTHERS_SLASH_COMMANDS});
const canManageOthersSlashCommands = haveITeamPermission(state, {team: ownProps.team.id, permission: Permissions.MANAGE_OTHERS_SLASH_COMMANDS});

return {
canManageOthersSlashCommands
Expand Down
4 changes: 2 additions & 2 deletions components/integrations/installed_incoming_webhooks/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {getAllChannels} from 'mattermost-redux/selectors/entities/channels';
import {getIncomingHooks} from 'mattermost-redux/selectors/entities/integrations';
import {getCurrentTeamId} from 'mattermost-redux/selectors/entities/teams';
import {getUsers} from 'mattermost-redux/selectors/entities/users';
import {haveITeamPerm} from 'mattermost-redux/selectors/entities/roles';
import {haveITeamPermission} from 'mattermost-redux/selectors/entities/roles';
import {Permissions} from 'mattermost-redux/constants';
import {getConfig} from 'mattermost-redux/selectors/entities/general';

Expand All @@ -17,7 +17,7 @@ import InstalledIncomingWebhooks from './installed_incoming_webhooks.jsx';
function mapStateToProps(state) {
const config = getConfig(state);
const teamId = getCurrentTeamId(state);
const canManageOthersWebhooks = haveITeamPerm(state, {team: teamId, perm: Permissions.MANAGE_OTHERS_WEBHOOKS});
const canManageOthersWebhooks = haveITeamPermission(state, {team: teamId, permission: Permissions.MANAGE_OTHERS_WEBHOOKS});
const incomingHooks = getIncomingHooks(state);
const incomingWebhooks = Object.keys(incomingHooks).
map((key) => incomingHooks[key]).
Expand Down
4 changes: 2 additions & 2 deletions components/integrations/installed_oauth_apps/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {connect} from 'react-redux';
import {bindActionCreators} from 'redux';
import * as Actions from 'mattermost-redux/actions/integrations';
import {getOAuthApps} from 'mattermost-redux/selectors/entities/integrations';
import {haveISystemPerm} from 'mattermost-redux/selectors/entities/roles';
import {haveISystemPermission} from 'mattermost-redux/selectors/entities/roles';
import {Permissions} from 'mattermost-redux/constants';
import {getConfig} from 'mattermost-redux/selectors/entities/general';

Expand All @@ -17,7 +17,7 @@ function mapStateToProps(state) {
const enableOnlyAdminIntegrations = config.EnableOnlyAdminIntegrations === 'true';

return {
canManageOauth: haveISystemPerm(state, {perm: Permissions.MANAGE_OAUTH}),
canManageOauth: haveISystemPermission(state, {permission: Permissions.MANAGE_OAUTH}),
oauthApps: getOAuthApps(state),
regenOAuthAppSecretRequest: state.requests.integrations.updateOAuthApp,
enableOAuthServiceProvider,
Expand Down
4 changes: 2 additions & 2 deletions components/integrations/installed_outgoing_webhooks/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {getOutgoingHooks} from 'mattermost-redux/selectors/entities/integrations
import {getCurrentTeamId} from 'mattermost-redux/selectors/entities/teams';
import {getAllChannels} from 'mattermost-redux/selectors/entities/channels';
import {getUsers} from 'mattermost-redux/selectors/entities/users';
import {haveITeamPerm} from 'mattermost-redux/selectors/entities/roles';
import {haveITeamPermission} from 'mattermost-redux/selectors/entities/roles';
import {Permissions} from 'mattermost-redux/constants';
import {getConfig} from 'mattermost-redux/selectors/entities/general';

Expand All @@ -14,7 +14,7 @@ import InstalledOutgoingWebhook from './installed_outgoing_webhooks.jsx';
function mapStateToProps(state) {
const config = getConfig(state);
const teamId = getCurrentTeamId(state);
const canManageOthersWebhooks = haveITeamPerm(state, {team: teamId, perm: Permissions.MANAGE_OTHERS_WEBHOOKS});
const canManageOthersWebhooks = haveITeamPermission(state, {team: teamId, permission: Permissions.MANAGE_OTHERS_WEBHOOKS});
const outgoingHooks = getOutgoingHooks(state);
const outgoingWebhooks = Object.keys(outgoingHooks).
map((key) => outgoingHooks[key]).
Expand Down
16 changes: 8 additions & 8 deletions components/integrations/integrations.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ export default class Integrations extends React.Component {
options.push(
<TeamPermissionGate
teamId={this.props.team.id}
perms={[Permissions.MANAGE_WEBHOOKS]}
key='incomingWebhookPerm'
permissions={[Permissions.MANAGE_WEBHOOKS]}
key='incomingWebhookPermission'
>
<IntegrationOption
key='incomingWebhook'
Expand All @@ -76,8 +76,8 @@ export default class Integrations extends React.Component {
options.push(
<TeamPermissionGate
teamId={this.props.team.id}
perms={[Permissions.MANAGE_WEBHOOKS]}
key='outgoingWebhookPerm'
permissions={[Permissions.MANAGE_WEBHOOKS]}
key='outgoingWebhookPermission'
>
<IntegrationOption
key='outgoingWebhook'
Expand All @@ -104,8 +104,8 @@ export default class Integrations extends React.Component {
options.push(
<TeamPermissionGate
teamId={this.props.team.id}
perms={[Permissions.MANAGE_SLASH_COMMANDS]}
key='commandPerm'
permissions={[Permissions.MANAGE_SLASH_COMMANDS]}
key='commandPermission'
>
<IntegrationOption
key='command'
Expand All @@ -131,8 +131,8 @@ export default class Integrations extends React.Component {
if (this.props.enableOAuthServiceProvider) {
options.push(
<SystemPermissionGate
perms={[Permissions.MANAGE_OAUTH]}
key='oauth2AppsPerm'
permissions={[Permissions.MANAGE_OAUTH]}
key='oauth2AppsPermission'
>
<IntegrationOption
key='oauth2Apps'
Expand Down
4 changes: 2 additions & 2 deletions components/member_list_team/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
import {connect} from 'react-redux';
import {bindActionCreators} from 'redux';
import {getTeamStats} from 'mattermost-redux/actions/teams';
import {haveITeamPerm} from 'mattermost-redux/selectors/entities/roles';
import {haveITeamPermission} from 'mattermost-redux/selectors/entities/roles';

import MemberListTeam from './member_list_team.jsx';

function mapStateToProps(state, ownProps) {
const canManageTeamMembers = haveITeamPerm(state, {team: ownProps.teamId, perm: Permissions.MANAGE_TEAM_MEMBERS});
const canManageTeamMembers = haveITeamPermission(state, {team: ownProps.teamId, permission: Permissions.MANAGE_TEAM_MEMBERS});
return {
canManageTeamMembers
};
Expand Down
4 changes: 2 additions & 2 deletions components/more_channels/more_channels.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export default class MoreChannels extends React.Component {
const createNewChannelButton = (
<TeamPermissionGate
teamId={TeamStore.getCurrentId()}
perms={[Permissions.CREATE_PUBLIC_CHANNEL]}
permissions={[Permissions.CREATE_PUBLIC_CHANNEL]}
>
<button
id='createNewChannel'
Expand All @@ -154,7 +154,7 @@ export default class MoreChannels extends React.Component {
const createChannelHelpText = (
<TeamPermissionGate
teamId={TeamStore.getCurrentId()}
perms={[Permissions.CREATE_PUBLIC_CHANNEL]}
permissions={[Permissions.CREATE_PUBLIC_CHANNEL]}
>
<p className='secondary-message'>
<FormattedMessage
Expand Down
Loading

0 comments on commit b4681e9

Please sign in to comment.