Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

Commit

Permalink
Relese 5.0 merge master 20180607 (#1298)
Browse files Browse the repository at this point in the history
* MM-10762: Adjusts team and channel role changes to support new permissions schemes. (#1293)

* Adds next Redux commit. (#1294)

* MM-10793: Handle the show/hide custom emojis in menu using permissions (#1290)

* fix missing users' status indicators on more DM modal (#1279)

* MM-10772 - Updating permissions changes (#1284)

* MM-10772 - Updating permissions changes

* Updating permissions stuff

* Updating button spacing

* Updating team icons

* Updating test snapshots

* Minor 5.0 Bug fixes (#1289)

* MM-10733 - Updating UI for posts

* MM-10780 - Updating emoji reaction tooltip

* MM-10713 Fixed collapsed post colour in permalink view (#1291)

* MM-10602 Removed extra space from OpenGraph preview for links without a description (#1276)

* MM-10602 Removed extra space from OpenGraph preview for links without a description

* Removed unnecessary div
  • Loading branch information
cpanato committed Jun 7, 2018
1 parent f498917 commit 641c194
Show file tree
Hide file tree
Showing 40 changed files with 694 additions and 307 deletions.
20 changes: 1 addition & 19 deletions actions/channel_actions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export function executeCommand(message, args, success, error) {
return;
} else if (
channel.type === Constants.DM_CHANNEL ||
channel.type === Constants.GM_CHANNEL
channel.type === Constants.GM_CHANNEL
) {
let name;
let category;
Expand Down Expand Up @@ -174,24 +174,6 @@ export async function removeUserFromChannel(channelId, userId, success, error) {
}
}

export async function makeUserChannelAdmin(channelId, userId, success, error) {
const {data, error: err} = await ChannelActions.updateChannelMemberRoles(channelId, userId, 'channel_user channel_admin')(dispatch, getState);
if (data && success) {
success(data);
} else if (err && error) {
error({id: err.server_error_id, ...err});
}
}

export async function makeUserChannelMember(channelId, userId, success, error) {
const {data, error: err} = await ChannelActions.updateChannelMemberRoles(channelId, userId, 'channel_user')(dispatch, getState);
if (data && success) {
success(data);
} else if (err && error) {
error({id: err.server_error_id, ...err});
}
}

export async function openDirectChannelToUser(userId, success, error) {
const channelName = Utils.getDirectChannelName(UserStore.getCurrentId(), userId);
const channel = ChannelStore.getByName(channelName);
Expand Down
9 changes: 0 additions & 9 deletions actions/team_actions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,6 @@ export async function removeUserFromTeam(teamId, userId, success, error) {
}
}

export async function updateTeamMemberRoles(teamId, userId, newRoles, success, error) {
const {data, error: err} = await TeamActions.updateTeamMemberRoles(teamId, userId, newRoles)(dispatch, getState);
if (data && success) {
success();
} else if (err && error) {
error({id: err.server_error_id, ...err});
}
}

export function addUserToTeamFromInvite(token, inviteId, success, error) {
Client4.addToTeamFromInvite(token, inviteId).then(
async (member) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import React from 'react';
import {Dropdown, MenuItem} from 'react-bootstrap';
import {FormattedMessage} from 'react-intl';

import {removeUserFromTeam, updateTeamMemberRoles} from 'actions/team_actions.jsx';
import {removeUserFromTeam} from 'actions/team_actions.jsx';
import * as Utils from 'utils/utils.jsx';

export default class ManageTeamsDropdown extends React.Component {
Expand All @@ -16,15 +16,14 @@ export default class ManageTeamsDropdown extends React.Component {
onError: PropTypes.func.isRequired,
onMemberChange: PropTypes.func.isRequired,
onMemberRemove: PropTypes.func.isRequired,
updateTeamMemberSchemeRoles: PropTypes.func.isRequired,
};

constructor(props) {
super(props);

this.toggleDropdown = this.toggleDropdown.bind(this);

this.makeTeamAdmin = this.makeTeamAdmin.bind(this);
this.makeMember = this.makeMember.bind(this);
this.removeFromTeam = this.removeFromTeam.bind(this);

this.handleMemberChange = this.handleMemberChange.bind(this);
Expand All @@ -41,25 +40,23 @@ export default class ManageTeamsDropdown extends React.Component {
});
}

makeTeamAdmin() {
updateTeamMemberRoles(
this.props.teamMember.team_id,
this.props.user.id,
'team_user team_admin',
this.handleMemberChange,
this.props.onError
);
}
makeTeamAdmin = async () => {
const {error} = await this.props.updateTeamMemberSchemeRoles(this.props.teamMember.team_id, this.props.user.id, true, true);
if (error) {
this.props.onError(error.message);
} else {
this.handleMemberChange();
}
};

makeMember() {
updateTeamMemberRoles(
this.props.teamMember.team_id,
this.props.user.id,
'team_user',
this.handleMemberChange,
this.props.onError
);
}
makeMember = async () => {
const {error} = await this.props.updateTeamMemberSchemeRoles(this.props.teamMember.team_id, this.props.user.id, true, false);
if (error) {
this.props.onError(error.message);
} else {
this.handleMemberChange();
}
};

removeFromTeam() {
removeUserFromTeam(
Expand All @@ -79,7 +76,7 @@ export default class ManageTeamsDropdown extends React.Component {
}

render() {
const isTeamAdmin = Utils.isAdmin(this.props.teamMember.roles);
const isTeamAdmin = Utils.isAdmin(this.props.teamMember.roles) || this.props.teamMember.scheme_admin;

let title;
if (isTeamAdmin) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export default class ManageTeamsModal extends React.Component {
onModalDismissed: PropTypes.func.isRequired,
show: PropTypes.bool.isRequired,
user: PropTypes.object,
updateTeamMemberSchemeRoles: PropTypes.func.isRequired,
};

constructor(props) {
Expand Down Expand Up @@ -134,6 +135,7 @@ export default class ManageTeamsModal extends React.Component {
onError={this.handleError}
onMemberChange={this.handleMemberChange}
onMemberRemove={this.handleMemberRemove}
updateTeamMemberSchemeRoles={this.props.updateTeamMemberSchemeRoles}
/>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export default class EditPostTimeLimitButton extends React.Component {
className='edit-post-time-limit-button'
onClick={this.props.onClick}
>
<i className='fa fa-gear'/>
<FormattedMessage
id={messageID}
values={{n: this.props.timeLimit}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import React from 'react';
import PropTypes from 'prop-types';
import {FormattedMessage} from 'react-intl';
import {FormattedMessage, FormattedHTMLMessage} from 'react-intl';
import {Modal} from 'react-bootstrap';

import {Constants} from 'utils/constants';
Expand Down Expand Up @@ -91,62 +91,67 @@ export default class EditPostTimeLimitModal extends React.Component {
</h4>
</Modal.Header>
<Modal.Body>
<FormattedMessage
<FormattedHTMLMessage
id='edit_post.time_limit_modal.description'
defaultMessage='Setting a time limit applies to all users who have the "Edit Post" permissions in any permission scheme.'
defaultMessage='Setting a time limit <strong>applies to all users</strong> who have the "Edit Post" permissions in any permission scheme.'
/>
<div>
<input
id='anytime'
type='radio'
name='limit'
value={Constants.ALLOW_EDIT_POST_ALWAYS}
checked={this.state.postEditTimeLimit === Constants.UNSET_POST_EDIT_TIME_LIMIT}
onChange={this.handleOptionChange}
/>
<label htmlFor='anytime'>
<FormattedMessage
id='edit_post.time_limit_modal.option_label_anytime'
defaultMessage='Anytime'
<div className='padding-left x2 padding-top padding-bottom'>
<div className='padding-top x2'>
<input
id='anytime'
type='radio'
name='limit'
value={Constants.ALLOW_EDIT_POST_ALWAYS}
checked={this.state.postEditTimeLimit === Constants.UNSET_POST_EDIT_TIME_LIMIT}
onChange={this.handleOptionChange}
/>
</label>
</div>
<div>
<input
id='timelimit'
type='radio'
name='limit'
value={Constants.ALLOW_EDIT_POST_TIME_LIMIT}
checked={this.state.postEditTimeLimit !== Constants.UNSET_POST_EDIT_TIME_LIMIT}
onChange={this.handleOptionChange}
/>
<label htmlFor='timelimit'>
<FormattedMessage
id='edit_post.time_limit_modal.option_label_time_limit.preinput'
defaultMessage='Can edit for'
<label htmlFor='anytime'>
<FormattedMessage
id='edit_post.time_limit_modal.option_label_anytime'
defaultMessage='Anytime'
/>
</label>
</div>
<div className='padding-top'>
<input
id='timelimit'
type='radio'
name='limit'
value={Constants.ALLOW_EDIT_POST_TIME_LIMIT}
checked={this.state.postEditTimeLimit !== Constants.UNSET_POST_EDIT_TIME_LIMIT}
onChange={this.handleOptionChange}
/>
</label>
<input
type='number'
min='0'
step='1'
max={INT32_MAX}
id='editPostTimeLimit'
readOnly={this.state.postEditTimeLimit === Constants.UNSET_POST_EDIT_TIME_LIMIT}
onChange={this.handleSecondsChange}
value={this.state.postEditTimeLimit === Constants.UNSET_POST_EDIT_TIME_LIMIT ? '' : this.state.postEditTimeLimit}
/>
<label htmlFor='timelimit'>
<label htmlFor='timelimit'>
<FormattedMessage
id='edit_post.time_limit_modal.option_label_time_limit.preinput'
defaultMessage='Can edit for'
/>
</label>
<input
type='number'
className='form-control inline'
min='0'
step='1'
max={INT32_MAX}
id='editPostTimeLimit'
readOnly={this.state.postEditTimeLimit === Constants.UNSET_POST_EDIT_TIME_LIMIT}
onChange={this.handleSecondsChange}
value={this.state.postEditTimeLimit === Constants.UNSET_POST_EDIT_TIME_LIMIT ? '' : this.state.postEditTimeLimit}
/>
<label htmlFor='timelimit'>
<FormattedMessage
id='edit_post.time_limit_modal.option_label_time_limit.postinput'
defaultMessage='seconds after posting'
/>
</label>
</div>
<div className='padding-top x2 light'>
<FormattedMessage
id='edit_post.time_limit_modal.option_label_time_limit.postinput'
defaultMessage='seconds after posting'
id='edit_post.time_limit_modal.subscript'
defaultMessage='Set the length of time users have to edit their messages after posting.'
/>
</label>
</div>
</div>
<FormattedMessage
id='edit_post.time_limit_modal.subscript'
defaultMessage='Set the length of time users have to edit their messages after posting.'
/>
</Modal.Body>
<Modal.Footer>
<div className='edit-post-time-limit-modal__error'>
Expand Down
2 changes: 2 additions & 0 deletions components/admin_console/system_users/list/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {connect} from 'react-redux';
import {bindActionCreators} from 'redux';

import {getUser} from 'mattermost-redux/actions/users';
import {updateTeamMemberSchemeRoles} from 'mattermost-redux/actions/teams';

import SystemUsersList from './system_users_list.jsx';
import {getUsers} from './selectors.jsx';
Expand All @@ -19,6 +20,7 @@ function mapDispatchToProps(dispatch) {
return {
actions: bindActionCreators({
getUser,
updateTeamMemberSchemeRoles,
}, dispatch),
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export default class SystemUsersList extends React.Component {

actions: PropTypes.shape({
getUser: PropTypes.func.isRequired,
updateTeamMemberSchemeRoles: PropTypes.func.isRequired,
}).isRequired,
};

Expand Down Expand Up @@ -287,6 +288,7 @@ export default class SystemUsersList extends React.Component {
user={this.state.user}
show={this.state.showManageTeamsModal}
onModalDismissed={this.doManageTeamsDismiss}
updateTeamMemberSchemeRoles={this.props.actions.updateTeamMemberSchemeRoles}
/>
<ManageRolesModal
user={this.state.user}
Expand Down
2 changes: 2 additions & 0 deletions components/backstage/backstage_controller.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export default class BackstageController extends React.Component {
enableOutgoingWebhooks: PropTypes.bool.isRequired,
enableCommands: PropTypes.bool.isRequired,
enableOAuthServiceProvider: PropTypes.bool.isRequired,
canCreateCustomEmoji: PropTypes.bool.isRequired,
}

scrollToTop = () => {
Expand Down Expand Up @@ -106,6 +107,7 @@ export default class BackstageController extends React.Component {
enableOutgoingWebhooks={this.props.enableOutgoingWebhooks}
enableCommands={this.props.enableCommands}
enableOAuthServiceProvider={this.props.enableOAuthServiceProvider}
canCreateCustomEmoji={this.props.canCreateCustomEmoji}
/>
<Switch>
<BackstageRoute
Expand Down
5 changes: 2 additions & 3 deletions components/backstage/components/backstage_sidebar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import {FormattedMessage} from 'react-intl';

import {Permissions} from 'mattermost-redux/constants';

import * as Utils from 'utils/utils.jsx';

import SystemPermissionGate from 'components/permissions_gates/system_permission_gate';
import TeamPermissionGate from 'components/permissions_gates/team_permission_gate';

Expand All @@ -25,11 +23,12 @@ export default class BackstageSidebar extends React.Component {
enableOutgoingWebhooks: PropTypes.bool.isRequired,
enableCommands: PropTypes.bool.isRequired,
enableOAuthServiceProvider: PropTypes.bool.isRequired,
canCreateCustomEmoji: PropTypes.bool.isRequired,
};
}

renderCustomEmoji() {
if (!this.props.enableCustomEmoji || !Utils.canCreateCustomEmoji(this.props.user)) {
if (!this.props.enableCustomEmoji || !this.props.canCreateCustomEmoji) {
return null;
}

Expand Down
15 changes: 14 additions & 1 deletion components/backstage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import {connect} from 'react-redux';
import {withRouter} from 'react-router-dom';

import {getCurrentUser} from 'mattermost-redux/selectors/entities/users';
import {getCurrentTeam} from 'mattermost-redux/selectors/entities/teams';
import {getMyTeams, getCurrentTeam} from 'mattermost-redux/selectors/entities/teams';
import {getConfig} from 'mattermost-redux/selectors/entities/general';
import {haveITeamPermission, haveISystemPermission} from 'mattermost-redux/selectors/entities/roles';
import {Permissions} from 'mattermost-redux/constants';

import BackstageController from './backstage_controller.jsx';

Expand All @@ -23,6 +25,16 @@ function mapStateToProps(state) {
const enableCommands = config.EnableCommands === 'true';
const enableOAuthServiceProvider = config.EnableOAuthServiceProvider === 'true';

let canCreateCustomEmoji = haveISystemPermission(state, {permission: Permissions.MANAGE_EMOJIS});
if (!canCreateCustomEmoji) {
for (const t of getMyTeams(state)) {
if (haveITeamPermission(state, {team: t.id, permission: Permissions.MANAGE_EMOJIS})) {
canCreateCustomEmoji = true;
break;
}
}
}

return {
user,
team,
Expand All @@ -32,6 +44,7 @@ function mapStateToProps(state) {
enableOutgoingWebhooks,
enableCommands,
enableOAuthServiceProvider,
canCreateCustomEmoji,
};
}

Expand Down
Loading

0 comments on commit 641c194

Please sign in to comment.