From 58f78ce50984cf02481b4f46883119df5d0c20af Mon Sep 17 00:00:00 2001 From: Sai Deepesh Date: Mon, 26 Jun 2023 19:51:20 +0530 Subject: [PATCH] [MM-23418] : Migrate "components/admin_console/schema_text.jsx" and tests to Typescript (#23614) --- ...est.jsx.snap => schema_text.test.tsx.snap} | 0 ...ema_text.test.jsx => schema_text.test.tsx} | 0 .../{schema_text.jsx => schema_text.tsx} | 30 +++++++++---------- 3 files changed, 15 insertions(+), 15 deletions(-) rename webapp/channels/src/components/admin_console/__snapshots__/{schema_text.test.jsx.snap => schema_text.test.tsx.snap} (100%) rename webapp/channels/src/components/admin_console/{schema_text.test.jsx => schema_text.test.tsx} (100%) rename webapp/channels/src/components/admin_console/{schema_text.jsx => schema_text.tsx} (72%) 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() {