FIX: makes composer-actions toggling whisper instead of replying

This commit is contained in:
Joffrey JAFFEUX 2018-02-01 23:07:37 +01:00 committed by GitHub
parent 0156ae486d
commit f7df68c9a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 52 deletions

View File

@ -4,7 +4,6 @@
{{composer-actions
composerModel=model
options=model.replyOptions
whispering=model.whisper
canWhisper=canWhisper
action=model.action}}
{{/if}}

View File

@ -28,8 +28,8 @@ export default DropdownSelectBoxComponent.extend({
return content;
},
@computed("options", "canWhisper", "whispering", "composerModel.post.username")
content(options, canWhisper, whispering, postUsername) {
@computed("options", "canWhisper", "composerModel.post.username")
content(options, canWhisper, postUsername) {
let items = [
{
name: I18n.t("composer.composer_actions.reply_as_new_topic.label"),
@ -58,21 +58,12 @@ export default DropdownSelectBoxComponent.extend({
}
if (canWhisper) {
if (whispering) {
items.push({
name: I18n.t("composer.composer_actions.reply_as_not_whisper.label"),
description: I18n.t("composer.composer_actions.reply_as_not_whisper.desc"),
icon: "eye",
id: "reply_as_not_whisper"
});
} else {
items.push({
name: I18n.t("composer.composer_actions.reply_as_whisper.label"),
description: I18n.t("composer.composer_actions.reply_as_whisper.desc"),
icon: "eye-slash",
id: "reply_as_whisper"
});
}
items.push({
name: I18n.t("composer.composer_actions.toggle_whisper.label"),
description: I18n.t("composer.composer_actions.toggle_whisper.desc"),
icon: "eye-slash",
id: "toggle_whisper"
});
}
return items;
@ -92,14 +83,8 @@ export default DropdownSelectBoxComponent.extend({
actions: {
onSelect(value) {
switch(value) {
case "reply_as_whisper":
this.set("composerModel.whisper", true);
this.get("composerController").save();
break;
case "reply_as_not_whisper":
this.set("composerModel.whisper", false);
this.get("composerController").save();
case "toggle_whisper":
this.set("composerModel.whisper", !this.get("composerModel.whisper"));
break;
case "reply_to_topic":

View File

@ -1301,12 +1301,9 @@ en:
reply_to_topic:
label: Reply to topic
desc: Reply to the original post without replying to a specific post
reply_as_whisper:
label: Reply as whisper
desc: This message will only be visible by staff members
reply_as_not_whisper:
label: Reply as not whisper
desc: This message will be visible by anyone
toggle_whisper:
label: Toggle whipser
desc: Whispers will only be visible by staff members
notifications:
tooltip:

View File

@ -19,7 +19,7 @@ QUnit.test('replying to post', assert => {
assert.equal(composerActions.rowByIndex(0).value(), 'reply_as_new_topic');
assert.equal(composerActions.rowByIndex(1).value(), 'reply_as_private_message');
assert.equal(composerActions.rowByIndex(2).value(), 'reply_to_topic');
assert.equal(composerActions.rowByIndex(3).value(), 'reply_as_whisper');
assert.equal(composerActions.rowByIndex(3).value(), 'toggle_whisper');
});
});
@ -51,32 +51,18 @@ QUnit.test('replying to post - reply_to_topic', assert => {
});
});
QUnit.test('replying to post - reply_as_whisper', assert => {
QUnit.test('replying to post - toggle_whisper', assert => {
const composerActions = selectKit('.composer-actions');
visit('/t/internationalization-localization/280');
click('article#post_3 button.reply');
fillIn('.d-editor-input', 'test replying as whisper to topic when intially not a whisper');
composerActions.expand().selectRowByValue('reply_as_whisper');
composerActions.expand().selectRowByValue('toggle_whisper');
andThen(() => {
assert.ok(exists(find('.topic-post:last .post-info.whisper')));
assert.equal(find('.topic-post:last .cooked p').html().trim(), 'test replying as whisper to topic when intially not a whisper');
});
});
QUnit.test('replying to post - reply_as_not_whisper', assert => {
const composerActions = selectKit('.composer-actions');
visit('/t/internationalization-localization/280');
click('article#post_3 button.reply');
fillIn('.d-editor-input', 'test replying as not a whisper to topic when intially a whisper');
selectKit('.toolbar-popup-menu-options').expand().selectRowByValue('toggleWhisper');
composerActions.expand().selectRowByValue('reply_as_not_whisper');
andThen(() => {
assert.notOk(exists(find('.topic-post:last .post-info.whisper')));
assert.equal(find('.topic-post:last .cooked p').html().trim(), 'test replying as not a whisper to topic when intially a whisper');
assert.ok(
find('.composer-fields .whisper').text().indexOf(I18n.t("composer.whisper")) > 0
);
});
});