Skip to content

Commit

Permalink
Merge branch 'master' of github.com:zanata/zanata-platform into eflod…
Browse files Browse the repository at this point in the history
…en/activity-panel-backend/ZNTA-2297
  • Loading branch information
efloden committed Feb 22, 2018
2 parents 82ececd + e38d758 commit 7a81307
Show file tree
Hide file tree
Showing 21 changed files with 171 additions and 137 deletions.
Expand Up @@ -35,17 +35,17 @@ public class TransReviewCriteria implements IsSerializable, Serializable {
private Long id;
private IssuePriority priority;
private String description;
private boolean editable;
private boolean commentRequired;

public TransReviewCriteria() {
}

public TransReviewCriteria(Long id, IssuePriority priority, String description,
boolean editable) {
boolean commentRequired) {
this.id = id;
this.priority = priority;
this.description = description;
this.editable = editable;
this.commentRequired = commentRequired;
}


Expand All @@ -57,8 +57,8 @@ public String getDescription() {
return description;
}

public boolean isEditable() {
return editable;
public boolean isCommentRequired() {
return commentRequired;
}

public Long getId() {
Expand Down
Expand Up @@ -80,7 +80,7 @@ protected ReviewService(ReviewCriteriaDAO reviewCriteriaDAO, UriInfo uriInfo, Ur

public static TransReviewCriteria fromModel(ReviewCriteria criteria) {
return new TransReviewCriteria(criteria.getId(), criteria.getPriority(),
criteria.getDescription(), criteria.isEditable());
criteria.getDescription(), criteria.isCommentRequired());
}

@POST
Expand All @@ -94,7 +94,7 @@ public Response addCriteria(TransReviewCriteria criteria) {
}
ReviewCriteria reviewCriteria =
new ReviewCriteria(criteria.getPriority(),
criteria.isEditable(), criteria.getDescription());
criteria.isCommentRequired(), criteria.getDescription());
reviewCriteriaDAO.makePersistent(reviewCriteria);
return Response.created(UriBuilder.fromUri(urlUtil.restPath(
uriInfo.getPath())).path(reviewCriteria.getId().toString()).build())
Expand All @@ -117,7 +117,7 @@ public Response editCriteria(@PathParam("id") Long id, TransReviewCriteria crite
return Response.status(Response.Status.NOT_FOUND).build();
}
reviewCriteria.setDescription(criteria.getDescription());
reviewCriteria.setEditable(criteria.isEditable());
reviewCriteria.setCommentRequired(criteria.isCommentRequired());
reviewCriteria.setPriority(criteria.getPriority());
return Response.ok(fromModel(reviewCriteria)).build();
}
Expand Down
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>

<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.0.xsd">

<changeSet id="1" author="efloden@redhat.com">
<comment>Rename editable to commentRequired</comment>
<renameColumn tableName="ReviewCriteria" oldColumnName="editable"
newColumnName="commentRequired" columnDataType="boolean" />
</changeSet>
<changeSet id="2" author="efloden@redhat.com">
<comment>Make commentRequired non-null</comment>
<sql>
update ReviewCriteria set commentRequired = false where commentRequired is null;
</sql>
</changeSet>
<changeSet id="3" author="efloden@redhat.com">
<comment>Make commentRequired non-nullable</comment>
<addNotNullConstraint tableName="ReviewCriteria"
columnName="commentRequired" columnDataType="boolean" />
</changeSet>

</databaseChangeLog>
2 changes: 2 additions & 0 deletions server/services/src/main/resources/db/db.changelog.xml
Expand Up @@ -51,6 +51,8 @@
file="changelogs/db.changelog-4.3.xml" />
<include relativeToChangelogFile="true"
file="changelogs/db.changelog-4.4.xml" />
<include relativeToChangelogFile="true"
file="changelogs/db.changelog-4.5.xml" />

<!-- NB: triggers and validations must appear after all table changes -->
<!-- If the Liquibase version is being updated, please refer to the
Expand Down
Expand Up @@ -19061,7 +19061,7 @@ exports[`Frontend Storyshots RejectionsForm Admin screen 1`] = `
</div>
`;

exports[`Frontend Storyshots RejectionsForm editable 1`] = `
exports[`Frontend Storyshots RejectionsForm commentRequired 1`] = `
<form
className="rejectionsForm form-inline"
>
Expand Down
4 changes: 2 additions & 2 deletions server/zanata-frontend/src/app/actions/review-actions.js
Expand Up @@ -33,7 +33,7 @@ export function addNewCriterion (criterion) {
ADD_CRITERION_FAILURE]
const body = {
...criterion,
editable: criterion.isEditable
commentRequired: criterion.isCommentRequired
}
return {
[CALL_API]: buildAPIRequest(endpoint, 'POST', getJsonHeaders(), apiTypes,
Expand Down Expand Up @@ -63,7 +63,7 @@ export function editCriterion (criterion) {
const endpoint = `${apiUrl}/review/criteria/${criterion.id}`
const body = {
...criterion,
editable: criterion.isEditable
commentRequired: criterion.isCommentRequired
}
return {
[CALL_API]: buildAPIRequest(endpoint, 'PUT', getJsonHeaders(), types,
Expand Down
Expand Up @@ -9,43 +9,43 @@ import { MINOR, MAJOR, CRITICAL } from "./index";
storiesOf('RejectionsForm', module)
.add('read only', () => (
<RejectionsForm
editable={false}
commentRequired={false}
criteriaPlaceholder='Format (mismatches, white-spaces, tag error or missing, special character, numeric format, truncated, etc.)'
priority={MINOR} textState='text-info' />
))
.add('editable', () => (
.add('commentRequired', () => (
<RejectionsForm
className='active'
editable={true}
commentRequired={true}
criteriaPlaceholder='Format (mismatches, white-spaces, tag error or missing, special character, numeric format, truncated, etc.)'
priority={MINOR} textState='text-info' />
))
.add('Admin screen', () => (
<div className='container'>
<h1>Reject translations settings</h1>
<RejectionsForm
editable={false}
commentRequired={false}
criteriaPlaceholder='Translation Errors (terminology, mistranslated, addition, omission, un-localized, do not translate, etc)'
priority={CRITICAL} textState='text-danger' />
<RejectionsForm
editable={true}
commentRequired={true}
className='active'
criteriaPlaceholder='Language Quality (grammar, spelling, punctuation, typo, ambiguous wording, product name, sentence structuring, readability, word choice, not natural, too literal, style and tone, etc)'
priority={MAJOR} textState='text-warning' />
<RejectionsForm
editable={false}
commentRequired={false}
criteriaPlaceholder='Consistency (inconsistent style or vocabulary, brand inconsistency, etc.)'
priority={MAJOR} textState='text-warning' />
<RejectionsForm
editable={false}
commentRequired={false}
criteriaPlaceholder='Style Guide & Glossary Violations'
priority={MINOR} textState='text-info' />
<RejectionsForm
editable={false}
commentRequired={false}
criteriaPlaceholder='Format (mismatches, white-spaces, tag error or missing, special character, numeric format, truncated, etc.)'
priority={MINOR} textState='text-info' />
<RejectionsForm
editable={true}
commentRequired={true}
className='active'
criteriaPlaceholder='Other (reason may be in comment section/history if necessary)'
priority={CRITICAL} textState='text-danger' />
Expand Down
22 changes: 11 additions & 11 deletions server/zanata-frontend/src/app/components/RejectionsForm/index.js
Expand Up @@ -43,7 +43,7 @@ class RejectionsForm extends Component {
description: PropTypes.string.isRequired,
onSave: PropTypes.func.isRequired,
onDelete: PropTypes.func,
editable: PropTypes.bool,
commentRequired: PropTypes.bool,
// if it's in admin mode, we will allow user to update
isAdminMode: PropTypes.bool.isRequired,
// whether delete button shoud be displayed
Expand All @@ -54,7 +54,7 @@ class RejectionsForm extends Component {

static defaultProps = {
criterionId: 'review-criteria',
editable: false,
commentRequired: false,
description: '',
isAdminMode: false,
displayDelete: true,
Expand All @@ -66,15 +66,15 @@ class RejectionsForm extends Component {
super(props)
this.state = {
description: this.props.description,
isEditable: this.props.editable,
isCommentRequired: this.props.commentRequired,
priority: this.props.priority
}
}

onEditableChange = e => {
const checked = e.target.checked
this.setState(_prevState => ({
isEditable: checked
isCommentRequired: checked
}))
}
onTextChange = e => {
Expand All @@ -92,15 +92,15 @@ class RejectionsForm extends Component {
this.props.onSave({
...this.state,
id: this.props.entityId,
editable: this.state.isEditable
commentRequired: this.state.isCommentRequired
})
}
onDelete = () => {
this.props.onDelete(this.props.entityId)
}
render () {
const {
editable,
commentRequired,
className,
isAdminMode,
displayDelete,
Expand All @@ -110,18 +110,18 @@ class RejectionsForm extends Component {
const textState = priorityToTextState(this.state.priority)
const error = isEmpty(this.state.description)
const title = <span className={textState}>{this.state.priority}</span>
const priorityDisabled = !isAdminMode && !editable
const priorityDisabled = !isAdminMode && !commentRequired
const deleteBtn = displayDelete
? (
<Button bsStyle='danger' className={className} onClick={this.onDelete}>
<Icon name='trash' className='s0 iconEdit' />
</Button>
) : DO_NOT_RENDER
const editableToggle = isAdminMode ? (
const commentToggle = isAdminMode ? (
<FormGroup controlId='formInlineEditable'>
<ControlLabel>Editable</ControlLabel><br />
<Toggle icons={false} onChange={this.onEditableChange}
checked={this.state.isEditable} />
checked={this.state.isCommentRequired} />
</FormGroup>
)
: DO_NOT_RENDER
Expand All @@ -141,7 +141,7 @@ class RejectionsForm extends Component {
<Form className='rejectionsForm' inline>
<FormGroup className='u-flexGrow1' controlId='formInlineCriteria'>
<ControlLabel>Criteria</ControlLabel><br />
<TextInput multiline editable={isAdminMode || editable}
<TextInput multiline editable={isAdminMode || commentRequired}
type='text' numberOfLines={2} onChange={this.onTextChange}
placeholder={criteriaPlaceholder} value={this.state.description} />
</FormGroup>
Expand All @@ -157,7 +157,7 @@ class RejectionsForm extends Component {
disabled={priorityDisabled}
/>
</FormGroup>
{editableToggle}
{commentToggle}
{formBtn}
</Form>
)
Expand Down
16 changes: 8 additions & 8 deletions server/zanata-frontend/src/app/containers/Admin/Review.js
Expand Up @@ -20,28 +20,28 @@ const exampleHeader = <span>Example criteria:
const exampleCriteria = <Accordion expanded={false} defaultExpanded={false}>
<Panel header={exampleHeader} eventKey="1">
<RejectionsForm
editable={false}
commentRequired={false}
criteriaPlaceholder='Translation Errors (terminology, mistranslated, addition, omission, un-localized, do not translate, etc)'
priority={CRITICAL} />
<RejectionsForm
editable
commentRequired
className='active'
criteriaPlaceholder='Language Quality (grammar, spelling, punctuation, typo, ambiguous wording, product name, sentence structuring, readability, word choice, not natural, too literal, style and tone, etc)'
priority={MAJOR} />
<RejectionsForm
editable={false}
commentRequired={false}
criteriaPlaceholder='Consistency (inconsistent style or vocabulary, brand inconsistency, etc.)'
priority={MAJOR} />
<RejectionsForm
editable={false}
commentRequired={false}
criteriaPlaceholder='Style Guide & Glossary Violations'
priority={MINOR} />
<RejectionsForm
editable={false}
commentRequired={false}
criteriaPlaceholder='Format (mismatches, white-spaces, tag error or missing, special character, numeric format, truncated, etc.)'
priority={MINOR} />
<RejectionsForm
editable
commentRequired
className='active'
criteriaPlaceholder='Other (reason may be in comment section/history if necessary)'
priority={CRITICAL} />
Expand All @@ -52,7 +52,7 @@ const exampleCriteria = <Accordion expanded={false} defaultExpanded={false}>
class AdminReview extends Component {
static propTypes = {
criteria: PropType.arrayOf(PropType.shape({
editable: PropType.bool.isRequired,
commentRequired: PropType.bool.isRequired,
description: PropType.string.isRequired,
priority: PropType.oneOf([MINOR, MAJOR, CRITICAL]).isRequired
})).isRequired,
Expand Down Expand Up @@ -82,7 +82,7 @@ class AdminReview extends Component {
render () {
const {criteria, deleteEntry, editEntry, notification} = this.props
const criteriaList = criteria.map((c, i) => <RejectionsForm key={i}
editable={c.editable} entityId={c.id} onDelete={deleteEntry}
commentRequired={c.commentRequired} entityId={c.id} onDelete={deleteEntry}
criteriaPlaceholder={c.description} isAdminMode displayDelete
onSave={editEntry} description={c.description}
priority={c.priority} />)
Expand Down
Expand Up @@ -57,7 +57,7 @@ class TransUnit extends React.Component {
// ])
selected: PropTypes.bool.isRequired,
criteria: PropTypes.arrayOf(PropTypes.shape({
editable: PropTypes.bool.isRequired,
commentRequired: PropTypes.bool.isRequired,
description: PropTypes.string.isRequired,
priority: PropTypes.oneOf([MINOR, MAJOR, CRITICAL]).isRequired
})),
Expand Down
Expand Up @@ -25,7 +25,7 @@ class MainContent extends React.Component {
toggleReviewModal: PropTypes.func.isRequired,
fetchAllCriteria: PropTypes.func.isRequired,
criteriaList: PropTypes.arrayOf(PropTypes.shape({
editable: PropTypes.bool.isRequired,
commentRequired: PropTypes.bool.isRequired,
description: PropTypes.string.isRequired,
priority: PropTypes.oneOf([MINOR, MAJOR, CRITICAL]).isRequired
})).isRequired,
Expand Down
Expand Up @@ -3,7 +3,9 @@ import { Component } from 'react'
import { Icon } from '../../../components'
import * as PropTypes from 'prop-types'
import Dropdown from '../../components/Dropdown'
import { MINOR, MAJOR, CRITICAL } from '../../utils/reject-trans-util'
import {
MINOR, MAJOR, CRITICAL, UNSPECIFIED
} from '../../utils/reject-trans-util'

/**
* A Local Editor Dropdown coponent that selects the Criteria
Expand All @@ -12,12 +14,13 @@ import { MINOR, MAJOR, CRITICAL } from '../../utils/reject-trans-util'
class CriteriaDropdown extends Component {
static propTypes = {
criteriaList: PropTypes.arrayOf(PropTypes.shape({
editable: PropTypes.bool.isRequired,
commentRequired: PropTypes.bool.isRequired,
description: PropTypes.string.isRequired,
priority: PropTypes.oneOf([MINOR, MAJOR, CRITICAL]).isRequired
})).isRequired,
onCriteriaChange: PropTypes.func.isRequired,
selectedCriteria: PropTypes.string.isRequired
onUnspecifiedCriteria: PropTypes.func.isRequired,
criteriaDescription: PropTypes.string.isRequired
}
constructor (props) {
super(props)
Expand All @@ -31,11 +34,15 @@ class CriteriaDropdown extends Component {
}))
}
onCriteriaChange = (event) => {
this.props.onCriteriaChange(event)
if (event.target.innerText === UNSPECIFIED.description) {
this.props.onUnspecifiedCriteria()
} else {
this.props.onCriteriaChange(event)
}
this.toggleDropdown()
}
render () {
const { criteriaList, selectedCriteria } = this.props
const { criteriaList, criteriaDescription } = this.props
const options = criteriaList.map((value, index) => {
return (
<li key={index}
Expand All @@ -51,7 +58,7 @@ class CriteriaDropdown extends Component {
className='dropdown-menu Criteria'>
<Dropdown.Button>
<a className='EditorDropdown-item'>
{selectedCriteria}
{criteriaDescription}
<Icon className='n1 u-pullRight' name='chevron-down' />
</a>
</Dropdown.Button>
Expand Down

0 comments on commit 7a81307

Please sign in to comment.