Skip to content

Commit

Permalink
Parse markdown in file instructions and segment notes (#3102)
Browse files Browse the repository at this point in the history
* Parse markdown in file instructions and segment notes

* Update Submodule

* Update submodule

* Update submodule

* Update submodule

* Change modal label

* dependencies

---------

Co-authored-by: Mauro Cassani <maurocassani1978@gmail.com>
  • Loading branch information
riccio82 and mauretto78 authored Feb 20, 2024
1 parent 2f8e8c6 commit 91b236b
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 38 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
"react-tagsinput": "^3.19.0",
"react-transition-group": "^4.2.2",
"react-virtual": "^2.10.4",
"showdown": "^2.0.0",
"sprintf-js": "^1.1.2"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion plugins/translated
2 changes: 1 addition & 1 deletion plugins/uber
Submodule uber updated from c5f7e7 to dd644f
5 changes: 5 additions & 0 deletions public/css/sass/modals/instructionsModal.scss
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@
line-height: 26px;
word-break: break-all;
}
blockquote {
border-left: 5px solid #ccc;
margin: 1.5em 10px;
padding: 0.5em 10px;
}
}

.description {
Expand Down
11 changes: 8 additions & 3 deletions public/css/sass/segment-notes.scss
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,21 @@ div.segment-notes ul.graysmall li span.note-label {
font-size: 16px;
word-break: break-word;
white-space: pre-wrap;
display: flex;
align-content: center;
}
.segments-notes-container .metadata-notes {
display: flex;
flex-wrap: wrap;
flex-direction: row;
}

.segments-notes-container div.note p {
margin: 0;
line-height: 25px;
.segments-notes-container div.note {
p,
span {
margin: 0;
line-height: 20px;
}
}

.segments-notes-container div.note p a {
Expand Down
13 changes: 2 additions & 11 deletions public/js/cat_source/es6/components/modals/JobMetadataModal.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,11 @@
import showdown from 'showdown'
import React from 'react'

import CommonUtils from '../../utils/commonUtils'
import TextUtils from '../../utils/textUtils'

class JobMetadataModal extends React.Component {
constructor(props) {
super(props)
this.state = {}
this.converter = new showdown.Converter()
this.converter.setOption('literalMidWordUnderscores', true)
// this.instructions =
// '**Client:** Product - Rider \n' +
// '**Domain:** UI \n' +
// '**Note:** Link to file a query: http://t.uber.com/riderq Rider \n' +
// ' Screen Search: https://docs.google.com/document/d/19Dk92t9NXdN.';
}
createFileList() {
const {currentFile, currentFilePart} = this.props
Expand Down Expand Up @@ -89,7 +80,7 @@ class JobMetadataModal extends React.Component {
}

getHtml(text) {
return TextUtils.replaceUrl(text.replace(/[ ]*\n/g, '<br>\n'))
return text
}

componentDidMount() {
Expand Down Expand Up @@ -123,7 +114,7 @@ class JobMetadataModal extends React.Component {
{this.props.files &&
this.props.files.find((file) => file.metadata.instructions) && (
<div>
<h2>Files instructions</h2>
<h2>File instructions</h2>
<div
className="ui styled fluid accordion"
ref={(acc) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ function SegmentFooter() {
getMetadataNoteTemplate: () =>
segment.metadata?.length > 0 ? segment.metadata : null,
allowHTML: () => '',
getNoteContentStructure: (note) => note,
}
const notes =
SegmentFooterTabMessages.prototype.getNotes.call(tabMessagesContext)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,39 +15,40 @@ class SegmentFooterTabMessages extends React.Component {
({meta_key}) => meta_key !== 'sizeRestriction',
)
}

getNoteContentStructure(note) {
return TEXT_UTILS.getContentWithAllowedLinkRedirect(note).length > 1
? TEXT_UTILS.getContentWithAllowedLinkRedirect(note).map(
(content, index) =>
typeof content === 'object' && content.isLink ? (
<a key={index} href={content.link} target="_blank">
{content.link}
</a>
) : (
content
),
)
: note
}
getNotes() {
let notesHtml = []
let self = this

const getNoteContentStructure = (note) =>
TEXT_UTILS.getContentWithAllowedLinkRedirect(note).length > 1
? TEXT_UTILS.getContentWithAllowedLinkRedirect(note).map(
(content, index) =>
typeof content === 'object' && content.isLink ? (
<a key={index} href={content.link} target="_blank">
{content.link}
</a>
) : (
content
),
)
: note

if (this.props.notes) {
this.props.notes.forEach(function (item, index) {
this.props.notes.forEach((item, index) => {
if (item.note && item.note !== '') {
if (
self.excludeMatchingNotesRegExp &&
self.excludeMatchingNotesRegExp.test(item.note)
this.excludeMatchingNotesRegExp &&
this.excludeMatchingNotesRegExp.test(item.note)
) {
return
}
let note = item.note
let html = (
<div className="note" key={'note-' + index}>
<span className="note-label">Note: </span>
<span>{getNoteContentStructure(note)}</span>
<span
dangerouslySetInnerHTML={{
__html: this.getNoteContentStructure(note),
}}
/>
</div>
)
notesHtml.push(html)
Expand Down

0 comments on commit 91b236b

Please sign in to comment.