Commit 84c73a67 authored by Jesse Hallam's avatar Jesse Hallam Committed by Carlos Tadeu Panato Junior

MM-10789: propagate post channel_mentions to Markdown (#1304)

The `post.props.channel_mentions` structure sent by the server needed to
be passed to the Markdown component to allow merging with the already
known channels for linking.
parent c91bc9d5
......@@ -18,7 +18,7 @@ import Markdown from './markdown';
function makeGetChannelNamesMap() {
return createSelector(
getChannelsNameMapInCurrentTeam,
(state, props) => props && props.channel_mentions,
(state, props) => props && props.channelNamesMap,
(channelNamesMap, channelMentions) => {
if (channelMentions) {
return Object.assign({}, channelMentions, channelNamesMap);
......
......@@ -46,6 +46,7 @@ export default class PostMarkdown extends React.PureComponent {
// Proxy images if we have an image proxy and the server hasn't already rewritten the post's image URLs.
const proxyImages = !this.props.post || !this.props.post.message_source || this.props.post.message === this.props.post.message_source;
const channelNamesMap = this.props.post && this.props.post.props && this.props.post.props.channel_mentions;
return (
<Markdown
......@@ -53,6 +54,7 @@ export default class PostMarkdown extends React.PureComponent {
isRHS={this.props.isRHS}
message={this.props.message}
proxyImages={proxyImages}
channelNamesMap={channelNamesMap}
/>
);
}
......
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`components/PostMarkdown should render properly with a post 1`] = `
<Connect(Markdown)
channelNamesMap={
Object {
"test": Object {
"display_name": "Test",
},
}
}
imageProps={Object {}}
isRHS={false}
message="message"
proxyImages={true}
/>
`;
exports[`components/PostMarkdown should render properly with an empty post 1`] = `
<Connect(Markdown)
imageProps={Object {}}
isRHS={false}
message="message"
proxyImages={true}
/>
`;
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import React from 'react';
import {shallow} from 'enzyme';
import PostMarkdown from 'components/post_markdown/post_markdown';
describe('components/PostMarkdown', () => {
const baseProps = {
imageProps: {},
isRHS: false,
message: 'message',
post: {},
};
test('should render properly with an empty post', () => {
const wrapper = shallow(
<PostMarkdown {...baseProps}/>
);
expect(wrapper).toMatchSnapshot();
});
test('should render properly with a post', () => {
const props = {
...baseProps,
post: {
props: {
channel_mentions: {
test: {
display_name: 'Test',
},
},
},
},
};
const wrapper = shallow(
<PostMarkdown {...props}/>
);
expect(wrapper).toMatchSnapshot();
});
});
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment