Unverified Commit 276ff528 authored by Tamika Tannis's avatar Tamika Tannis Committed by GitHub

feat: Support markdown for dashboard descriptions (#506)

* Support markdown for dashboard descriptions

* Code cleanup

* Fix test for build to pass; Need to re-write so this doesn't keep happening

* Fix test for build to pass; Need to re-write so this doesn't keep happening
parent 98ed705d
...@@ -119,10 +119,6 @@ $aside-separation-space: 40px; ...@@ -119,10 +119,6 @@ $aside-separation-space: 40px;
.editable-text { .editable-text {
font-size: 16px; font-size: 16px;
.markdown-wrapper {
font-size: 16px;
}
} }
.avatar-label-component { .avatar-label-component {
...@@ -130,6 +126,13 @@ $aside-separation-space: 40px; ...@@ -130,6 +126,13 @@ $aside-separation-space: 40px;
color: $text-primary; color: $text-primary;
} }
} }
.markdown-wrapper {
font-size: 16px;
> p {
margin: 0;
}
}
} }
> .right-panel { > .right-panel {
......
import * as React from 'react'; import * as React from 'react';
import * as ReactMarkdown from 'react-markdown';
import * as History from 'history'; import * as History from 'history';
import { shallow } from 'enzyme'; import { shallow } from 'enzyme';
...@@ -182,6 +183,14 @@ describe('DashboardPage', () => { ...@@ -182,6 +183,14 @@ describe('DashboardPage', () => {
}); });
describe('renders description', () => { describe('renders description', () => {
it('using a ReactMarkdown component', () => {
const markdown = wrapper.find(ReactMarkdown);
expect(markdown.exists()).toBe(true);
expect(markdown.props()).toMatchObject({
source: props.dashboard.description,
});
});
it('with link to add description if none exists', () => { it('with link to add description if none exists', () => {
const { wrapper } = setup({ const { wrapper } = setup({
dashboard: { dashboard: {
......
...@@ -5,6 +5,8 @@ import { Link } from 'react-router-dom'; ...@@ -5,6 +5,8 @@ import { Link } from 'react-router-dom';
import { RouteComponentProps } from 'react-router'; import { RouteComponentProps } from 'react-router';
import * as qs from 'simple-query-string'; import * as qs from 'simple-query-string';
import * as ReactMarkdown from 'react-markdown';
import AvatarLabel from 'components/common/AvatarLabel'; import AvatarLabel from 'components/common/AvatarLabel';
import Breadcrumb from 'components/common/Breadcrumb'; import Breadcrumb from 'components/common/Breadcrumb';
import BookmarkIcon from 'components/common/Bookmark/BookmarkIcon'; import BookmarkIcon from 'components/common/Bookmark/BookmarkIcon';
...@@ -212,8 +214,8 @@ export class DashboardPage extends React.Component< ...@@ -212,8 +214,8 @@ export class DashboardPage extends React.Component<
)}`} )}`}
> >
{hasDescription && ( {hasDescription && (
<div className="body-2 and text-primary"> <div className="markdown-wrapper">
{dashboard.description} <ReactMarkdown source={dashboard.description} />
</div> </div>
)} )}
{!hasDescription && ( {!hasDescription && (
......
...@@ -61,6 +61,7 @@ class MetadataTest(unittest.TestCase): ...@@ -61,6 +61,7 @@ class MetadataTest(unittest.TestCase):
'schema': 'test_schema', 'schema': 'test_schema',
'name': 'test_table', 'name': 'test_table',
'description': 'This is a test', 'description': 'This is a test',
'resource_reports': [],
'programmatic_descriptions': [ 'programmatic_descriptions': [
{'source': 'c_1', 'text': 'description c'}, {'source': 'c_1', 'text': 'description c'},
{'source': 'a_1', 'text': 'description a'}, {'source': 'a_1', 'text': 'description a'},
...@@ -136,6 +137,7 @@ class MetadataTest(unittest.TestCase): ...@@ -136,6 +137,7 @@ class MetadataTest(unittest.TestCase):
'text': 'description c' 'text': 'description c'
}, },
], ],
'resource_reports': [],
'table_writer': { 'table_writer': {
'application_url': 'https://test-test.test.test', 'application_url': 'https://test-test.test.test',
'name': 'test_name', 'name': 'test_name',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment