FIX: do not show "move to new PM" option to moderators

This commit is contained in:
Arpit Jalan 2019-02-18 11:34:29 +05:30
parent 052eaed16a
commit dc2776bcdd
2 changed files with 13 additions and 9 deletions

View File

@ -66,10 +66,9 @@ export default Ember.Controller.extend(ModalFunctionality, {
}); });
const isPrivateMessage = this.get("model.isPrivateMessage"); const isPrivateMessage = this.get("model.isPrivateMessage");
const canSplitTopic = this.get("canSplitTopic");
if (isPrivateMessage) { if (isPrivateMessage) {
this.set("selection", canSplitTopic ? "new_message" : "existing_message"); this.set("selection", this.get("canSplitToPM") ? "new_message" : "existing_message");
} else if (!canSplitTopic) { } else if (!this.get("canSplitTopic")) {
this.set("selection", "existing_topic"); this.set("selection", "existing_topic");
Ember.run.next(() => $("#choose-topic-title").focus()); Ember.run.next(() => $("#choose-topic-title").focus());
} }
@ -85,6 +84,11 @@ export default Ember.Controller.extend(ModalFunctionality, {
); );
}, },
@computed("canSplitTopic")
canSplitToPM(canSplitTopic) {
return canSplitTopic && (this.currentUser && this.currentUser.admin);
},
actions: { actions: {
performMove() { performMove() {
this.get("moveTypes").forEach(type => { this.get("moveTypes").forEach(type => {

View File

@ -2,17 +2,17 @@
{{#if model.isPrivateMessage}} {{#if model.isPrivateMessage}}
<div class="radios"> <div class="radios">
{{#if canSplitTopic}} {{#if canSplitToPM}}
<label class="radio-label" for="move-to-new-message"> <label class="radio-label" for="move-to-new-message">
{{radio-button id='move-to-new-message' name="move-to-entity" value="new_message" selection=selection}} {{radio-button id='move-to-new-message' name="move-to-entity" value="new_message" selection=selection}}
<b>{{i18n 'topic.move_to_new_message.radio_label'}}</b> <b>{{i18n 'topic.move_to_new_message.radio_label'}}</b>
</label> </label>
{{/if}} {{/if}}
<label class="radio-label" for="move-to-existing-message"> <label class="radio-label" for="move-to-existing-message">
{{radio-button id='move-to-existing-message' name="move-to-entity" value="existing_message" selection=selection}} {{radio-button id='move-to-existing-message' name="move-to-entity" value="existing_message" selection=selection}}
<b>{{i18n 'topic.move_to_existing_message.radio_label'}}</b> <b>{{i18n 'topic.move_to_existing_message.radio_label'}}</b>
</label> </label>
</div> </div>
{{#if canSplitTopic}} {{#if canSplitTopic}}
@ -55,7 +55,7 @@
<b>{{i18n 'topic.merge_topic.radio_label'}}</b> <b>{{i18n 'topic.merge_topic.radio_label'}}</b>
</label> </label>
{{#if canSplitTopic}} {{#if canSplitToPM}}
<label class="radio-label" for="move-to-new-message"> <label class="radio-label" for="move-to-new-message">
{{radio-button id='move-to-new-message' name="move-to-entity" value="new_message" selection=selection}} {{radio-button id='move-to-new-message' name="move-to-entity" value="new_message" selection=selection}}
<b>{{i18n 'topic.move_to_new_message.radio_label'}}</b> <b>{{i18n 'topic.move_to_new_message.radio_label'}}</b>