From faf0a23a3aedcfc10d051fab2c0f697fa466b26a Mon Sep 17 00:00:00 2001
From: Mark Allen <3417310+maallen@users.noreply.github.com>
Date: Tue, 5 Nov 2024 15:37:02 +0000
Subject: [PATCH] Added support for displaying and filtering by new MT statuses
---
.../service/tm/search/StatusFilter.java | 4 +-
.../service/tm/search/TextUnitSearcher.java | 5 +++
.../main/resources/properties/en.properties | 12 ++++++
.../js/components/widgets/StatusGlyph.js | 8 ++++
.../js/components/workbench/StatusDropdown.js | 6 +++
.../js/components/workbench/TextUnit.js | 10 ++++-
.../workbench/TextUnitsReviewModal.js | 38 ++++++++++++++++++-
.../workbench/TranslationHistoryModal.js | 3 +-
.../main/resources/public/js/sdk/TextUnit.js | 2 +
.../js/stores/workbench/SearchParamsStore.js | 8 ++++
10 files changed, 92 insertions(+), 4 deletions(-)
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 c0d8baa316..5b86390163 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
@@ -55,5 +55,7 @@ public enum StatusFilter {
/** TextUnits with status ({@link TMTextUnitVariant.Status#OVERRIDDEN}). */
OVERRIDDEN,
/** TextUnits with status (@link TMTextUnitVariant.Status#MT_TRANSLATED}). */
- MT_TRANSLATED
+ MT_TRANSLATED,
+ /** TextUnits with status (@link TMTextUnitVariant.Status#MT_REVIEW_NEEDED}). */
+ MT_REVIEW_NEEDED,
}
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 18882d854e..85999c4dff 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
@@ -420,6 +420,11 @@ NativeCriteria getCriteriaForSearch(TextUnitSearcherParameters searchParameters)
conjunction.add(
new NativeEqExpFix("tuv.status", TMTextUnitVariant.Status.MT_TRANSLATED.toString()));
break;
+ case MT_REVIEW_NEEDED:
+ conjunction.add(
+ new NativeEqExpFix(
+ "tuv.status", TMTextUnitVariant.Status.MT_REVIEW_NEEDED.toString()));
+ break;
case TRANSLATED:
conjunction.add(NativeExps.isNotNull("tuv.id"));
break;
diff --git a/webapp/src/main/resources/properties/en.properties b/webapp/src/main/resources/properties/en.properties
index 224a9c8796..e809162bb8 100644
--- a/webapp/src/main/resources/properties/en.properties
+++ b/webapp/src/main/resources/properties/en.properties
@@ -225,6 +225,12 @@ search.statusDropdown.yes=Yes
# Search filter option label to indicate that the filter is inactive
search.statusDropdown.no=No
+# Search filter option label to search for text units that are machine translated
+search.statusDropdown.machineTranslated=Machine Translated
+
+# Search filter option label to search for text units that are machine translated and sent for review
+search.statusDropdown.mtReviewNeeded=MT Review Needed
+
# label displayed alternately if the "loading" image used during pagination is not available
search.pagination.isLoading=Loading...
@@ -325,6 +331,12 @@ workbench.shareSearchParamsModal.errors.copyToClipboard=Can't copy the URL to th
# Label for the Review button on the modal in the workbench
textUnit.reviewModal.rejected=Rejected
+# Label for the MT review button on the modal in the workbench
+textUnit.reviewModal.mtReview=MT Review Needed
+
+# Label for the Machine Translated button on the modal in the workbench
+textUnit.reviewModal.mt=Machine Translated
+
# Button label used for primary action "removeReview" on modal dialog
textUnit.reviewModal.accepted=Accepted
diff --git a/webapp/src/main/resources/public/js/components/widgets/StatusGlyph.js b/webapp/src/main/resources/public/js/components/widgets/StatusGlyph.js
index 8c129f4e40..6ae02f14d6 100644
--- a/webapp/src/main/resources/public/js/components/widgets/StatusGlyph.js
+++ b/webapp/src/main/resources/public/js/components/widgets/StatusGlyph.js
@@ -14,6 +14,8 @@ class StatusGlyph extends React.Component {
TextUnitSDK.STATUS.APPROVED,
TextUnitSDK.STATUS.REVIEW_NEEDED,
TextUnitSDK.STATUS.TRANSLATION_NEEDED,
+ TextUnitSDK.STATUS.MACHINE_TRANSLATED,
+ TextUnitSDK.STATUS.MT_REVIEW_NEEDED,
TextUnitSDK.STATUS.REJECTED]).isRequired,
"onClick": PropTypes.func.isRequired,
"noButton" : PropTypes.bool,
@@ -33,6 +35,12 @@ class StatusGlyph extends React.Component {
case TextUnitSDK.STATUS.TRANSLATION_NEEDED:
glyph = {type: 'edit', title: this.props.intl.formatMessage({id: "textUnit.reviewModal.translationNeeded"})};
break;
+ case TextUnitSDK.STATUS.MACHINE_TRANSLATED:
+ glyph = {type: 'asterisk', title: this.props.intl.formatMessage({id: "textUnit.reviewModal.mt"})};
+ break;
+ case TextUnitSDK.STATUS.MT_REVIEW_NEEDED:
+ glyph = {type: 'hourglass', title: this.props.intl.formatMessage({id: "textUnit.reviewModal.mtReview"})};
+ break;
case TextUnitSDK.STATUS.REJECTED:
glyph = {type: 'alert', title: this.props.intl.formatMessage({id: "textUnit.reviewModal.rejected"})};
break;
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 5481e3085a..023c5f6364 100644
--- a/webapp/src/main/resources/public/js/components/workbench/StatusDropdown.js
+++ b/webapp/src/main/resources/public/js/components/workbench/StatusDropdown.js
@@ -166,6 +166,10 @@ let StatusDropdown = createReactClass({
return this.props.intl.formatMessage({ id: "search.statusDropdown.untranslated" });
case SearchParamsStore.STATUS.FOR_TRANSLATION:
return this.props.intl.formatMessage({ id: "search.statusDropdown.forTranslation" });
+ case SearchParamsStore.STATUS.MACHINE_TRANSLATED:
+ return this.props.intl.formatMessage({ id: "search.statusDropdown.machineTranslated" });
+ case SearchParamsStore.STATUS.MT_REVIEW_NEEDED:
+ return this.props.intl.formatMessage({ id: "search.statusDropdown.mtReviewNeeded" });
case SearchParamsStore.STATUS.REVIEW_NEEDED:
return this.props.intl.formatMessage({ id: "search.statusDropdown.needsReview" });
case SearchParamsStore.STATUS.REJECTED:
@@ -263,6 +267,8 @@ let StatusDropdown = createReactClass({
{this.renderStatusMenuItem(SearchParamsStore.STATUS.TRANSLATED)}
{this.renderStatusMenuItem(SearchParamsStore.STATUS.UNTRANSLATED)}
{this.renderStatusMenuItem(SearchParamsStore.STATUS.FOR_TRANSLATION)}
+ {this.renderStatusMenuItem(SearchParamsStore.STATUS.MACHINE_TRANSLATED)}
+ {this.renderStatusMenuItem(SearchParamsStore.STATUS.MT_REVIEW_NEEDED)}
{this.renderStatusMenuItem(SearchParamsStore.STATUS.REVIEW_NEEDED)}
{this.renderStatusMenuItem(SearchParamsStore.STATUS.REJECTED)}
{this.renderStatusMenuItem(SearchParamsStore.STATUS.OVERRIDDEN)}
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 228dd4bd25..faf4e85df3 100644
--- a/webapp/src/main/resources/public/js/components/workbench/TextUnit.js
+++ b/webapp/src/main/resources/public/js/components/workbench/TextUnit.js
@@ -438,7 +438,15 @@ let TextUnit = createReactClass({
let glyphType = "ok";
let glyphTitle = this.props.intl.formatMessage({id: "textUnit.reviewModal.accepted"});
- if (!this.props.textUnit.isIncludedInLocalizedFile()) {
+ if (this.props.textUnit.getStatus() === TextUnitSDK.STATUS.MACHINE_TRANSLATED) {
+ glyphType = "asterisk";
+ glyphTitle = this.props.intl.formatMessage({id: "textUnit.reviewModal.mt"});
+ }
+ else if (this.props.textUnit.getStatus() === TextUnitSDK.STATUS.MT_REVIEW_NEEDED) {
+ glyphType = "hourglass";
+ glyphTitle = this.props.intl.formatMessage({id: "textUnit.reviewModal.mtReview"});
+ }
+ else if (!this.props.textUnit.isIncludedInLocalizedFile()) {
glyphType = "alert";
glyphTitle = this.props.intl.formatMessage({id: "textUnit.reviewModal.rejected"});
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 a83fd067ed..dee06a1420 100644
--- a/webapp/src/main/resources/public/js/components/workbench/TextUnitsReviewModal.js
+++ b/webapp/src/main/resources/public/js/components/workbench/TextUnitsReviewModal.js
@@ -19,6 +19,8 @@ class TextUnitsreviewModal extends React.Component {
super(props, context);
this.REVIEW = "review";
this.REJECT = "reject";
+ this.MACHINE_TRANSLATED = "machine translated";
+ this.MT_REVIEW = "mt review needed";
this.ACCEPT = "accept";
this.TRANSLATE = "translate"
this.OVERRIDDEN = "overridden";
@@ -74,6 +76,32 @@ class TextUnitsreviewModal extends React.Component {
);
};
+ /**
+ * @returns {JSX} The JSX for the MT review button with class active set according to the current component state
+ */
+ getMTReviewNeededButton = () => {
+ return (
+
+ );
+ };
+
+ /**
+ * @returns {JSX} The JSX for the Machine Translated button with class active set according to the current component state
+ */
+ getMTButton = () => {
+ return (
+
+ );
+ };
+
/**
* @returns {JSX} The JSX for the review button with class active set according to the current component state
*/
@@ -170,7 +198,13 @@ class TextUnitsreviewModal extends React.Component {
let currentReviewState = "";
if (typeof textUnit !== "undefined") {
currentReviewState = this.ACCEPT;
- if (!textUnit.isIncludedInLocalizedFile()) {
+ if (textUnit.getStatus() === TextUnit.STATUS.MACHINE_TRANSLATED) {
+ currentReviewState = this.MACHINE_TRANSLATED;
+ }
+ else if (textUnit.getStatus() === TextUnit.STATUS.MT_REVIEW_NEEDED) {
+ currentReviewState = this.MT_REVIEW;
+ }
+ else if (!textUnit.isIncludedInLocalizedFile()) {
currentReviewState = this.REJECT;
} else if (textUnit.getStatus() === TextUnit.STATUS.REVIEW_NEEDED) {
currentReviewState = this.REVIEW;
@@ -226,6 +260,8 @@ class TextUnitsreviewModal extends React.Component {
{this.getRejectButton()}
{this.getTranslateButton()}
+ {this.getMTButton()}
+ {this.getMTReviewNeededButton()}
{this.getReviewButton()}
{this.getAcceptButton()}
{this.getOverriddenButton()}
diff --git a/webapp/src/main/resources/public/js/components/workbench/TranslationHistoryModal.js b/webapp/src/main/resources/public/js/components/workbench/TranslationHistoryModal.js
index 425e664620..793109832a 100644
--- a/webapp/src/main/resources/public/js/components/workbench/TranslationHistoryModal.js
+++ b/webapp/src/main/resources/public/js/components/workbench/TranslationHistoryModal.js
@@ -19,7 +19,8 @@ class translationHistoryModal extends React.Component {
renderHistoryItem = (item) => {
const { textUnit, openTmTextUnitVariantId } = this.props;
const rowClass = textUnit.getTmTextUnitVariantId() === item.id ? "history-current-variant" : "";
- const status = item.id && !item.includedInLocalizedFile ? TextUnitSDK.STATUS.REJECTED : item.status;
+ const mtStatus = item.status === TextUnitSDK.STATUS.MACHINE_TRANSLATED || item.status === TextUnitSDK.STATUS.MT_REVIEW_NEEDED;
+ const status = item.id && !item.includedInLocalizedFile && !mtStatus ? TextUnitSDK.STATUS.REJECTED : item.status;
const isOpenTmTextUnitVariant = openTmTextUnitVariantId === item.id;
return item ? (
diff --git a/webapp/src/main/resources/public/js/sdk/TextUnit.js b/webapp/src/main/resources/public/js/sdk/TextUnit.js
index 762a3843f7..675b7a7b6a 100644
--- a/webapp/src/main/resources/public/js/sdk/TextUnit.js
+++ b/webapp/src/main/resources/public/js/sdk/TextUnit.js
@@ -310,4 +310,6 @@ TextUnit.STATUS = {
"APPROVED": "APPROVED",
"REJECTED": "REJECTED",
"OVERRIDDEN": "OVERRIDDEN",
+ "MACHINE_TRANSLATED": "MT_TRANSLATED",
+ "MT_REVIEW_NEEDED": "MT_REVIEW_NEEDED",
};
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 34aafe7532..a7172a912e 100644
--- a/webapp/src/main/resources/public/js/stores/workbench/SearchParamsStore.js
+++ b/webapp/src/main/resources/public/js/stores/workbench/SearchParamsStore.js
@@ -450,6 +450,14 @@ SearchParamsStore.STATUS = {
* TextUnits with status OVERRIDDEN.
*/
"OVERRIDDEN": "OVERRIDDEN",
+ /**
+ * TextUnits with status MACHINE_TRANSLATED.
+ */
+ "MACHINE_TRANSLATED": "MT_TRANSLATED",
+ /**
+ * TextUnits with status MT_REVIEW_NEEDED.
+ */
+ "MT_REVIEW_NEEDED": "MT_REVIEW_NEEDED",
};
export default alt.createStore(SearchParamsStore, 'SearchParamsStore');