Skip to content

Commit

Permalink
Merge branch 'release-4.8' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
jespino committed Mar 14, 2018
2 parents 0c55bba + c5f27bb commit e30a3e1
Show file tree
Hide file tree
Showing 35 changed files with 242 additions and 188 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ test: .yarninstall ## Runs tests

.yarninstall: package.json
@echo Getting dependencies using yarn


yarn cache clean --pattern "mattermost-redux"
yarn install --pure-lockfile
cd node_modules/mattermost-redux; npm run build

Expand Down
40 changes: 37 additions & 3 deletions actions/post_actions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
// See License.txt for license information.

import {batchActions} from 'redux-batched-actions';
import {PostTypes} from 'mattermost-redux/action_types';
import {PostTypes, SearchTypes} from 'mattermost-redux/action_types';
import {getMyChannelMember} from 'mattermost-redux/actions/channels';
import * as PostActions from 'mattermost-redux/actions/posts';
import * as Selectors from 'mattermost-redux/selectors/entities/posts';
import {comparePosts} from 'mattermost-redux/utils/post_utils';

import {browserHistory} from 'utils/browser_history';
import {sendDesktopNotification} from 'actions/notification_actions.jsx';
Expand Down Expand Up @@ -98,8 +99,25 @@ export async function flagPost(postId) {

const rhsState = getRhsState(getState());

// This is a hack that should be fixed with better reducers/actions, see MM-9793
if (rhsState === RHSStates.FLAG) {
dispatch(RhsActions.getFlaggedPosts());
let results = getState().entities.search.results;
const index = results.indexOf(postId);
if (index === -1) {
results = [...results, postId];

const posts = {};
results.forEach((id) => {
posts[id] = Selectors.getPost(getState(), id);
});

results.sort((a, b) => comparePosts(posts[a], posts[b]));

dispatch({
type: SearchTypes.RECEIVED_SEARCH_POSTS,
data: {posts, order: results},
});
}
}
}

Expand All @@ -108,8 +126,24 @@ export async function unflagPost(postId) {

const rhsState = getRhsState(getState());

// This is a hack that should be fixed with better reducers/actions, see MM-9793
if (rhsState === RHSStates.FLAG) {
dispatch(RhsActions.getFlaggedPosts());
let results = getState().entities.search.results;
const index = results.indexOf(postId);
if (index > -1) {
results = [...results];
results.splice(index, 1);

const posts = {};
results.forEach((id) => {
posts[id] = Selectors.getPost(getState(), id);
});

dispatch({
type: SearchTypes.RECEIVED_SEARCH_POSTS,
data: {posts, order: results},
});
}
}
}

Expand Down
11 changes: 4 additions & 7 deletions actions/views/create_comment.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ import * as GlobalActions from 'actions/global_actions.jsx';
import * as ChannelActions from 'actions/channel_actions.jsx';
import {setGlobalItem, actionOnGlobalItemsWithPrefix} from 'actions/storage';
import {EmojiMap} from 'stores/emoji_store.jsx';
import {makeGetCommentDraft} from 'selectors/rhs';
import {getPostDraft} from 'selectors/rhs';

import * as Utils from 'utils/utils.jsx';
import {Constants, StoragePrefixes} from 'utils/constants.jsx';

