diff --git a/app/components/ProjectLog/GeneralAction/GeneralAction.css b/app/components/ProjectLog/GeneralAction/GeneralAction.css index 5f82ba17..8efdfd5a 100644 --- a/app/components/ProjectLog/GeneralAction/GeneralAction.css +++ b/app/components/ProjectLog/GeneralAction/GeneralAction.css @@ -7,3 +7,54 @@ text-transform: capitalize; padding-right: 10px; } + +.markdownContainer { + display: block; + margin-top: 5px; + padding: 10px; + border-radius: 4px; + border: 1px solid rgb(213 213 213); + white-space: normal; +} + +.markdownFull { + display: block; +} + +.markdownCollapsed { + display: block; + max-height: 100px; + overflow: hidden; + position: relative; +} + +.markdownCollapsed::after { + content: ''; + position: absolute; + bottom: 0; + left: 0; + right: 0; + height: 20px; +} + +.toggleButton { + display: block; + width: 100%; + background: none; + border: none; + color: #1976d2; + cursor: pointer; + padding: 10px 0 5px; + font-size: 0.85rem; + font-weight: 500; + border-top: 1px solid transparent; +} + +.toggleButton:hover { + text-decoration: underline; +} + +.emptyContent { + color: #999; + font-style: italic; +} diff --git a/app/components/ProjectLog/GeneralAction/GeneralAction.js b/app/components/ProjectLog/GeneralAction/GeneralAction.js index 4b4af398..58748a40 100644 --- a/app/components/ProjectLog/GeneralAction/GeneralAction.js +++ b/app/components/ProjectLog/GeneralAction/GeneralAction.js @@ -1,12 +1,52 @@ -import React from 'react'; +import React, { useState } from 'react'; import PropTypes from 'prop-types'; +import ReactMarkdown from 'react-markdown'; +import gfm from 'remark-gfm'; +import Constants from '../../../constants/constants'; import styles from './GeneralAction.css'; +const CollapsibleMarkdown = ({ content }) => { + const [expanded, setExpanded] = useState(false); + + // Consider it "long" if it's over a certain length so we can show the toggle. + const isLong = content && content.length > 200; + + return ( +
+
+ +
+ {isLong && ( + + )} +
+ ); +}; + +CollapsibleMarkdown.propTypes = { + content: PropTypes.string, +}; + const formatValue = (value) => { + if (Array.isArray(value)) { + return value.length > 0 ? value.join(', ') : (Empty); + } if (typeof value === 'object' && value !== null) { + if (value.contentType === Constants.DescriptionContentType.MARKDOWN) { + if (!value.content) { + return (Empty description); + } + return ; + } return JSON.stringify(value); } - return Array.isArray(value) ? value.join(', ') : value; + return value || ''; }; const generateRow = (key, value) => {