Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show lexiQA styleguide list #2228

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion lib/Utils/MultiCurlHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand Down Expand Up @@ -428,4 +437,4 @@ protected function _callbackExecute( $record, Callable $function = null ){
return $record;
}

}
}
6 changes: 6 additions & 0 deletions public/css/sass/segment-notes.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 7 additions & 0 deletions public/js/cat_source/es6/actions/SegmentActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
3 changes: 3 additions & 0 deletions public/js/cat_source/es6/components.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}

Expand Down Expand Up @@ -66,3 +67,5 @@ window.OfflineUtils = OfflineUtils
window.Shortcuts = Shortcuts

window.SegmentFooterTabMatches = SegmentFooterTabMatches

window.lexiqaTooltipWarningPluginOptions = lexiqaTooltipWarningPluginOptions
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class SegmentFooterTabMessages extends React.Component {
}

getNotes() {
console.log(this.props.segment.styleGuideMessages)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Se non serve possiamo rimuovere il console.log.

let notesHtml = []
let self = this
if (this.props.notes) {
Expand Down Expand Up @@ -108,6 +109,19 @@ class SegmentFooterTabMessages extends React.Component {
)
}

getStyleGuideMessages(messages) {
return (
<div className="note note-style-guide" key="style-guide">
<span className="note-label">Style guide: </span>
<ul>
{messages.map((style, index) => (
<li key={index}>{style}</li>
))}
</ul>
</div>
)
}

componentDidMount() {}

componentWillUnmount() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -243,7 +242,6 @@ class SegmentsContainer extends React.Component {

getSegment(segment, segImmutable, currentFileId, collectionTypeSeparator) {
let isReviewExtended = !!this.props.isReviewExtended

let item = (
<Segment
key={segment.sid}
Expand Down
1 change: 1 addition & 0 deletions public/js/cat_source/es6/constants/SegmentConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ module.exports = keyMirror({
SET_QA_CHECK_MATCHES: null,
SET_QA_BLACKLIST_MATCHES: null,
ADD_LXQ_HIGHLIGHT: null,
ADD_LXQ_STYLE_GUIDE_MESSAGES: null,
ADD_SEARCH_RESULTS: null,
REMOVE_SEARCH_RESULTS: null,
ADD_CURRENT_SEARCH: null,
Expand Down
18 changes: 18 additions & 0 deletions public/js/cat_source/es6/stores/SegmentStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -772,6 +772,14 @@ const SegmentStore = assign({}, EventEmitter.prototype, {
)
}
},
addLexiqaStyleGuideMessages(sid, styleGuideMessages) {
const index = this.getSegmentIndex(sid)
if (index === -1) return
this._segments = this._segments.setIn(
[index, 'styleGuideMessages'],
styleGuideMessages,
)
},
updateGlobalWarnings: function (warnings) {
Object.keys(warnings).map((key) => {
Object.keys(warnings[key].Categories).map((key2) => {
Expand Down Expand Up @@ -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,
Expand Down
21 changes: 19 additions & 2 deletions public/js/cat_source/es6/utils/lxq.main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down