Expand All @@ -39,11 +40,9 @@ export function updateCommentDraft(rootId, draft) {

export function makeOnMoveHistoryIndex(rootId, direction) {
const getMessageInHistory = makeGetMessageInHistoryItem(Posts.MESSAGE_TYPES.COMMENT);
const getCommentDraft = makeGetCommentDraft(rootId);

return () => (dispatch, getState) => {
const draft = getCommentDraft(getState());

const draft = getPostDraft(getState(), StoragePrefixes.COMMENT_DRAFT, rootId);
if (draft.message !== '' && draft.message !== getMessageInHistory(getState())) {
return;
}
Expand Down Expand Up @@ -124,10 +123,8 @@ export function submitCommand(channelId, rootId, draft) {
}

export function makeOnSubmit(channelId, rootId, latestPostId) {
const getCommentDraft = makeGetCommentDraft(rootId);

return () => async (dispatch, getState) => {
const draft = getCommentDraft(getState());
const draft = getPostDraft(getState(), StoragePrefixes.COMMENT_DRAFT, rootId);
const {message} = draft;

dispatch(addMessageIntoHistory(message));
Expand Down
2 changes: 1 addition & 1 deletion actions/websocket_actions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ function handleReactionRemovedEvent(msg) {

function handleChannelViewedEvent(msg) {
// Useful for when multiple devices have the app open to different channels
if (ChannelStore.getCurrentId() !== msg.data.channel_id &&
if ((!window.isActive || ChannelStore.getCurrentId() !== msg.data.channel_id) &&
UserStore.getCurrentId() === msg.broadcast.user_id) {
// Mark previous and next channel as read
ChannelStore.resetCounts([msg.data.channel_id]);
Expand Down
11 changes: 0 additions & 11 deletions components/announcement_bar/announcement_bar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ export default class AnnouncementBar extends React.PureComponent {
bannerColor: PropTypes.string,
bannerTextColor: PropTypes.string,
enableSignUpWithGitLab: PropTypes.bool.isRequired,
enableAPIv3: PropTypes.bool.isRequired,
}

constructor(props) {
Expand Down Expand Up @@ -71,9 +70,6 @@ export default class AnnouncementBar extends React.PureComponent {
} else if (!this.props.sendEmailNotifications) {
ErrorStore.storeLastError({notification: true, message: ErrorBarTypes.PREVIEW_MODE});
return;
} else if (isSystemAdmin && this.props.enableAPIv3) {
ErrorStore.storeLastError({notification: true, message: ErrorBarTypes.APIV3_ENABLED});
return;
}
}

Expand Down Expand Up @@ -246,13 +242,6 @@ export default class AnnouncementBar extends React.PureComponent {
defaultMessage='Preview Mode: Email notifications have not been configured'
/>
);
} else if (message === ErrorBarTypes.APIV3_ENABLED) {
message = (
<FormattedHTMLMessage
id={ErrorBarTypes.APIV3_ENABLED}
defaultMessage='API version 3 is deprecated and scheduled for removal. <a href="https://api.mattermost.com/#tag/APIv3-Deprecation" target="_blank">Learn how to migrate to APIv4</a>.'
/>
);
} else if (message === ErrorBarTypes.LICENSE_EXPIRING) {
message = (
<FormattedHTMLMessage
Expand Down
2 changes: 0 additions & 2 deletions components/announcement_bar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ function mapStateToProps(state) {
const bannerColor = config.BannerColor;
const bannerTextColor = config.BannerTextColor;
const enableSignUpWithGitLab = config.EnableSignUpWithGitLab === 'true';
const enableAPIv3 = config.EnableAPIv3 === 'true';

return {
isLoggedIn: Boolean(getCurrentUserId(state)),
Expand All @@ -33,7 +32,6 @@ function mapStateToProps(state) {
bannerColor,
bannerTextColor,
enableSignUpWithGitLab,
enableAPIv3,
};
}

Expand Down
8 changes: 4 additions & 4 deletions components/create_comment/create_comment.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ export default class CreateComment extends React.PureComponent {
}

commentMsgKeyPress = (e) => {
if (!UserAgent.isMobile() && ((this.props.ctrlSend && Utils.cmdOrCtrlPressed(e)) || !this.props.ctrlSend)) {
if (!UserAgent.isMobile() && ((this.props.ctrlSend && (e.ctrlKey || e.metaKey)) || !this.props.ctrlSend)) {
if (Utils.isKeyPressed(e, KeyCodes.ENTER) && !e.shiftKey && !e.altKey) {
e.preventDefault();
this.refs.textbox.blur();
Expand Down Expand Up @@ -331,23 +331,23 @@ export default class CreateComment extends React.PureComponent {
}

handleKeyDown = (e) => {
if (this.props.ctrlSend && Utils.isKeyPressed(e, Constants.KeyCodes.ENTER) && Utils.cmdOrCtrlPressed(e)) {
if (this.props.ctrlSend && Utils.isKeyPressed(e, Constants.KeyCodes.ENTER) && (e.ctrlKey || e.metaKey)) {
this.commentMsgKeyPress(e);
return;
}

const {draft} = this.state;
const {message} = draft;

if (!Utils.cmdOrCtrlPressed(e) && !e.altKey && !e.shiftKey && Utils.isKeyPressed(e, Constants.KeyCodes.UP) && message === '') {
if (!e.ctrlKey && !e.metaKey && !e.altKey && !e.shiftKey && Utils.isKeyPressed(e, Constants.KeyCodes.UP) && message === '') {
e.preventDefault();
if (this.refs.textbox) {
this.refs.textbox.blur();
}
this.props.onEditLatestPost();
}

if ((Utils.cmdOrCtrlPressed(e)) && !e.altKey && !e.shiftKey) {
if ((e.ctrlKey || e.metaKey) && !e.altKey && !e.shiftKey) {
if (Utils.isKeyPressed(e, Constants.KeyCodes.UP)) {
e.preventDefault();
this.props.onMoveHistoryIndexBack();
Expand Down
10 changes: 4 additions & 6 deletions components/create_comment/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {makeGetMessageInHistoryItem} from 'mattermost-redux/selectors/entities/p
import {resetCreatePostRequest, resetHistoryIndex} from 'mattermost-redux/actions/posts';
import {Preferences, Posts} from 'mattermost-redux/constants';

import {Constants} from 'utils/constants.jsx';
import {Constants, StoragePrefixes} from 'utils/constants.jsx';

import {
clearCommentDraftUploads,
Expand All @@ -20,18 +20,16 @@ import {
makeOnSubmit,
makeOnEditLatestPost,
} from 'actions/views/create_comment';
import {makeGetCommentDraft} from 'selectors/rhs';
import {getPostDraft} from 'selectors/rhs';

import CreateComment from './create_comment.jsx';

function mapStateToProps(state, ownProps) {
const err = state.requests.posts.createPost.error || {};

const getCommentDraft = makeGetCommentDraft(ownProps.rootId);

const draft = getCommentDraft(state);

const draft = getPostDraft(state, StoragePrefixes.COMMENT_DRAFT, ownProps.rootId);
const enableAddButton = draft.message.trim().length !== 0 || draft.fileInfos.length !== 0;

const channelMembersCount = getAllChannelStats(state)[ownProps.channelId] ? getAllChannelStats(state)[ownProps.channelId].member_count : 1;
const messageInHistory = makeGetMessageInHistoryItem(Posts.MESSAGE_TYPES.COMMENT)(state);

Expand Down
6 changes: 3 additions & 3 deletions components/create_post/create_post.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ export default class CreatePost extends React.Component {
}

postMsgKeyPress = (e) => {
const ctrlOrMetaKeyPressed = Utils.cmdOrCtrlPressed(e);
const ctrlOrMetaKeyPressed = e.ctrlKey || e.metaKey;
if (!UserAgent.isMobile() && ((this.props.ctrlSend && ctrlOrMetaKeyPressed) || !this.props.ctrlSend)) {
if (Utils.isKeyPressed(e, KeyCodes.ENTER) && !e.shiftKey && !e.altKey) {
e.preventDefault();
Expand Down Expand Up @@ -558,7 +558,7 @@ export default class CreatePost extends React.Component {
}

showShortcuts(e) {
if (Utils.cmdOrCtrlPressed(e) && Utils.isKeyPressed(e, KeyCodes.FORWARD_SLASH)) {
if ((e.ctrlKey || e.metaKey) && Utils.isKeyPressed(e, KeyCodes.FORWARD_SLASH)) {
e.preventDefault();

GlobalActions.toggleShortcutsModal();
Expand Down Expand Up @@ -588,7 +588,7 @@ export default class CreatePost extends React.Component {
}

handleKeyDown = (e) => {
const ctrlOrMetaKeyPressed = Utils.cmdOrCtrlPressed(e);
const ctrlOrMetaKeyPressed = e.ctrlKey || e.metaKey;
const messageIsEmpty = this.state.message.length === 0;
const draftMessageIsEmpty = this.props.draft.message.length === 0;
const ctrlEnterKeyCombo = this.props.ctrlSend && Utils.isKeyPressed(e, KeyCodes.ENTER) && ctrlOrMetaKeyPressed;
Expand Down
10 changes: 3 additions & 7 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, postListScrollChange} from 'actions/global_actions.jsx';
import {createPost, setEditingPost} from 'actions/post_actions.jsx';
import {selectPostFromRightHandSideSearchByPostId} from 'actions/views/rhs';
import {makeGetGlobalItem} from 'selectors/storage';
import {getPostDraft} from 'selectors/rhs';
import {setGlobalItem, actionOnGlobalItemsWithPrefix} from 'actions/storage';
import {Constants, Preferences, StoragePrefixes, TutorialSteps} from 'utils/constants.jsx';
import {canUploadFiles} from 'utils/file_utils';
Expand All @@ -39,11 +39,7 @@ function mapStateToProps() {
return (state) => {
const config = getConfig(state);
const currentChannel = getCurrentChannel(state) || {};
const getDraft = makeGetGlobalItem(StoragePrefixes.DRAFT + currentChannel.id, {
message: '',
uploadsInProgress: [],
fileInfos: [],
});
const draft = getPostDraft(state, StoragePrefixes.DRAFT, currentChannel.id);
const recentPostIdInChannel = getMostRecentPostIdInChannel(state, currentChannel.id);
const post = getPost(state, recentPostIdInChannel);
const getCommentCountForPost = makeGetCommentCountForPost();
Expand All @@ -63,7 +59,7 @@ function mapStateToProps() {
fullWidthTextBox: get(state, Preferences.CATEGORY_DISPLAY_SETTINGS, Preferences.CHANNEL_DISPLAY_MODE, Preferences.CHANNEL_DISPLAY_MODE_DEFAULT) === Preferences.CHANNEL_DISPLAY_MODE_FULL_SCREEN,
showTutorialTip: enableTutorial && tutorialStep === TutorialSteps.POST_POPOVER,
messageInHistoryItem: makeGetMessageInHistoryItem(Posts.MESSAGE_TYPES.POST)(state),
draft: getDraft(state),
draft,
recentPostIdInChannel,
commentCountForPost: getCommentCountForPost(state, {post}),
latestReplyablePostId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,14 @@ class EditChannelHeaderModal extends React.PureComponent {

handleKeyDown = (e) => {
const {ctrlSend} = this.props;
if (ctrlSend && Utils.isKeyPressed(e, KeyCodes.ENTER) && Utils.cmdOrCtrlPressed(e)) {
if (ctrlSend && Utils.isKeyPressed(e, KeyCodes.ENTER) && e.ctrlKey === true) {
this.handleKeyPress(e);
}
}

handleKeyPress = (e) => {
const {ctrlSend} = this.props;
if (!UserAgent.isMobile() && ((ctrlSend && Utils.cmdOrCtrlPressed(e)) || !ctrlSend)) {
if (!UserAgent.isMobile() && ((ctrlSend && e.ctrlKey) || !ctrlSend)) {
if (Utils.isKeyPressed(e, KeyCodes.ENTER) && !e.shiftKey && !e.altKey) {
e.preventDefault();
ReactDOM.findDOMNode(this.refs.editChannelHeaderTextbox).blur();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export default class EditChannelPurposeModal extends React.Component {
handleKeyDown = (e) => {
const {ctrlSend} = this.props;

if (ctrlSend && Utils.isKeyPressed(e, Constants.KeyCodes.ENTER) && Utils.cmdOrCtrlPressed(e)) {
if (ctrlSend && Utils.isKeyPressed(e, Constants.KeyCodes.ENTER) && e.ctrlKey) {
e.preventDefault();
this.handleSave(e);
} else if (!ctrlSend && Utils.isKeyPressed(e, Constants.KeyCodes.ENTER) && !e.shiftKey && !e.altKey) {
Expand Down
4 changes: 2 additions & 2 deletions components/edit_post_modal/edit_post_modal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -191,15 +191,15 @@ export default class EditPostModal extends React.PureComponent {
e.preventDefault();
this.refs.editbox.blur();
this.handleEdit();
} else if (this.props.ctrlSend && Utils.cmdOrCtrlPressed(e) && Utils.isKeyPressed(e, KeyCodes.ENTER)) {
} else if (this.props.ctrlSend && e.ctrlKey && Utils.isKeyPressed(e, KeyCodes.ENTER)) {
e.preventDefault();
this.refs.editbox.blur();
this.handleEdit();
}
}

handleKeyDown = (e) => {
if (this.props.ctrlSend && Utils.isKeyPressed(e, KeyCodes.ENTER) && Utils.cmdOrCtrlPressed(e)) {
if (this.props.ctrlSend && Utils.isKeyPressed(e, KeyCodes.ENTER) && e.ctrlKey === true) {
this.handleEdit();
}
}
Expand Down
Loading

0 comments on commit e30a3e1

Please sign in to comment.