Skip to content

Commit

Permalink
add some markdown support for descriptions and actions
Browse files Browse the repository at this point in the history
  • Loading branch information
rloomans committed Dec 13, 2016
1 parent 7cc2f1c commit 23c3ac0
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 44 deletions.
7 changes: 6 additions & 1 deletion client/js/components/assessment/assessmentReport.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ var _ = require('lodash')
var PlotlyComponent = require('./plotlyComponent')
var ReactBootstrap = require('react-bootstrap')
var Table = ReactBootstrap.Table
var ReactMarkdown = require('react-markdown')

var AssessmentReport = React.createClass({
propTypes: {
Expand Down Expand Up @@ -116,7 +117,11 @@ var AssessmentReport = React.createClass({
<td style={{verticalAlign: 'middle'}}>{attribute.name}</td>
<td className='text-center' style={currentStyle}>{currentRating ? currentRating.name : '-'}</td>
<td className='text-center' style={targetStyle}>{targetRating ? targetRating.name : '-'}</td>
<td>{measurement ? measurement.action : '-'}</td>
<td>
{measurement && measurement.action
? <ReactMarkdown escapeHtml source={measurement.action} />
: '-'}
</td>
</tr>
)
}, this))
Expand Down
44 changes: 23 additions & 21 deletions client/js/components/assessment/attribute.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ var _ = require('lodash')
var Panel = ReactBootstrap.Panel
var Alert = ReactBootstrap.Alert
var ListGroup = ReactBootstrap.ListGroup
var ReactMarkdown = require('react-markdown')

var Attribute = React.createClass({
propTypes: {
Expand Down Expand Up @@ -106,27 +107,28 @@ var Attribute = React.createClass({
}

return (
<Panel
header={(this.state.attribute && this.state.attribute.name) ? this.state.attribute.name : ''}
bsStyle='primary'>
<Alert
bsStyle='warning'
className={this.state.attribute && this.state.attribute.desc_class ? this.state.attribute.desc_class : ''}>
{this.state.attribute && this.state.attribute.desc ? this.state.attribute.desc : ''}
</Alert>
<ObserveFormControl
measurement={this.state.measurement}
syncMeasurement={this.props.syncMeasurement}
onObservationChange={this.onObservationChange}
onActionChange={this.onActionChange}
attributeId={(this.state.attribute) ? this.state.attribute.id : null}
disabled={this.props.disabled}
/>
<Loader loaded={!this.props.measureSyncActivity} />
<ListGroup fill>
{ratingList}
</ListGroup>
</Panel>
<Loader loaded={this.state.attribute}>
{this.state.attribute &&
<Panel header={this.state.attribute.name || ''} bsStyle='primary'>
<Alert bsStyle='warning'>
<ReactMarkdown escapeHtml
source={this.state.attribute.desc || ''}
className={this.state.attribute.desc_class || ''} />
</Alert>
<ObserveFormControl
measurement={this.state.measurement}
syncMeasurement={this.props.syncMeasurement}
onObservationChange={this.onObservationChange}
onActionChange={this.onActionChange}
attributeId={(this.state.attribute) ? this.state.attribute.id : null}
disabled={this.props.disabled}
/>
<Loader loaded={!this.props.measureSyncActivity} />
<ListGroup fill>
{ratingList}
</ListGroup>
</Panel>}
</Loader>
)
}
})
Expand Down
2 changes: 1 addition & 1 deletion client/js/components/common/announcements.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ var Announcements = React.createClass({
<Accordion>
{ this.state.announcements.map(function (announcement) {
return <Panel bsStyle={announcement.style} header={announcement.title} key={announcement.id}>
<ReactMarkdown source={announcement.content} />
<ReactMarkdown escapeHtml source={announcement.content} />
</Panel>
})}
</Accordion>
Expand Down
65 changes: 44 additions & 21 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1424,7 +1424,7 @@ cheerio@^0.22.0:
lodash.reject "^4.4.0"
lodash.some "^4.4.0"

chokidar@1.6.0:
chokidar@1.6.0, chokidar@^1.0.0:
version "1.6.0"
resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-1.6.0.tgz#90c32ad4802901d7713de532dc284e96a63ad058"
dependencies:
Expand All @@ -1439,21 +1439,6 @@ chokidar@1.6.0:
optionalDependencies:
fsevents "^1.0.0"

chokidar@^1.0.0:
version "1.6.1"
resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-1.6.1.tgz#2f4447ab5e96e50fb3d789fd90d4c72e0e4c70c2"
dependencies:
anymatch "^1.3.0"
async-each "^1.0.0"
glob-parent "^2.0.0"
inherits "^2.0.1"
is-binary-path "^1.0.0"
is-glob "^2.0.0"
path-is-absolute "^1.0.0"
readdirp "^2.0.0"
optionalDependencies:
fsevents "^1.0.0"

cipher-base@^1.0.0, cipher-base@^1.0.1:
version "1.0.3"
resolved "https://registry.yarnpkg.com/cipher-base/-/cipher-base-1.0.3.tgz#eeabf194419ce900da3018c207d212f2a6df0a07"
Expand Down Expand Up @@ -1653,6 +1638,24 @@ commander@~2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/commander/-/commander-2.1.0.tgz#d121bbae860d9992a3d517ba96f56588e47c6781"

commonmark-react-renderer@^4.2.4:
version "4.3.2"
resolved "http://nexus.int.corp.sun/content/groups/publicnpm/commonmark-react-renderer/-/commonmark-react-renderer-4.3.2.tgz#f30cdebd66141eef45ccd2d82fc00861e1e1f747"
dependencies:
in-publish "^2.0.0"
lodash.assign "^4.2.0"
lodash.isplainobject "^4.0.6"
pascalcase "^0.1.1"
xss-filters "^1.2.6"

commonmark@^0.24.0:
version "0.24.0"
resolved "http://nexus.int.corp.sun/content/groups/publicnpm/commonmark/-/commonmark-0.24.0.tgz#b80de0182c546355643aa15db12bfb282368278f"
dependencies:
entities "~ 1.1.1"
mdurl "~ 1.0.1"
string.prototype.repeat "^0.2.0"

compare-angle@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/compare-angle/-/compare-angle-1.0.1.tgz#a4eb63416ea3c747fc6bd6c8b63668b4de4fa129"
Expand Down Expand Up @@ -2387,7 +2390,7 @@ engine.io@1.7.0:
engine.io-parser "1.3.0"
ws "1.1.1"

entities@^1.1.1, entities@~1.1.1:
entities@^1.1.1, "entities@~ 1.1.1", entities@~1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/entities/-/entities-1.1.1.tgz#6e5c2d0a5621b5dadaecef80b90edfb5cd7772f0"

Expand Down Expand Up @@ -5043,7 +5046,7 @@ lodash.isequal@^3.0.4:
lodash._baseisequal "^3.0.0"
lodash._bindcallback "^3.0.0"

lodash.isplainobject@^4.0.4:
lodash.isplainobject@^4.0.4, lodash.isplainobject@^4.0.6:
version "4.0.6"
resolved "https://registry.yarnpkg.com/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz#7c526a52d89b45c45cc690b88163be0497f550cb"

Expand Down Expand Up @@ -5214,13 +5217,13 @@ mapbox-gl-function@^1.2.1:
version "1.3.0"
resolved "https://registry.yarnpkg.com/mapbox-gl-function/-/mapbox-gl-function-1.3.0.tgz#cee3d95750c189d45e83ab41a0a57fc2a8a509bc"

"mapbox-gl-shaders@github:mapbox/mapbox-gl-shaders#de2ab007455aa2587c552694c68583f94c9f2747":
mapbox-gl-shaders@mapbox/mapbox-gl-shaders#de2ab007455aa2587c552694c68583f94c9f2747:
version "1.0.0"
resolved "https://codeload.github.com/mapbox/mapbox-gl-shaders/tar.gz/de2ab007455aa2587c552694c68583f94c9f2747"
dependencies:
brfs "^1.4.0"

"mapbox-gl-style-spec@github:mapbox/mapbox-gl-style-spec#83b1a3e5837d785af582efd5ed1a212f2df6a4ae":
mapbox-gl-style-spec@mapbox/mapbox-gl-style-spec#83b1a3e5837d785af582efd5ed1a212f2df6a4ae:
version "8.8.0"
resolved "https://codeload.github.com/mapbox/mapbox-gl-style-spec/tar.gz/83b1a3e5837d785af582efd5ed1a212f2df6a4ae"
dependencies:
Expand Down Expand Up @@ -5333,7 +5336,7 @@ matrix-camera-controller@^2.1.1:
gl-vec3 "^1.0.3"
mat4-interpolate "^1.0.3"

mdurl@^1.0.1:
mdurl@^1.0.1, "mdurl@~ 1.0.1":
version "1.0.1"
resolved "https://registry.yarnpkg.com/mdurl/-/mdurl-1.0.1.tgz#fe85b2ec75a59037f2adfec100fd6c601761152e"

Expand Down Expand Up @@ -6082,6 +6085,10 @@ parseurl@~1.3.1:
version "1.3.1"
resolved "https://registry.yarnpkg.com/parseurl/-/parseurl-1.3.1.tgz#c8ab8c9223ba34888aa64a297b28853bec18da56"

pascalcase@^0.1.1:
version "0.1.1"
resolved "http://nexus.int.corp.sun/content/groups/publicnpm/pascalcase/-/pascalcase-0.1.1.tgz#b363e55e8006ca6fe21784d2db22bd15d7917f14"

path-browserify@~0.0.0:
version "0.0.0"
resolved "https://registry.yarnpkg.com/path-browserify/-/path-browserify-0.0.0.tgz#a0b870729aae214005b7d5032ec2cbbb0fb4451a"
Expand Down Expand Up @@ -6529,6 +6536,14 @@ react-loader@^2.4.0:
dependencies:
spin.js "2.x"

react-markdown@^2.4.2:
version "2.4.2"
resolved "http://nexus.int.corp.sun/content/groups/publicnpm/react-markdown/-/react-markdown-2.4.2.tgz#0e9f80f28e62245b782a1915be7724fa93b04999"
dependencies:
commonmark "^0.24.0"
commonmark-react-renderer "^4.2.4"
in-publish "^2.0.0"

react-overlays@^0.6.10:
version "0.6.10"
resolved "https://registry.yarnpkg.com/react-overlays/-/react-overlays-0.6.10.tgz#e7e52dad47f00a0fc784eb044428c3a9e874bfa3"
Expand Down Expand Up @@ -7710,6 +7725,10 @@ string.prototype.codepointat@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/string.prototype.codepointat/-/string.prototype.codepointat-0.2.0.tgz#6b26e9bd3afcaa7be3b4269b526de1b82000ac78"

string.prototype.repeat@^0.2.0:
version "0.2.0"
resolved "http://nexus.int.corp.sun/content/groups/publicnpm/string.prototype.repeat/-/string.prototype.repeat-0.2.0.tgz#aba36de08dcee6a5a337d49b2ea1da1b28fc0ecf"

string.prototype.trim@~1.1.2:
version "1.1.2"
resolved "https://registry.yarnpkg.com/string.prototype.trim/-/string.prototype.trim-1.1.2.tgz#d04de2c89e137f4d7d206f086b5ed2fae6be8cea"
Expand Down Expand Up @@ -8639,6 +8658,10 @@ xmlhttprequest-ssl@1.5.1:
version "1.5.1"
resolved "https://registry.yarnpkg.com/xmlhttprequest-ssl/-/xmlhttprequest-ssl-1.5.1.tgz#3b7741fea4a86675976e908d296d4445961faa67"

xss-filters@^1.2.6:
version "1.2.7"
resolved "http://nexus.int.corp.sun/content/groups/publicnpm/xss-filters/-/xss-filters-1.2.7.tgz#59fa1de201f36f2f3470dcac5f58ccc2830b0a9a"

"xtend@>=4.0.0 <4.1.0-0", xtend@^4.0.0, xtend@^4.0.1, xtend@~4.0.0:
version "4.0.1"
resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.1.tgz#a5c6d532be656e23db820efb943a1f04998d63af"
Expand Down

0 comments on commit 23c3ac0

Please sign in to comment.