Skip to content

Commit

Permalink
Added support for displaying and filtering by new MT statuses (#182)
Browse files Browse the repository at this point in the history
* Added support for displaying and filtering by new MT statuses

* Don't allow editing of MT statuses from UI
  • Loading branch information
maallen authored Nov 7, 2024
1 parent 191ffee commit fb93e93
Show file tree
Hide file tree
Showing 10 changed files with 109 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 12 additions & 0 deletions webapp/src/main/resources/properties/en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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...

Expand Down Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -29,6 +31,10 @@ class TextUnitsreviewModal extends React.Component {
};
}

isMTState = () => {
return this.state.currentReviewState === this.MACHINE_TRANSLATED || this.state.currentReviewState === this.MT_REVIEW;
}

/**
* Sets the state of the component to the button that was clicked upon.
* @param {string} reviewState
Expand Down Expand Up @@ -67,20 +73,50 @@ class TextUnitsreviewModal extends React.Component {
getRejectButton = () => {
return (
<Button active={this.state.currentReviewState === this.REJECT}
onClick={this.optionClicked.bind(this, this.REJECT)}>
onClick={this.optionClicked.bind(this, this.REJECT)}
disabled={this.isMTState()}>

<FormattedMessage id="textUnit.reviewModal.rejected"/>
</Button>
);
};

/**
* @returns {JSX} The JSX for the MT review button with class active set according to the current component state
*/
getMTReviewNeededButton = () => {
return (
<Button active={this.state.currentReviewState === this.MT_REVIEW}
onClick={this.optionClicked.bind(this, this.MT_REVIEW)}
disabled={true}>

<FormattedMessage id="textUnit.reviewModal.mtReview"/>
</Button>
);
};

/**
* @returns {JSX} The JSX for the Machine Translated button with class active set according to the current component state
*/
getMTButton = () => {
return (
<Button active={this.state.currentReviewState === this.MACHINE_TRANSLATED}
onClick={this.optionClicked.bind(this, this.MACHINE_TRANSLATED)}
disabled={true}>

<FormattedMessage id="textUnit.reviewModal.mt"/>
</Button>
);
};

/**
* @returns {JSX} The JSX for the review button with class active set according to the current component state
*/
getReviewButton = () => {
return (
<Button active={this.state.currentReviewState === this.REVIEW}
onClick={this.optionClicked.bind(this, this.REVIEW)}>
onClick={this.optionClicked.bind(this, this.REVIEW)}
disabled={this.isMTState()}>

<FormattedMessage id="textUnit.reviewModal.needsReview"/>
</Button>
Expand All @@ -93,7 +129,8 @@ class TextUnitsreviewModal extends React.Component {
getAcceptButton = () => {
return (
<Button active={this.state.currentReviewState === this.ACCEPT}
onClick={this.optionClicked.bind(this, this.ACCEPT)}>
onClick={this.optionClicked.bind(this, this.ACCEPT)}
disabled={this.isMTState()}>

<FormattedMessage id="textUnit.reviewModal.accepted"/>
</Button>
Expand All @@ -103,7 +140,8 @@ class TextUnitsreviewModal extends React.Component {
getOverriddenButton = () => {
return (
<Button active={this.state.currentReviewState === this.OVERRIDDEN}
onClick={this.optionClicked.bind(this, this.OVERRIDDEN)}>
onClick={this.optionClicked.bind(this, this.OVERRIDDEN)}
disabled={this.isMTState()}>
<FormattedMessage id="textUnit.reviewModal.overridden"/>
</Button>
);
Expand All @@ -115,7 +153,8 @@ class TextUnitsreviewModal extends React.Component {
getTranslateButton = () => {
return (
<Button active={this.state.currentReviewState === this.TRANSLATE}
onClick={this.optionClicked.bind(this, this.TRANSLATE)}>
onClick={this.optionClicked.bind(this, this.TRANSLATE)}
disabled={this.isMTState()}>

<FormattedMessage id="textUnit.reviewModal.translationNeeded"/>
</Button>
Expand Down Expand Up @@ -170,7 +209,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;
Expand Down Expand Up @@ -226,6 +271,8 @@ class TextUnitsreviewModal extends React.Component {
<ButtonGroup ref="optionsGroup">
{this.getRejectButton()}
{this.getTranslateButton()}
{this.getMTButton()}
{this.getMTReviewNeededButton()}
{this.getReviewButton()}
{this.getAcceptButton()}
{this.getOverriddenButton()}
Expand All @@ -234,7 +281,7 @@ class TextUnitsreviewModal extends React.Component {
</Modal.Body>
<Modal.Footer>
<Button bsStyle="primary" onClick={this.onReviewModalSaveClicked}
disabled={this.state.currentReviewState === ""}>
disabled={this.state.currentReviewState === "" || this.isMTState()} >
<FormattedMessage id="label.save"/>
</Button>
<Button onClick={this.closeModal}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 ? (
Expand Down
2 changes: 2 additions & 0 deletions webapp/src/main/resources/public/js/sdk/TextUnit.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,4 +310,6 @@ TextUnit.STATUS = {
"APPROVED": "APPROVED",
"REJECTED": "REJECTED",
"OVERRIDDEN": "OVERRIDDEN",
"MACHINE_TRANSLATED": "MT_TRANSLATED",
"MT_REVIEW_NEEDED": "MT_REVIEW_NEEDED",
};
Original file line number Diff line number Diff line change
Expand Up @@ -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');

0 comments on commit fb93e93

Please sign in to comment.