diff --git a/public/js/cat_source/es6/components/quality_report/SegmentQRLine.js b/public/js/cat_source/es6/components/quality_report/SegmentQRLine.js
index ce0419087c..0d23077c49 100644
--- a/public/js/cat_source/es6/components/quality_report/SegmentQRLine.js
+++ b/public/js/cat_source/es6/components/quality_report/SegmentQRLine.js
@@ -1,10 +1,24 @@
-import React from 'react'
-
-class SegmentQRLine extends React.Component {
- allowHTML(string) {
+import React, {useRef} from 'react'
+const SegmentQRLine = ({
+ showSuggestionSource = false,
+ segment,
+ classes,
+ onClickLabel,
+ label,
+ showDiffButton,
+ diffActive = false,
+ onClickDiff,
+ text,
+ showSegmentWords = false,
+ showIceMatchInfo = false,
+ tte,
+ showIsPretranslated,
+}) => {
+ const textRef = useRef()
+ const allowHTML = (string) => {
return {__html: string}
}
- getTimeToEdit(tte) {
+ const getTimeToEdit = (tte) => {
let str_pad_left = function (string, pad, length) {
return (new Array(length + 1).join(pad) + string).slice(-length)
}
@@ -32,135 +46,134 @@ class SegmentQRLine extends React.Component {
return str_pad_left(seconds, '0', 2) + "''"
}
}
- render() {
- let suggestionMatch, suggestionMatchClass
- if (this.props.showSuggestionSource) {
- suggestionMatch =
- this.props.segment.get('match_type') === 'ICE'
- ? 101
- : parseInt(this.props.segment.get('suggestion_match'))
- suggestionMatchClass =
- suggestionMatch === 101
- ? 'per-blu'
- : suggestionMatch === 100
+ let suggestionMatch, suggestionMatchClass
+ if (showSuggestionSource) {
+ suggestionMatch =
+ segment.get('match_type') === 'ICE'
+ ? 101
+ : parseInt(segment.get('suggestion_match'))
+ suggestionMatchClass =
+ suggestionMatch === 101
+ ? 'per-blu'
+ : suggestionMatch === 100
? 'per-green'
: suggestionMatch > 0 && suggestionMatch <= 99
- ? 'per-orange'
- : ''
+ ? 'per-orange'
+ : ''
+ }
+
+ const copyText = async (e) => {
+ const internalClipboard = document.getSelection()
+ if (internalClipboard) {
+ e.preventDefault()
+ // Get plain text form internalClipboard fragment
+ const plainText = internalClipboard
+ .toString()
+ .replace(new RegExp(String.fromCharCode(parseInt('200B', 16)), 'g'), '')
+ .replace(/ยท/g, ' ')
+ return await navigator.clipboard.writeText(plainText)
}
+ }
- return (
-
- {this.props.onClickLabel ? (
-
- {this.props.label}
- {this.props.showDiffButton ? (
-
- ) : null}
-
- ) : (
-
- {this.props.label}
-
- )}
+ return (
+
+ {onClickLabel ? (
+
+ {label}
+ {showDiffButton ? (
+
+ ) : null}
+
+ ) : (
+
+ {label}
+
+ )}
-
+
- {this.props.showSegmentWords ? (
-
-
Words:
-
- {parseInt(this.props.segment.get('raw_word_count'))}
-
+ {showSegmentWords ? (
+
+
Words:
+
+ {parseInt(segment.get('raw_word_count'))}
- ) : null}
+
+ ) : null}
- {this.props.showSuggestionSource ? (
-
-
- {this.props.segment.get('suggestion_source')}
-
- {this.props.segment.get('suggestion_source') &&
- this.props.segment.get('suggestion_source') !== 'MT' ? (
-
- {suggestionMatch}%
-
- ) : null}
+ {showSuggestionSource ? (
+
+
+ {segment.get('suggestion_source')}
- ) : null}
-
- {this.props.showIceMatchInfo &&
- this.props.segment.get('ice_locked') === '1' ? (
-
- {this.props.segment.get('ice_locked') === '1' ? (
-
-
ICE Match
- {this.props.segment.get('ice_modified') ? (
-
(Modified)
- ) : null}
-
- ) : null}
+ {segment.get('suggestion_source') &&
+ segment.get('suggestion_source') !== 'MT' ? (
+
+ {suggestionMatch}%
+
+ ) : null}
+
+ ) : null}
- {this.props.tte ? (
-
-
TTE:
-
-
{this.getTimeToEdit(this.props.tte)}
-
-
- ) : null}
-
- ) : this.props.tte ? (
-
-
TTE:
+ {showIceMatchInfo && segment.get('ice_locked') === '1' ? (
+
+ {segment.get('ice_locked') === '1' ? (
-
{this.getTimeToEdit(this.props.tte)}
+
ICE Match
+ {segment.get('ice_modified') ?
(Modified)
: null}
-
- ) : null}
+ ) : null}
- {this.props.showIsPretranslated ? (
-
-
-
Pre-Translated
+ {tte ? (
+
+ ) : null}
+
+ ) : tte ? (
+
+
TTE:
+
- ) : null}
- {!(
- this.props.showIceMatchInfo &&
- this.props.segment.get('ice_locked') === '1'
- ) &&
- !this.props.showSuggestionSource &&
- !this.props.showSegmentWords &&
- !this.props.tte &&
- !this.props.showIsPretranslated ? (
-
- ) : null}
-
- )
- }
-}
+
+ ) : null}
-SegmentQRLine.defaultProps = {
- showSegmentWords: false,
- showSuggestionSource: false,
- showIceMatchInfo: false,
- diffActive: false,
+ {showIsPretranslated ? (
+
+ ) : null}
+ {!(showIceMatchInfo && segment.get('ice_locked') === '1') &&
+ !showSuggestionSource &&
+ !showSegmentWords &&
+ !tte &&
+ !showIsPretranslated ? (
+
+ ) : null}
+
+ )
}
export default SegmentQRLine