diff --git a/lib/Utils/MultiCurlHandler.php b/lib/Utils/MultiCurlHandler.php index b8864ff681..160f0c17a1 100644 --- a/lib/Utils/MultiCurlHandler.php +++ b/lib/Utils/MultiCurlHandler.php @@ -399,6 +399,15 @@ public function getErrors() { return array_filter( $map ); // <- remove null array entries } + /** + * @param $tokenHash + * + * @return int + */ + public function getStatusCode( $tokenHash ) { + return (int)$this->multi_curl_info[ $tokenHash ][ 'http_code' ]; + } + public function clear(){ $this->multiCurlCloseAll(); $this->curl_headers_requests = []; @@ -428,4 +437,4 @@ protected function _callbackExecute( $record, Callable $function = null ){ return $record; } -} +} diff --git a/public/css/sass/segment-notes.scss b/public/css/sass/segment-notes.scss index 902913d877..0fa36aea2e 100644 --- a/public/css/sass/segment-notes.scss +++ b/public/css/sass/segment-notes.scss @@ -85,6 +85,12 @@ div.segment-notes ul.graysmall li span.note-label { font-weight: bold; } +.segments-notes-container div.note-style-guide > ul { + list-style-type: square; + padding-left: 14px; + margin-top: 6px; +} + .tab-preview-screenshot { text-align: center; padding-top: 10px; diff --git a/public/js/cat_source/es6/actions/SegmentActions.js b/public/js/cat_source/es6/actions/SegmentActions.js index 7656637583..22633d539a 100644 --- a/public/js/cat_source/es6/actions/SegmentActions.js +++ b/public/js/cat_source/es6/actions/SegmentActions.js @@ -365,6 +365,13 @@ const SegmentActions = { type: type, }) }, + addLexiqaStyleGuideMessages: function (sid, styleGuideMessages) { + AppDispatcher.dispatch({ + actionType: SegmentConstants.ADD_LXQ_STYLE_GUIDE_MESSAGES, + sid, + styleGuideMessages, + }) + }, selectNextSegmentDebounced: _.debounce(() => { SegmentActions.selectNextSegment() }, 100), diff --git a/public/js/cat_source/es6/components.js b/public/js/cat_source/es6/components.js index ceb469055f..cf1614869b 100644 --- a/public/js/cat_source/es6/components.js +++ b/public/js/cat_source/es6/components.js @@ -28,6 +28,7 @@ import CursorUtils from './utils/cursorUtils' import OfflineUtils from './utils/offlineUtils' import Shortcuts from './utils/shortcuts' import SegmentFooterTabMatches from './components/segments/SegmentFooterTabMatches' +import {pluginOptions as lexiqaTooltipWarningPluginOptions} from './api/lexiqaTooltipwarnings' window.MC = {} @@ -66,3 +67,5 @@ window.OfflineUtils = OfflineUtils window.Shortcuts = Shortcuts window.SegmentFooterTabMatches = SegmentFooterTabMatches + +window.lexiqaTooltipWarningPluginOptions = lexiqaTooltipWarningPluginOptions diff --git a/public/js/cat_source/es6/components/segments/SegmentFooterTabMessages.js b/public/js/cat_source/es6/components/segments/SegmentFooterTabMessages.js index 59b2b96783..c6345d856c 100644 --- a/public/js/cat_source/es6/components/segments/SegmentFooterTabMessages.js +++ b/public/js/cat_source/es6/components/segments/SegmentFooterTabMessages.js @@ -10,6 +10,7 @@ class SegmentFooterTabMessages extends React.Component { } getNotes() { + console.log(this.props.segment.styleGuideMessages) let notesHtml = [] let self = this if (this.props.notes) { @@ -108,6 +109,19 @@ class SegmentFooterTabMessages extends React.Component { ) } + getStyleGuideMessages(messages) { + return ( +
+ Style guide: + +
+ ) + } + componentDidMount() {} componentWillUnmount() {} diff --git a/public/js/cat_source/es6/components/segments/SegmentsContainer.js b/public/js/cat_source/es6/components/segments/SegmentsContainer.js index 647118e1f6..3c88a3d2cb 100644 --- a/public/js/cat_source/es6/components/segments/SegmentsContainer.js +++ b/public/js/cat_source/es6/components/segments/SegmentsContainer.js @@ -89,7 +89,6 @@ class SegmentsContainer extends React.Component { renderSegments(segments) { // VirtualList.prototype.animateScroll = false; // Update previous last segment height inside segmentsHeightsMap - if (this.state.segments.size !== segments.size) { const oldLastSegment = this.getSegmentByIndex( this.state.segments.size - 1, @@ -243,7 +242,6 @@ class SegmentsContainer extends React.Component { getSegment(segment, segImmutable, currentFileId, collectionTypeSeparator) { let isReviewExtended = !!this.props.isReviewExtended - let item = ( { Object.keys(warnings[key].Categories).map((key2) => { @@ -1671,6 +1679,16 @@ AppDispatcher.register(function (action) { SegmentStore._segments, ) break + case SegmentConstants.ADD_LXQ_STYLE_GUIDE_MESSAGES: + SegmentStore.addLexiqaStyleGuideMessages( + action.sid, + action.styleGuideMessages, + ) + SegmentStore.emitChange( + SegmentConstants.RENDER_SEGMENTS, + SegmentStore._segments, + ) + break case SegmentConstants.ADD_SEARCH_RESULTS: SegmentStore.addSearchResult( action.occurrencesList, diff --git a/public/js/cat_source/es6/utils/lxq.main.js b/public/js/cat_source/es6/utils/lxq.main.js index 3523fa5ec7..14620192f7 100644 --- a/public/js/cat_source/es6/utils/lxq.main.js +++ b/public/js/cat_source/es6/utils/lxq.main.js @@ -8,6 +8,14 @@ import {lexiqaIgnoreError} from '../api/lexiqaIgnoreError' import SegmentStore from '../stores/SegmentStore' import {lexiqaTooltipwarnings} from '../api/lexiqaTooltipwarnings' +const styleGuideManager = (() => { + let map = {} + function getMessage(id) { + return this.map[id].msg ?? '' + } + return {map, getMessage} +})() + const LXQ = { enabled: function () { return !!config.lxq_enabled @@ -93,7 +101,6 @@ const LXQ = { function (err, result) { if (!err) { var noVisibleErrorsFound = false - if (result.hasOwnProperty('qaData') && result.qaData.length > 0) { //highlight the segments // source_val = $( ".source", segment ).html(); @@ -164,7 +171,13 @@ const LXQ = { LXQ.lxqRemoveSegmentFromWarningList(id_segment) } } //there was no error - else { + // style guides + if (result.styleGuideMessages) { + const messages = result.styleGuideMessages.map((style) => + styleGuideManager.getMessage(style), + ) + SegmentActions.addLexiqaStyleGuideMessages(id_segment, messages) + } else { if (callback != null) callback() } //error in doQA }, //end lexiqaAuthenticator callback @@ -784,6 +797,10 @@ LXQ.init = function () { modulesNoHighlight = Object.entries(data) .filter(([key]) => key[key.length - 1] === 'g') .map(([key]) => key) + + styleGuideManager.map = { + ...(data?.styleGuideMessages ?? {}), + } }) } // Interfaces