diff --git a/webapp/channels/src/components/admin_console/__snapshots__/schema_text.test.jsx.snap b/webapp/channels/src/components/admin_console/__snapshots__/schema_text.test.tsx.snap similarity index 100% rename from webapp/channels/src/components/admin_console/__snapshots__/schema_text.test.jsx.snap rename to webapp/channels/src/components/admin_console/__snapshots__/schema_text.test.tsx.snap diff --git a/webapp/channels/src/components/admin_console/schema_text.test.jsx b/webapp/channels/src/components/admin_console/schema_text.test.tsx similarity index 100% rename from webapp/channels/src/components/admin_console/schema_text.test.jsx rename to webapp/channels/src/components/admin_console/schema_text.test.tsx diff --git a/webapp/channels/src/components/admin_console/schema_text.jsx b/webapp/channels/src/components/admin_console/schema_text.tsx similarity index 72% rename from webapp/channels/src/components/admin_console/schema_text.jsx rename to webapp/channels/src/components/admin_console/schema_text.tsx index 78510a33d1..7ade3bdec7 100644 --- a/webapp/channels/src/components/admin_console/schema_text.jsx +++ b/webapp/channels/src/components/admin_console/schema_text.tsx @@ -2,24 +2,20 @@ // See LICENSE.txt for license information. import marked from 'marked'; -import PropTypes from 'prop-types'; import React from 'react'; import {FormattedMessage} from 'react-intl'; import FormattedMarkdownMessage, {CustomRenderer} from 'components/formatted_markdown_message'; -export default class SchemaText extends React.PureComponent { - static propTypes = { - isMarkdown: PropTypes.bool, - isTranslated: PropTypes.bool, - text: PropTypes.oneOfType([ - PropTypes.string, - PropTypes.object, - ]).isRequired, - textDefault: PropTypes.string, - textValues: PropTypes.object, - }; +type Props = { + isMarkdown?: boolean; + isTranslated?: boolean; + text: string | object; + textDefault?: string; + textValues?: Record; +} +export default class SchemaText extends React.PureComponent { static defaultProps = { isTranslated: true, }; @@ -56,8 +52,12 @@ export default class SchemaText extends React.PureComponent { }; renderUntranslated = () => { - if (this.props.isMarkdown) { - const html = marked(this.props.text, { + const {isMarkdown, text} = this.props; + if (isMarkdown) { + if (typeof text === 'object') { + return text; + } + const html = marked(text, { breaks: true, sanitize: true, renderer: new CustomRenderer(), @@ -66,7 +66,7 @@ export default class SchemaText extends React.PureComponent { return ; } - return {this.props.text}; + return {text}; }; render() {