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

Fix tab editor settings #3692

Open
wants to merge 2 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
1 change: 0 additions & 1 deletion lib/Controller/newProjectController.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,6 @@ public function setTemplateVars() {

//Enable tag projection at instance level
$this->template->show_tag_projection = true;
$this->template->tag_projection_enabled = true;
$this->template->tag_projection_default = true;

$this->template->globalMessage = Utils::getGlobalMessage()[ 'messages' ];
Expand Down
2 changes: 0 additions & 2 deletions lib/Decorator/CatDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,6 @@ private function assignOptions() {

//show Tag Projection
$this->template->show_tag_projection = true;

$this->template->tag_projection_enabled = $chunk_options_model->isEnabled( 'tag_projection' );
$this->template->speech2text_enabled = $chunk_options_model->isEnabled( 'speech2text' );

LexiQADecorator::getInstance( $this->template )->checkJobHasLexiQAEnabled( $chunk_options_model )->decorateViewLexiQA();
Expand Down
1 change: 0 additions & 1 deletion lib/Model/LexiQA/LexiQADecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ public function decorateViewLexiQA() {
$this->template->lexiqa_languages = json_encode( ProjectOptionsSanitizer::$lexiQA_allowed_languages );
}

$this->template->lxq_enabled = $this->lexiqa_enabled;
$this->template->lexiqaServer = $this->lexiqa_server;

}
Expand Down
2 changes: 0 additions & 2 deletions lib/View/templates/_index.html
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,13 @@
*/
lxq_license: '${lxq_license | string:}',
lxq_partnerid: '${lxq_partnerid | string:}',
lxq_enabled: ${lxq_enabled},
lexiqa_languages: ${lexiqa_languages | string:[]},
lexiqaServer: '${lexiqaServer | string:}',

qa_check_glossary_enabled : ${qa_check_glossary_enabled | string:false },
qa_check_blacklist_enabled : ${qa_check_blacklist_enabled | string:false },
support_mail : '${support_mail}',
speech2text_enabled: ${speech2text_enabled | string:false},
tag_projection_enabled: ${tag_projection_enabled | string:false},
tag_projection_languages: ${tag_projection_languages},
segmentation_rule : '${segmentation_rule}',
segmentFilterEnabled: true,
Expand Down
1 change: 0 additions & 1 deletion public/js/cat_source/es6/actions/SegmentActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,6 @@ const SegmentActions = {
},
changeTagProjectionStatus: function (enabled) {
//TODO: transform paremeter to bool
config.tag_projection_enabled = enabled ? 1 : 0
toggleTagProjectionJob({enabled}).then(() => {
AppDispatcher.dispatch({
actionType: SegmentConstants.SET_GUESS_TAGS,
Expand Down
7 changes: 5 additions & 2 deletions public/js/cat_source/es6/components/header/cattol/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const Header = ({
openTmPanel,
jobMetadata,
}) => {
const {isUserLogged} = useContext(ApplicationWrapperContext)
const {isUserLogged, userInfo} = useContext(ApplicationWrapperContext)

useEffect(() => {
if (isUserLogged) {
Expand Down Expand Up @@ -136,7 +136,10 @@ export const Header = ({
<UserMenu />
</div>
<div id="header-bars-wrapper">
<SubHeaderContainer filtersEnabled={SegmentFilter.enabled()} />
<SubHeaderContainer
userInfo={userInfo}
filtersEnabled={SegmentFilter.enabled()}
/>
</div>
</header>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ class SubHeaderContainer extends React.Component {
active={this.state.search}
isReview={config.isReview}
searchable_statuses={config.searchable_statuses}
userInfo={this.props.userInfo}
/>
{this.props.filtersEnabled ? (
<SegmentsFilter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,17 @@ class Search extends React.Component {
if (this.state.funcFindButton) {
SearchUtils.execFind(this.state.search)
}

const {guess_tag: guessTag} = this.props.userInfo.metadata

this.setState({
funcFindButton: false,
...(config.tag_projection_enabled === 1 && {
...(guessTag === 1 && {
previousIsTagProjectionEnabled: true,
}),
})
// disable tag projection
if (config.tag_projection_enabled === 1) {
if (guessTag === 1) {
SegmentActions.changeTagProjectionStatus(false)
}
}
Expand Down
21 changes: 13 additions & 8 deletions public/js/cat_source/es6/components/segments/SegmentsContainer.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, {
createRef,
useCallback,
useContext,
useEffect,
useLayoutEffect,
useMemo,
Expand All @@ -25,6 +26,7 @@ import {isUndefined} from 'lodash'
import SegmentUtils from '../../utils/segmentUtils'
import CommentsStore from '../../stores/CommentsStore'
import DraftMatecatUtils from './utils/DraftMatecatUtils'
import {ApplicationWrapperContext} from '../common/ApplicationWrapper'

const ROW_HEIGHT = 90
const OVERSCAN = 5
Expand All @@ -37,14 +39,7 @@ const SEARCH_BAR_OPENED_PADDING_TOP = 80

const listRef = createRef()

function SegmentsContainer({
isReview,
startSegmentId,
firstJobSegment,
guessTagActive,
speechToTextActive,
multiMatchLangs,
}) {
function SegmentsContainer({isReview, startSegmentId, firstJobSegment}) {
useHotkeys(
Shortcuts.cattol.events.copySource.keystrokes[Shortcuts.shortCutsKeyType],
(e) => {
Expand Down Expand Up @@ -149,6 +144,8 @@ function SegmentsContainer({
{enableOnContentEditable: true, preventDefault: true},
)

const {userInfo} = useContext(ApplicationWrapperContext)

const [segments, setSegments] = useState(Immutable.fromJS([]))
const [rows, setRows] = useState([])
const [essentialRows, setEssentialRows] = useState([])
Expand Down Expand Up @@ -180,11 +177,19 @@ function SegmentsContainer({
const cachedRowsHeightMap = useRef(new Map())
const cachedSegmentsToJS = useRef(new Map())

const {guess_tags: guessTagActive, dictation: speechToTextActive} =
userInfo?.metadata ?? {}

const onChangeRowHeight = useCallback((id, newHeight) => {
rowsRenderedHeight.current.set(id, newHeight)
setOnUpdateRow(Symbol())
}, [])

const multiMatchLangs = useMemo(
() => userInfo?.metadata?.cross_language_matches ?? [],
[userInfo?.metadata],
)

const scrollToParams = useMemo(() => {
const position = scrollToSelected ? 'auto' : 'start'
const ROWS_LENGTH = rows.length
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ export const GuessTag = ({sourceLang, targetLangs}) => {
const onChange = (isActive) => {
setIsActive(isActive)

setUserMetadataKey(METADATA_KEY, isActive ? 1 : 0)

SegmentActions.changeTagProjectionStatus(isActive)
setUserMetadataKey(METADATA_KEY, isActive ? 1 : 0).then(() =>
SegmentActions.changeTagProjectionStatus(isActive),
)
}

useEffect(() => {
Expand Down
11 changes: 7 additions & 4 deletions public/js/cat_source/es6/hooks/useAuth.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import commonUtils from '../utils/commonUtils'
import {isEqual} from 'lodash'
import {logoutUser} from '../api/logoutUser'
import {updateUserMetadata} from '../api/updateUserMetadata'
import {flushSync} from 'react-dom'

const USER_INFO_SCHEMA = {
user: {
Expand Down Expand Up @@ -152,10 +153,12 @@ function useAuth() {
new Promise((resolve, reject) => {
updateUserMetadata(key, value)
.then((data) => {
setUserInfo((prevState) => ({
...prevState,
metadata: {...prevState.metadata, [key]: value},
}))
flushSync(() =>
setUserInfo((prevState) => ({
...prevState,
metadata: {...prevState.metadata, [key]: value},
})),
)

resolve(data)
})
Expand Down
13 changes: 1 addition & 12 deletions public/js/cat_source/es6/pages/CatTool.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import CatToolConstants from '../constants/CatToolConstants'
import OfflineUtils from '../utils/offlineUtils'
import SegmentActions from '../actions/SegmentActions'
import CatToolActions from '../actions/CatToolActions'
import SegmentFilter from '../components/header/cattol/segment_filter/segment_filter'
import SegmentStore from '../stores/SegmentStore'
import SegmentConstants from '../constants/SegmentConstants'
import useSegmentsLoader from '../hooks/useSegmentsLoader'
Expand All @@ -34,7 +33,6 @@ import CommonUtils from '../utils/commonUtils'
import {CattoolFooter} from '../components/footer/CattoolFooter'
import {mountPage} from './mountPage'
import {ApplicationWrapperContext} from '../components/common/ApplicationWrapper'
import NotificationBox from '../components/notificationsComponent/NotificationBox'
import SseListener from '../sse/SseListener'
import Speech2Text from '../utils/speech2text'
import {initTagSignature} from '../components/segments/utils/DraftMatecatUtils/tagModel'
Expand Down Expand Up @@ -274,7 +272,6 @@ function CatTool() {
)
CatToolActions.onRender()
$('html').trigger('start')
if (LXQ.enabled()) LXQ.initPopup()
UI.splittedTranslationPlaceholder = '##$_SPLIT$##'
}, [])

Expand Down Expand Up @@ -376,15 +373,10 @@ function CatTool() {
if (metadata) {
if (Speech2Text.enabled(metadata)) Speech2Text.init()
initTagSignature(metadata)
if (LXQ.enabled(metadata)) LXQ.init()
}
}, [userInfo?.metadata])

const {
guess_tags: guessTagActive,
dictation: speechToTextActive,
cross_language_matches: multiMatchLangs = [],
} = userInfo?.metadata ?? {}

const isFakeCurrentTemplateReady =
projectTemplates.length &&
typeof projectTemplates[1] !== 'undefined' &&
Expand Down Expand Up @@ -441,9 +433,6 @@ function CatTool() {
isReview={config.isReview}
startSegmentId={UI.startSegmentId?.toString()}
firstJobSegment={config.first_job_segment}
guessTagActive={guessTagActive}
speechToTextActive={speechToTextActive}
multiMatchLangs={multiMatchLangs}
languages={supportedLanguages}
/>
</div>
Expand Down
1 change: 0 additions & 1 deletion public/js/cat_source/es6/pages/SignIn.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, {useContext, useEffect} from 'react'
import {mountPage} from './mountPage'
import Header from '../components/header/Header'
import NotificationBox from '../components/notificationsComponent/NotificationBox'
import OnBoarding from '../components/onBoarding/OnBoarding'
import {ApplicationWrapperContext} from '../components/common/ApplicationWrapper'

Expand Down
62 changes: 23 additions & 39 deletions public/js/cat_source/es6/utils/lxq.main.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,28 @@ import {lexiqaIgnoreError} from '../api/lexiqaIgnoreError'
import SegmentStore from '../stores/SegmentStore'
import {lexiqaTooltipwarnings} from '../api/lexiqaTooltipwarnings'
import CatToolActions from '../actions/CatToolActions'
import CommonUtils from './commonUtils'
import UserStore from '../stores/UserStore'

const LXQ = {
enabled: function () {
return !!config.lxq_enabled
enabled: function ({lexiqa} = {}) {
return (lexiqa ? lexiqa : UserStore.getUserMetadata()?.lexiqa) === 1
},
enable: function () {
if (!config.lxq_enabled) {
config.lxq_enabled = 1
toggleTagLexica({enabled: true}).then(() => {
if (!LXQ.initialized) {
LXQ.init()
} else {
SegmentActions.qaComponentsetLxqIssues(LXQ.lexiqaData.segments)
}
CatToolActions.onRender()
SegmentActions.getSegmentsQa(SegmentStore.getCurrentSegment())
})
}
toggleTagLexica({enabled: true}).then(() => {
if (!LXQ.initialized) {
LXQ.init()
} else {
SegmentActions.qaComponentsetLxqIssues(LXQ.lexiqaData.segments)
}
CatToolActions.onRender()
SegmentActions.getSegmentsQa(SegmentStore.getCurrentSegment())
})
},
disable: function () {
if (config.lxq_enabled) {
config.lxq_enabled = 0
toggleTagLexica({enabled: false}).then(() => {
CatToolActions.onRender()
SegmentActions.qaComponentsetLxqIssues([])
})
}
toggleTagLexica({enabled: false}).then(() => {
CatToolActions.onRender()
SegmentActions.qaComponentsetLxqIssues([])
})
},
checkCanActivate: function () {
if (isUndefined(this.canActivate)) {
Expand Down Expand Up @@ -269,8 +263,6 @@ LXQ.init = function () {
lxqServer: config.lexiqaServer,
projectId: config.id_job + '-' + config.password,
})
} else {
config.lxq_enabled = false
}
/*
* Add lexiQA event handlers for warnings events
Expand Down Expand Up @@ -762,14 +754,13 @@ LXQ.init = function () {
}
}

var initPopup = function () {
lexiqaTooltipwarnings().then((data) => {
warningMessages = data
modulesNoHighlight = Object.entries(data)
.filter(([key]) => key[key.length - 1] === 'g')
.map(([key]) => key)
})
}
lexiqaTooltipwarnings().then((data) => {
warningMessages = data
modulesNoHighlight = Object.entries(data)
.filter(([key]) => key[key.length - 1] === 'g')
.map(([key]) => key)
})

// Interfaces
$.extend(LXQ, {
getRanges: getRanges,
Expand All @@ -779,17 +770,10 @@ LXQ.init = function () {
ignoreError: ignoreError,
redoHighlighting: redoHighlighting,
doQAallSegments: doQAallSegments,
initPopup: initPopup,
partnerid: partnerid,
projectid: config.id_job + '-' + config.password,
})
})(jQuery, config, window, LXQ)
}

document.addEventListener('DOMContentLoaded', () => {
if (LXQ.enabled()) {
LXQ.init()
}
})

export default LXQ
3 changes: 2 additions & 1 deletion public/js/cat_source/es6/utils/segmentUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import CommonUtils from './commonUtils'
import SegmentStore from '../stores/SegmentStore'
import DraftMatecatUtils from '../components/segments/utils/DraftMatecatUtils'
import {SEGMENTS_STATUS} from '../constants/Constants'
import UserStore from '../stores/UserStore'

const SegmentUtils = {
/**
Expand All @@ -16,7 +17,7 @@ const SegmentUtils = {
* Tag Projection: check if is enable the Tag Projection
*/
checkTPEnabled: function () {
return !!config.tag_projection_enabled && !!!config.isReview
return UserStore.getUserMetadata()?.guess_tags === 1 && !!!config.isReview
},
/**
* Check if the the Tag Projection in the current segment is enabled and still not tagged
Expand Down