Skip to content

Commit

Permalink
Merge branch 'merge410rc2'
Browse files Browse the repository at this point in the history
  • Loading branch information
GoldUniform committed May 11, 2018
2 parents 807e36f + 288bb85 commit c0b766c
Show file tree
Hide file tree
Showing 39 changed files with 2,195 additions and 666 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,18 @@
import SchemaAdminSettings from 'components/admin_console/schema_admin_settings.jsx';

export default class CustomPluginSettings extends SchemaAdminSettings {
componentWillReceiveProps = (nextProps) => {
if (nextProps.schema !== this.props.schema) {
constructor(props) {
super(props);
this.isPlugin = true;
}

componentWillReceiveProps(nextProps) {
if (!this.props.schema && nextProps.schema) {
this.setState(this.getStateFromConfig(nextProps.config, nextProps.schema));
}
}

getConfigFromState = (config) => {
getConfigFromState(config) {
const schema = this.props.schema;

if (schema) {
Expand All @@ -23,14 +28,19 @@ export default class CustomPluginSettings extends SchemaAdminSettings {
const settings = schema.settings || [];
settings.forEach((setting) => {
const lowerKey = setting.key.toLowerCase();
configSettings[lowerKey] = this.state[lowerKey];
const value = this.state[lowerKey] || setting.default;
if (value == null) {
Reflect.deleteProperty(configSettings, lowerKey);
} else {
configSettings[lowerKey] = value;
}
});
}

return config;
}

getStateFromConfig = (config, schema = this.props.schema) => {
getStateFromConfig(config, schema = this.props.schema) {
const state = {};

if (schema) {
Expand Down
9 changes: 7 additions & 2 deletions components/admin_console/schema_admin_settings.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,12 @@ export default class SchemaAdminSettings extends AdminSettings {
if (schema.settings) {
schema.settings.forEach((setting) => {
if (this.buildSettingFunctions[setting.type] && !this.isHidden(setting)) {
settingsList.push(this.buildSettingFunctions[setting.type](setting));
// This is a hack required as plugin settings are case insensitive
let s = setting;
if (this.isPlugin) {
s = {...setting, key: setting.key.toLowerCase()};
}
settingsList.push(this.buildSettingFunctions[setting.type](s));
}
});
}
Expand Down Expand Up @@ -496,7 +501,7 @@ export default class SchemaAdminSettings extends AdminSettings {
render = () => {
const schema = this.props.schema;

if (schema.component) {
if (schema && schema.component) {
const CustomComponent = schema.component;
return (<CustomComponent {...this.props}/>);
}
Expand Down
11 changes: 6 additions & 5 deletions components/at_mention/at_mention.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,19 @@ import PropTypes from 'prop-types';
import React from 'react';
import {OverlayTrigger} from 'react-bootstrap';
import {Client4} from 'mattermost-redux/client';
import {displayUsername} from 'mattermost-redux/utils/user_utils';

import Pluggable from 'plugins/pluggable';
import ProfilePopover from 'components/profile_popover';

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

export default class AtMention extends React.PureComponent {
static propTypes = {
children: PropTypes.node,
currentUserId: PropTypes.string.isRequired,
hasMention: PropTypes.bool,
isRHS: PropTypes.bool,
mentionName: PropTypes.string.isRequired,
teammateNameDisplay: PropTypes.string.isRequired,
usersByUsername: PropTypes.object.isRequired,
};

Expand Down Expand Up @@ -49,7 +50,7 @@ export default class AtMention extends React.PureComponent {

getUserFromMentionName(props) {
const usersByUsername = props.usersByUsername;
let mentionName = props.mentionName;
let mentionName = props.mentionName.toLowerCase();

while (mentionName.length > 0) {
if (usersByUsername.hasOwnProperty(mentionName)) {
Expand All @@ -69,7 +70,7 @@ export default class AtMention extends React.PureComponent {

render() {
if (!this.state.user) {
return <span>{'@' + this.props.mentionName}</span>;
return <React.Fragment>{this.props.children}</React.Fragment>;
}

const user = this.state.user;
Expand Down Expand Up @@ -99,7 +100,7 @@ export default class AtMention extends React.PureComponent {
</Pluggable>
}
>
<a className={className}>{'@' + Utils.getDisplayNameByUser(user)}</a>
<a className={className}>{'@' + displayUsername(user, this.props.teammateNameDisplay)}</a>
</OverlayTrigger>
{suffix}
</span>
Expand Down
2 changes: 2 additions & 0 deletions components/at_mention/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
// See LICENSE.txt for license information.

import {connect} from 'react-redux';
import {getTeammateNameDisplaySetting} from 'mattermost-redux/selectors/entities/preferences';
import {getCurrentUserId, getUsersByUsername} from 'mattermost-redux/selectors/entities/users';

import AtMention from './at_mention.jsx';

function mapStateToProps(state) {
return {
currentUserId: getCurrentUserId(state),
teammateNameDisplay: getTeammateNameDisplaySetting(state),
usersByUsername: getUsersByUsername(state),
};
}
Expand Down
8 changes: 3 additions & 5 deletions components/create_post/create_post.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ const KeyCodes = Constants.KeyCodes;
export default class CreatePost extends React.Component {
static propTypes = {

isRhsOpen: PropTypes.bool.isRequired,

/**
* ref passed from channelView for EmojiPickerOverlay
*/
Expand Down Expand Up @@ -681,9 +679,9 @@ export default class CreatePost extends React.Component {
replyToLastPost = (e) => {
e.preventDefault();
const latestReplyablePostId = this.props.latestReplyablePostId;
const isRhsOpen = this.props.isRhsOpen;
if (isRhsOpen) {
document.getElementById('reply_textbox').focus();
const replyBox = document.getElementById('reply_textbox');
if (replyBox) {
replyBox.focus();
}
if (latestReplyablePostId) {
this.props.actions.selectPostFromRightHandSideSearchByPostId(latestReplyablePostId);
Expand Down
4 changes: 1 addition & 3 deletions components/create_post/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {Posts} from 'mattermost-redux/constants';
import {emitUserPostedEvent, postListScrollChangeToBottom} from 'actions/global_actions.jsx';
import {createPost, setEditingPost} from 'actions/post_actions.jsx';
import {selectPostFromRightHandSideSearchByPostId} from 'actions/views/rhs';
import {getPostDraft, getIsRhsOpen} from 'selectors/rhs';
import {getPostDraft} from 'selectors/rhs';
import {setGlobalItem, actionOnGlobalItemsWithPrefix} from 'actions/storage';
import {openModal} from 'actions/views/modals';
import {Constants, Preferences, StoragePrefixes, TutorialSteps, UserStatuses} from 'utils/constants.jsx';
Expand All @@ -50,7 +50,6 @@ function mapStateToProps() {
const tutorialStep = getInt(state, Preferences.TUTORIAL_STEP, getCurrentUserId(state), TutorialSteps.FINISHED);
const enableEmojiPicker = config.EnableEmojiPicker === 'true';
const enableConfirmNotificationsToChannel = config.EnableConfirmNotificationsToChannel === 'true';
const isRhsOpen = getIsRhsOpen(state);
const currentUserId = getCurrentUserId(state);
const userIsOutOfOffice = getStatusForUserId(state, currentUserId) === UserStatuses.OUT_OF_OFFICE;

Expand All @@ -73,7 +72,6 @@ function mapStateToProps() {
enableEmojiPicker,
enableConfirmNotificationsToChannel,
maxPostSize: parseInt(config.MaxPostSize, 10) || Constants.DEFAULT_CHARACTER_LIMIT,
isRhsOpen,
userIsOutOfOffice,
};
};
Expand Down
4 changes: 2 additions & 2 deletions components/navbar/navbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,9 @@ export default class Navbar extends React.Component {
</li>
</ChannelPermissionGate>
);
}

if (!ChannelStore.isDefault(channel)) {
deleteChannelOption = (
<ChannelPermissionGate
channelId={channel.id}
Expand All @@ -668,9 +670,7 @@ export default class Navbar extends React.Component {
</li>
</ChannelPermissionGate>
);
}

if (!ChannelStore.isDefault(channel)) {
leaveChannelOption = (
<li role='presentation'>
<a
Expand Down
2 changes: 1 addition & 1 deletion components/rhs_thread/rhs_thread.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ export default class RhsThread extends React.Component {

let createAt = selected.create_at;
if (!createAt) {
createAt = this.props.posts[0].create_at;
createAt = this.props.posts[this.props.posts.length - 1].create_at;
}
const rootPostDay = Utils.getDateForUnixTicks(createAt);
let previousPostDay = rootPostDay;
Expand Down
1 change: 1 addition & 0 deletions components/setting_picture.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ export default class SettingPicture extends Component {
<div
alt={`${imageContext} image preview`}
style={imageStyles}
className={`${imageContext}-img-preview`}
/>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions components/suggestion/switch_channel_provider.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,14 +155,14 @@ function makeChannelSearchFilter(channelPrefix) {
let searchString = channel.display_name;

if (channel.type === Constants.GM_CHANNEL || channel.type === Constants.DM_CHANNEL) {
const usersInChannel = usersInChannels[channel.id] || [];
const usersInChannel = usersInChannels[channel.id] || new Set([]);

// In case the channel is a DM and the profilesInChannel is not populated
if (!usersInChannel.length && channel.type === Constants.DM_CHANNEL) {
const userId = Utils.getUserIdFromChannelId(channel.name);
const user = getUser(curState, userId);
if (user) {
usersInChannel.push(userId);
usersInChannel.add(userId);
}
}

Expand Down
Loading

0 comments on commit c0b766c

Please sign in to comment.