From bcb8a568bcfb182f9f4e661104a9f81d4e1de30b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Espino=20Garc=C3=ADa?= Date: Wed, 1 Jul 2020 14:30:02 +0200 Subject: [PATCH] Render markdown on custom post types (#85) --- webapp/src/components/post_type_todo/index.js | 2 ++ .../src/components/post_type_todo/post_type_todo.jsx | 11 +++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/webapp/src/components/post_type_todo/index.js b/webapp/src/components/post_type_todo/index.js index ec961d65..f4454307 100644 --- a/webapp/src/components/post_type_todo/index.js +++ b/webapp/src/components/post_type_todo/index.js @@ -5,12 +5,14 @@ import {connect} from 'react-redux'; import {bindActionCreators} from 'redux'; import {remove, complete, accept} from '../../actions'; +import {getSiteURL} from '../../selectors'; import PostTypeTodo from './post_type_todo'; function mapStateToProps(state, ownProps) { return { ...ownProps, + siteURL: getSiteURL(), pendingAnswer: state['plugins-com.mattermost.plugin-todo'].inIssues.some((issue) => issue.id === ownProps.post.props.issueId), }; } diff --git a/webapp/src/components/post_type_todo/post_type_todo.jsx b/webapp/src/components/post_type_todo/post_type_todo.jsx index 475ba3af..1b12594d 100644 --- a/webapp/src/components/post_type_todo/post_type_todo.jsx +++ b/webapp/src/components/post_type_todo/post_type_todo.jsx @@ -7,11 +7,14 @@ import RemoveButton from '../buttons/remove'; import CompleteButton from '../buttons/complete'; import AcceptButton from '../buttons/accept'; +const PostUtils = window.PostUtils; // import the post utilities + export default class PostTypeTodo extends React.PureComponent { static propTypes = { post: PropTypes.object.isRequired, pendingAnswer: PropTypes.bool.isRequired, theme: PropTypes.object.isRequired, + siteURL: PropTypes.string.isRequired, actions: PropTypes.shape({ complete: PropTypes.func.isRequired, remove: PropTypes.func.isRequired, @@ -31,8 +34,12 @@ export default class PostTypeTodo extends React.PureComponent { const style = getStyle(this.props.theme); const preText = 'Automated message'; - const title = this.props.post.props.message; - const subtitle = this.props.post.props.todo; + + const titleHTMLFormattedText = PostUtils.formatText(this.props.post.props.message, {siteURL: this.props.siteURL}); + const title = PostUtils.messageHtmlToComponent(titleHTMLFormattedText); + + const subtitleHTMLFormattedText = PostUtils.formatText(this.props.post.props.todo, {siteURL: this.props.siteURL}); + const subtitle = PostUtils.messageHtmlToComponent(subtitleHTMLFormattedText); const content = (