Skip to content

Commit

Permalink
Editor: deactivate placeables in read-only mode
Browse files Browse the repository at this point in the history
Fixes #460.
  • Loading branch information
julen committed Apr 6, 2020
1 parent 8fc770d commit 1e5d8f0
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ v.next (unreleased)
* Browser: disabled projects are taken out from counters by default (#425).
* Editor: allowed to filter units from enabled/disabled projects (#425).
* Fixed bug where no overview stats were shown for language pages (#425).
* Editor: placeables are not actionable in read-only mode (#460).


v0.9.1 (2020-03-11)
Expand Down
4 changes: 3 additions & 1 deletion pootle/static/js/editor/components/UnitSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { highlightRW } from '../../utils';

const UnitSource = React.createClass({
propTypes: {
canEdit: React.PropTypes.bool.isRequired,
id: React.PropTypes.number.isRequired,
values: React.PropTypes.array.isRequired,
hasPlurals: React.PropTypes.bool.isRequired,
Expand All @@ -27,6 +28,7 @@ const UnitSource = React.createClass({
lang: this.props.sourceLocaleCode,
dir: this.props.sourceLocaleDir,
};
const placeablesExtraClassName = this.props.canEdit ? 'js-editor-copytext' : '';

return (
<div key={`source-value-${index}`}>
Expand All @@ -39,7 +41,7 @@ const UnitSource = React.createClass({
className="translation-text js-translation-text"
data-string={sourceValue}
dangerouslySetInnerHTML={{
__html: highlightRW(sourceValue, 'js-editor-copytext'),
__html: highlightRW(sourceValue, placeablesExtraClassName),
}}
{...props}
></div>
Expand Down
2 changes: 2 additions & 0 deletions pootle/static/js/editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ const ReactEditor = {
);
ReactRenderer.render(
<UnitSource
canEdit={this.props.canSuggest || this.props.canTranslate}
id={this.props.unitId}
values={this.props.sourceValues}
hasPlurals={this.props.hasPlurals}
Expand All @@ -71,6 +72,7 @@ const ReactEditor = {
const unit = this.props.alternativeSources[mountNode.dataset.id];
ReactRenderer.render(
<UnitSource
canEdit={this.props.canSuggest || this.props.canTranslate}
id={unit.id}
values={unit.target}
hasPlurals={unit.has_plurals}
Expand Down
2 changes: 2 additions & 0 deletions pootle/templates/editor/units/edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@

<script type="text/javascript">
PTL.reactEditor.init({
canSuggest: {{ cansuggest|yesno:'true,false' }},
canTranslate: {{ cantranslate|yesno:'true,false' }},
initialValues: {{ unit_values|to_jquery_safe_js }},
isDisabled: {{ form.target_f.field.widget.attrs.disabled|yesno:'true,false' }},
currentLocaleCode: '{{ language.code }}',
Expand Down

0 comments on commit 1e5d8f0

Please sign in to comment.