Skip to content

Commit

Permalink
MM-10977: Search in attachment contents. (mattermost#1458)
Browse files Browse the repository at this point in the history
  • Loading branch information
grundleborg authored and hmhealey committed Jul 18, 2018
1 parent 854a0fd commit df5601f
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 2 deletions.
10 changes: 9 additions & 1 deletion components/post_view/post_attachment.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ export default class PostAttachment extends React.PureComponent {
* The attachment to render
*/
attachment: PropTypes.object.isRequired,

/**
* Options specific to text formatting
*/
options: PropTypes.object,
}

constructor(props) {
Expand Down Expand Up @@ -272,7 +277,10 @@ export default class PostAttachment extends React.PureComponent {

text = (
<div className='attachment__text'>
<Markdown message={attachmentText || ''}/>
<Markdown
message={attachmentText || ''}
options={this.props.options}
/>
{shouldCollapse &&
<div>
<a
Expand Down
6 changes: 6 additions & 0 deletions components/post_view/post_attachment_list.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ export default class PostAttachmentList extends React.PureComponent {
* Array of attachments to render
*/
attachments: PropTypes.array.isRequired,

/**
* Options specific to text formatting
*/
options: PropTypes.object,
}

render() {
Expand All @@ -28,6 +33,7 @@ export default class PostAttachmentList extends React.PureComponent {
attachment={attachment}
postId={this.props.postId}
key={'att_' + i}
options={this.props.options}
/>
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ export default class PostBodyAdditionalContent extends React.PureComponent {
* If an image proxy is enabled.
*/
hasImageProxy: PropTypes.bool.isRequired,

/**
* Options specific to text formatting
*/
options: PropTypes.object,
}

static defaultProps = {
Expand Down Expand Up @@ -109,6 +114,7 @@ export default class PostBodyAdditionalContent extends React.PureComponent {
attachments={attachments}
postId={this.props.post.id}
key={this.props.post.id}
options={this.props.options}
/>
);
}
Expand Down
8 changes: 7 additions & 1 deletion components/search_results_item/search_results_item.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,13 @@ export default class SearchResultsItem extends React.PureComponent {
);

message = (
<PostBodyAdditionalContent post={post}>
<PostBodyAdditionalContent
post={post}
options={{
searchTerm: this.props.term,
searchMatches: this.props.matches,
}}
>
<PostMessageContainer
post={post}
options={{
Expand Down
12 changes: 12 additions & 0 deletions tests/components/__snapshots__/search_results_item.test.jsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,12 @@ exports[`components/SearchResultsItem should match snapshot for DM 1`] = `
className=" post--edited"
>
<Connect(PostBodyAdditionalContent)
options={
Object {
"searchMatches": undefined,
"searchTerm": "test",
}
}
post={
Object {
"channel_id": "channel_id",
Expand Down Expand Up @@ -374,6 +380,12 @@ exports[`components/SearchResultsItem should match snapshot for channel 1`] = `
className=" post--edited"
>
<Connect(PostBodyAdditionalContent)
options={
Object {
"searchMatches": undefined,
"searchTerm": "test",
}
}
post={
Object {
"channel_id": "channel_id",
Expand Down

0 comments on commit df5601f

Please sign in to comment.