diff --git a/webapp/src/main/java/com/box/l10n/mojito/entity/TMTextUnitVariant.java b/webapp/src/main/java/com/box/l10n/mojito/entity/TMTextUnitVariant.java index 20ebb9440..1ef4414fb 100644 --- a/webapp/src/main/java/com/box/l10n/mojito/entity/TMTextUnitVariant.java +++ b/webapp/src/main/java/com/box/l10n/mojito/entity/TMTextUnitVariant.java @@ -73,7 +73,10 @@ public enum Status { MT_REVIEW, /** A string that doesn't need any work to be performed on it. */ - APPROVED; + APPROVED, + + /** It was translated in Mojito, so it won't be updated during third-party sync */ + TRANSLATED_IN_MOJITO; }; @Column(name = "content", length = Integer.MAX_VALUE) diff --git a/webapp/src/main/java/com/box/l10n/mojito/service/tm/importer/TextUnitBatchImporterService.java b/webapp/src/main/java/com/box/l10n/mojito/service/tm/importer/TextUnitBatchImporterService.java index a54cb4caf..e4a0f77e1 100644 --- a/webapp/src/main/java/com/box/l10n/mojito/service/tm/importer/TextUnitBatchImporterService.java +++ b/webapp/src/main/java/com/box/l10n/mojito/service/tm/importer/TextUnitBatchImporterService.java @@ -250,36 +250,41 @@ void importTextUnitsOfLocaleAndAsset( currentTextUnit.getLocaleId(), currentTextUnit.getTmTextUnitId()); } - User importedBy = auditorAwareImpl.getCurrentAuditor().orElse(null); - AddTMTextUnitCurrentVariantResult addTMTextUnitCurrentVariantResult = - tmService.addTMTextUnitCurrentVariantWithResult( - tmTextUnitCurrentVariant, - asset.getRepository().getTm().getId(), - asset.getId(), - currentTextUnit.getTmTextUnitId(), - locale.getId(), - textUnitForBatchImport.getContent(), - textUnitForBatchImport.getComment(), - textUnitForBatchImport.getStatus(), - textUnitForBatchImport.isIncludedInLocalizedFile(), - importTime, - importedBy); - - if (addTMTextUnitCurrentVariantResult.isTmTextUnitCurrentVariantUpdated()) { - - Long tmTextUnitVariantId = - addTMTextUnitCurrentVariantResult - .getTmTextUnitCurrentVariant() - .getTmTextUnitVariant() - .getId(); - - for (TMTextUnitVariantComment tmTextUnitVariantComment : - textUnitForBatchImport.getTmTextUnitVariantComments()) { - tmMTextUnitVariantCommentService.addComment( - tmTextUnitVariantId, - tmTextUnitVariantComment.getType(), - tmTextUnitVariantComment.getSeverity(), - tmTextUnitVariantComment.getContent()); + if (tmTextUnitCurrentVariant != null + && tmTextUnitCurrentVariant.getTmTextUnitVariant() != null + && tmTextUnitCurrentVariant.getTmTextUnitVariant().getStatus() + != Status.MANUALLY_TRANSLATED) { + User importedBy = auditorAwareImpl.getCurrentAuditor().orElse(null); + AddTMTextUnitCurrentVariantResult addTMTextUnitCurrentVariantResult = + tmService.addTMTextUnitCurrentVariantWithResult( + tmTextUnitCurrentVariant, + asset.getRepository().getTm().getId(), + asset.getId(), + currentTextUnit.getTmTextUnitId(), + locale.getId(), + textUnitForBatchImport.getContent(), + textUnitForBatchImport.getComment(), + textUnitForBatchImport.getStatus(), + textUnitForBatchImport.isIncludedInLocalizedFile(), + importTime, + importedBy); + + if (addTMTextUnitCurrentVariantResult.isTmTextUnitCurrentVariantUpdated()) { + + Long tmTextUnitVariantId = + addTMTextUnitCurrentVariantResult + .getTmTextUnitCurrentVariant() + .getTmTextUnitVariant() + .getId(); + + for (TMTextUnitVariantComment tmTextUnitVariantComment : + textUnitForBatchImport.getTmTextUnitVariantComments()) { + tmMTextUnitVariantCommentService.addComment( + tmTextUnitVariantId, + tmTextUnitVariantComment.getType(), + tmTextUnitVariantComment.getSeverity(), + tmTextUnitVariantComment.getContent()); + } } } }); diff --git a/webapp/src/main/java/com/box/l10n/mojito/service/tm/search/StatusFilter.java b/webapp/src/main/java/com/box/l10n/mojito/service/tm/search/StatusFilter.java index 35065c5b8..82827fb6c 100644 --- a/webapp/src/main/java/com/box/l10n/mojito/service/tm/search/StatusFilter.java +++ b/webapp/src/main/java/com/box/l10n/mojito/service/tm/search/StatusFilter.java @@ -52,4 +52,6 @@ public enum StatusFilter { * TextUnits that are not rejected, ie {@link TMTextUnitVariant#includedInLocalizedFile} is true. */ NOT_REJECTED, + /** TextUnits with status ({@link TMTextUnitVariant.Status#TRANSLATED_IN_MOJITO}). */ + TRANSLATED_IN_MOJITO, } diff --git a/webapp/src/main/java/com/box/l10n/mojito/service/tm/search/TextUnitSearcher.java b/webapp/src/main/java/com/box/l10n/mojito/service/tm/search/TextUnitSearcher.java index 846fbd2e4..07a28c1b6 100644 --- a/webapp/src/main/java/com/box/l10n/mojito/service/tm/search/TextUnitSearcher.java +++ b/webapp/src/main/java/com/box/l10n/mojito/service/tm/search/TextUnitSearcher.java @@ -436,6 +436,11 @@ NativeCriteria getCriteriaForSearch(TextUnitSearcherParameters searchParameters) "tuv.status", TMTextUnitVariant.Status.TRANSLATION_NEEDED.toString()), new NativeEqExpFix("tuv.included_in_localized_file", Boolean.FALSE)))); break; + case TRANSLATED_IN_MOJITO: + conjunction.add( + new NativeEqExpFix( + "tuv.status", TMTextUnitVariant.Status.TRANSLATED_IN_MOJITO.toString())); + break; default: throw new RuntimeException("Filter type not implemented"); } diff --git a/webapp/src/main/resources/properties/en.properties b/webapp/src/main/resources/properties/en.properties index c267fe188..88ba572c9 100644 --- a/webapp/src/main/resources/properties/en.properties +++ b/webapp/src/main/resources/properties/en.properties @@ -213,6 +213,9 @@ search.statusDropdown.needsReview=Needs Review # Status filter option to search for text units that need to be translated search.statusDropdown.forTranslation=Needs Translation +# Status filter option to search for text units that are translated in Mojito +search.statusDropdown.translatedInMojito=Translated in Mojito + # Status filter option to search for text units that are rejected (won't be added in localized file) search.statusDropdown.rejected=Rejected @@ -325,6 +328,9 @@ textUnit.reviewModal.rejected=Rejected # Button label used for primary action "removeReview" on modal dialog textUnit.reviewModal.accepted=Accepted +# Label for Translated in Mojito button on modal dialog +textUnit.reviewModal.translatedInMojito=Translated in Mojito + # Button label used for the Needs Review button on the textunit review modal textUnit.reviewModal.needsReview=Needs Review diff --git a/webapp/src/main/resources/public/js/components/workbench/StatusDropdown.js b/webapp/src/main/resources/public/js/components/workbench/StatusDropdown.js index a33f732eb..faa4d1a0d 100644 --- a/webapp/src/main/resources/public/js/components/workbench/StatusDropdown.js +++ b/webapp/src/main/resources/public/js/components/workbench/StatusDropdown.js @@ -103,8 +103,8 @@ let StatusDropdown = createReactClass({ }, setStateAndCallSearchParamChanged(searchFilterParam, searchFilterParamValue) { - let state = {}; + state[searchFilterParam] = searchFilterParamValue; this.setState(state, function () { @@ -170,6 +170,8 @@ let StatusDropdown = createReactClass({ return this.props.intl.formatMessage({ id: "search.statusDropdown.needsReview" }); case SearchParamsStore.STATUS.REJECTED: return this.props.intl.formatMessage({ id: "search.statusDropdown.rejected" }); + case SearchParamsStore.STATUS.TRANSLATED_IN_MOJITO: + return this.props.intl.formatMessage({ id: "search.statusDropdown.translatedInMojito" }); } }, @@ -263,6 +265,7 @@ let StatusDropdown = createReactClass({ {this.renderStatusMenuItem(SearchParamsStore.STATUS.FOR_TRANSLATION)} {this.renderStatusMenuItem(SearchParamsStore.STATUS.REVIEW_NEEDED)} {this.renderStatusMenuItem(SearchParamsStore.STATUS.REJECTED)} + {this.renderStatusMenuItem(SearchParamsStore.STATUS.TRANSLATED_IN_MOJITO)} diff --git a/webapp/src/main/resources/public/js/components/workbench/TextUnit.js b/webapp/src/main/resources/public/js/components/workbench/TextUnit.js index 58057b16b..00f3654b5 100644 --- a/webapp/src/main/resources/public/js/components/workbench/TextUnit.js +++ b/webapp/src/main/resources/public/js/components/workbench/TextUnit.js @@ -363,6 +363,10 @@ let TextUnit = createReactClass({ textUnit.setIncludedInLocalizedFile(true); textUnit.setStatus(TextUnitSDK.STATUS.TRANSLATION_NEEDED); break; + case "translated_in_mojito": + textUnit.setIncludedInLocalizedFile(true); + textUnit.setStatus(TextUnitSDK.STATUS.TRANSLATED_IN_MOJITO); + break; } WorkbenchActions.saveTextUnit(textUnit); diff --git a/webapp/src/main/resources/public/js/components/workbench/TextUnitsReviewModal.js b/webapp/src/main/resources/public/js/components/workbench/TextUnitsReviewModal.js index 750134eb4..04a0a510f 100644 --- a/webapp/src/main/resources/public/js/components/workbench/TextUnitsReviewModal.js +++ b/webapp/src/main/resources/public/js/components/workbench/TextUnitsReviewModal.js @@ -20,7 +20,8 @@ class TextUnitsreviewModal extends React.Component { this.REVIEW = "review"; this.REJECT = "reject"; this.ACCEPT = "accept"; - this.TRANSLATE = "translate"; + this.TRANSLATE = "translate" + this.TRANSLATED_IN_MOJITO = "translated_in_mojito"; this.state = { "currentReviewState": this.getInitialReviewStateOfTextUnits(), @@ -99,6 +100,15 @@ class TextUnitsreviewModal extends React.Component { ); }; + getManuallyTranslatedButton = () => { + return ( + + ); + }; + /** * @returns {JSX} The JSX for the translate button with class active set according to the current component state */ @@ -166,6 +176,8 @@ class TextUnitsreviewModal extends React.Component { currentReviewState = this.REVIEW; } else if (textUnit.getStatus() === TextUnit.STATUS.TRANSLATION_NEEDED) { currentReviewState = this.TRANSLATE; + } else if (textUnit.getStatus() === TextUnit.STATUS.TRANSLATED_IN_MOJITO) { + currentReviewState = this.TRANSLATED_IN_MOJITO; } } @@ -195,7 +207,7 @@ class TextUnitsreviewModal extends React.Component { return ( { e.stopPropagation() - }}> + }} bsSize="large"> @@ -216,6 +228,7 @@ class TextUnitsreviewModal extends React.Component { {this.getTranslateButton()} {this.getReviewButton()} {this.getAcceptButton()} + {this.getManuallyTranslatedButton()} diff --git a/webapp/src/main/resources/public/js/sdk/TextUnit.js b/webapp/src/main/resources/public/js/sdk/TextUnit.js index 8a6172b3a..fa01acd04 100644 --- a/webapp/src/main/resources/public/js/sdk/TextUnit.js +++ b/webapp/src/main/resources/public/js/sdk/TextUnit.js @@ -308,5 +308,6 @@ TextUnit.STATUS = { "TRANSLATION_NEEDED": "TRANSLATION_NEEDED", "REVIEW_NEEDED": "REVIEW_NEEDED", "APPROVED": "APPROVED", - "REJECTED": "REJECTED" + "REJECTED": "REJECTED", + "TRANSLATED_IN_MOJITO": "TRANSLATED_IN_MOJITO", }; diff --git a/webapp/src/main/resources/public/js/stores/workbench/SearchParamsStore.js b/webapp/src/main/resources/public/js/stores/workbench/SearchParamsStore.js index 812d0af9b..cd39c097b 100644 --- a/webapp/src/main/resources/public/js/stores/workbench/SearchParamsStore.js +++ b/webapp/src/main/resources/public/js/stores/workbench/SearchParamsStore.js @@ -446,7 +446,10 @@ SearchParamsStore.STATUS = { * TextUnits that are not rejected, ie includedInLocalizedFile is true. */ "NOT_REJECTED": "NOT_REJECTED", - + /** + * TextUnits with status MANUALLY_TRANSLATED. + */ + "MANUALLY_TRANSLATED": "MANUALLY_TRANSLATED", }; export default alt.createStore(SearchParamsStore, 'SearchParamsStore');