From 9923829402997c7af3e25121d6d3a345536f3884 Mon Sep 17 00:00:00 2001 From: Joffrey JAFFEUX Date: Thu, 1 Feb 2018 16:42:56 +0100 Subject: [PATCH] FEATURE: Menu toggle for different reply modes Allow users to access different reply modes from the composer. Actions introduced: - reply_as_new_topic - reply_as_private_message - reply_to_topic - reply_as_whisper/not --- .../components/composer-action-title.js.es6 | 63 ++++++++ .../discourse/models/composer.js.es6 | 140 +++++++++--------- .../components/composer-action-title.hbs | 12 ++ .../discourse/templates/composer.hbs | 2 +- .../components/composer-actions.js.es6 | 132 +++++++++++++++++ .../stylesheets/common/base/compose.scss | 26 +++- .../common/select-kit/composer-actions.scss | 22 +++ config/locales/client.ar.yml | 2 - config/locales/client.ca.yml | 2 - config/locales/client.cs.yml | 2 - config/locales/client.da.yml | 2 - config/locales/client.de.yml | 2 - config/locales/client.el.yml | 2 - config/locales/client.en.yml | 19 ++- config/locales/client.es.yml | 2 - config/locales/client.et.yml | 2 - config/locales/client.fa_IR.yml | 2 - config/locales/client.fi.yml | 2 - config/locales/client.fr.yml | 2 - config/locales/client.gl.yml | 2 - config/locales/client.he.yml | 2 - config/locales/client.it.yml | 2 - config/locales/client.ja.yml | 2 - config/locales/client.ko.yml | 2 - config/locales/client.lv.yml | 2 - config/locales/client.nb_NO.yml | 2 - config/locales/client.nl.yml | 2 - config/locales/client.pl_PL.yml | 2 - config/locales/client.pt.yml | 2 - config/locales/client.pt_BR.yml | 2 - config/locales/client.ro.yml | 2 - config/locales/client.ru.yml | 2 - config/locales/client.sk.yml | 2 - config/locales/client.sq.yml | 2 - config/locales/client.sv.yml | 2 - config/locales/client.th.yml | 2 - config/locales/client.tr_TR.yml | 2 - config/locales/client.ur.yml | 2 - config/locales/client.vi.yml | 2 - config/locales/client.zh_CN.yml | 2 - config/locales/client.zh_TW.yml | 2 - .../acceptance/composer-actions-test.js.es6 | 101 +++++++++++++ 42 files changed, 439 insertions(+), 144 deletions(-) create mode 100644 app/assets/javascripts/discourse/components/composer-action-title.js.es6 create mode 100644 app/assets/javascripts/discourse/templates/components/composer-action-title.hbs create mode 100644 app/assets/javascripts/select-kit/components/composer-actions.js.es6 create mode 100644 app/assets/stylesheets/common/select-kit/composer-actions.scss create mode 100644 test/javascripts/acceptance/composer-actions-test.js.es6 diff --git a/app/assets/javascripts/discourse/components/composer-action-title.js.es6 b/app/assets/javascripts/discourse/components/composer-action-title.js.es6 new file mode 100644 index 00000000000..bc6e0e95bfe --- /dev/null +++ b/app/assets/javascripts/discourse/components/composer-action-title.js.es6 @@ -0,0 +1,63 @@ +import { default as computed } from 'ember-addons/ember-computed-decorators'; +import { PRIVATE_MESSAGE, CREATE_TOPIC, REPLY, EDIT } from "discourse/models/composer"; +import { iconHTML } from 'discourse-common/lib/icon-library'; + +export default Ember.Component.extend({ + classNames: ["composer-action-title"], + options: Ember.computed.alias("model.replyOptions"), + action: Ember.computed.alias("model.action"), + isEditing: Ember.computed.equal("action", EDIT), + + @computed("options", "action") + actionTitle(opts, action) { + switch (action) { + case PRIVATE_MESSAGE: + return I18n.t("topic.private_message"); + case CREATE_TOPIC: + return I18n.t("topic.create_long"); + case REPLY: + if (opts.userAvatar && opts.userLink) { + return this._formatReplyToUserPost(opts.userAvatar, opts.userLink); + } else if (opts.topicLink) { + return this._formatReplyToTopic(opts.topicLink); + } + case EDIT: + if (opts.userAvatar && opts.userLink && opts.topicLink) { + return this._formatEditUserPost( + opts.userAvatar, + opts.userLink, + opts.topicLink, + opts.originalUser + ); + } + }; + }, + + _formatEditUserPost(userAvatar, userLink, topicLink, originalUser) { + let editTitle = ` + ${topicLink.anchor} + ${userAvatar} + ${userLink.anchor} + ${iconHTML("mail-forward", { class: "reply-to-glyph" })} + `; + + if (originalUser) { + editTitle += ` + ${originalUser.avatar} + ${originalUser.username} + `; + } + + return editTitle.htmlSafe(); + }, + + _formatReplyToTopic(link) { + return `${link.anchor}`.htmlSafe(); + }, + + _formatReplyToUserPost(avatar, link) { + const htmlLink = `${link.anchor}`; + return `${avatar}${htmlLink}`.htmlSafe(); + }, + +}); diff --git a/app/assets/javascripts/discourse/models/composer.js.es6 b/app/assets/javascripts/discourse/models/composer.js.es6 index 41ec3ba3221..3b9815b9d8a 100644 --- a/app/assets/javascripts/discourse/models/composer.js.es6 +++ b/app/assets/javascripts/discourse/models/composer.js.es6 @@ -1,4 +1,3 @@ -import { iconHTML } from 'discourse-common/lib/icon-library'; import RestModel from 'discourse/models/rest'; import Topic from 'discourse/models/topic'; import { throwAjaxError } from 'discourse/lib/ajax-error'; @@ -6,45 +5,45 @@ import Quote from 'discourse/lib/quote'; import Draft from 'discourse/models/draft'; import computed from 'ember-addons/ember-computed-decorators'; import { escapeExpression, tinyAvatar } from 'discourse/lib/utilities'; -import { emojiUnescape } from 'discourse/lib/text'; + +// The actions the composer can take +export const + CREATE_TOPIC = 'createTopic', + PRIVATE_MESSAGE = 'privateMessage', + NEW_PRIVATE_MESSAGE_KEY = 'new_private_message', + REPLY = 'reply', + EDIT = 'edit', + REPLY_AS_NEW_TOPIC_KEY = "reply_as_new_topic", + REPLY_AS_NEW_PRIVATE_MESSAGE_KEY = "reply_as_new_private_message"; const CLOSED = 'closed', - SAVING = 'saving', - OPEN = 'open', - DRAFT = 'draft', + SAVING = 'saving', + OPEN = 'open', + DRAFT = 'draft', - // The actions the composer can take - CREATE_TOPIC = 'createTopic', - PRIVATE_MESSAGE = 'privateMessage', - NEW_PRIVATE_MESSAGE_KEY = 'new_private_message', - REPLY = 'reply', - EDIT = 'edit', - REPLY_AS_NEW_TOPIC_KEY = "reply_as_new_topic", - REPLY_AS_NEW_PRIVATE_MESSAGE_KEY = "reply_as_new_private_message", + // When creating, these fields are moved into the post model from the composer model + _create_serializer = { + raw: 'reply', + title: 'title', + unlist_topic: 'unlistTopic', + category: 'categoryId', + topic_id: 'topic.id', + is_warning: 'isWarning', + whisper: 'whisper', + archetype: 'archetypeId', + target_usernames: 'targetUsernames', + typing_duration_msecs: 'typingTime', + composer_open_duration_msecs: 'composerTime', + tags: 'tags', + featured_link: 'featuredLink' + }, - // When creating, these fields are moved into the post model from the composer model - _create_serializer = { - raw: 'reply', - title: 'title', - unlist_topic: 'unlistTopic', - category: 'categoryId', - topic_id: 'topic.id', - is_warning: 'isWarning', - whisper: 'whisper', - archetype: 'archetypeId', - target_usernames: 'targetUsernames', - typing_duration_msecs: 'typingTime', - composer_open_duration_msecs: 'composerTime', - tags: 'tags', - featured_link: 'featuredLink' - }, - - _edit_topic_serializer = { - title: 'topic.title', - categoryId: 'topic.category.id', - tags: 'topic.tags', - featuredLink: 'topic.featured_link' - }; + _edit_topic_serializer = { + title: 'topic.title', + categoryId: 'topic.category.id', + tags: 'topic.tags', + featuredLink: 'topic.featured_link' + }; const _saveLabels = {}; _saveLabels[EDIT] = 'composer.save_edit'; @@ -167,52 +166,55 @@ const Composer = RestModel.extend({ return this.get('canEditTopicFeaturedLink') ? 'composer.title_or_link_placeholder' : 'composer.title_placeholder'; }, - // Determine the appropriate title for this action - actionTitle: function() { - const topic = this.get('topic'); + @computed("action", "post", "topic", "topic.title") + replyOptions(action, post, topic, topicTitle) { + let options = { + userLink: null, + topicLink: null, + postLink: null, + userAvatar: null, + originalUser: null + }; - let postLink, topicLink, usernameLink; if (topic) { - const postNumber = this.get('post.post_number'); - postLink = "" + - I18n.t("post.post_number", { number: postNumber }) + ""; - - let title = topic.get('fancy_title') || escapeExpression(topic.get('title')); - - topicLink = " " + title + ""; - usernameLink = "" + this.get('post.username') + ""; + options.topicLink = { + href: topic.get("url"), + anchor: topic.get("fancy_title") || escapeExpression(topicTitle) + }; } - let postDescription; - const post = this.get('post'); - if (post) { - postDescription = I18n.t('post.' + this.get('action'), { - link: postLink, - replyAvatar: tinyAvatar(post.get('avatar_template')), - username: this.get('post.username'), - usernameLink - }); + options.label = I18n.t(`post.${action}`); + options.userAvatar = tinyAvatar(post.get("avatar_template")); if (!this.site.mobileView) { - const replyUsername = post.get('reply_to_user.username'); - const replyAvatarTemplate = post.get('reply_to_user.avatar_template'); - if (replyUsername && replyAvatarTemplate && this.get('action') === EDIT) { - postDescription += ` ${iconHTML('mail-forward', { class: 'reply-to-glyph' })} ` + tinyAvatar(replyAvatarTemplate) + " " + replyUsername; + const originalUserName = post.get('reply_to_user.username'); + const originalUserAvatar = post.get('reply_to_user.avatar_template'); + if (originalUserName && originalUserAvatar && action === EDIT) { + options.originalUser = { + username: originalUserName, + avatar: tinyAvatar(originalUserAvatar) + }; } } } - switch (this.get('action')) { - case PRIVATE_MESSAGE: return I18n.t('topic.private_message'); - case CREATE_TOPIC: return I18n.t('topic.create_long'); - case REPLY: - case EDIT: - if (postDescription) return postDescription; - if (topic) return emojiUnescape(I18n.t('post.reply_topic', { link: topicLink })); + if (topic && post) { + const postNumber = post.get("post_number"); + + options.postLink = { + href: `${topic.get("url")}/${postNumber}`, + anchor: I18n.t("post.post_number", { number: postNumber }) + }; + + options.userLink = { + href: `${topic.get("url")}/${postNumber}`, + anchor: post.get("username") + }; } - }.property('action', 'post', 'topic', 'topic.title'), + return options; + }, // whether to disable the post button cantSubmitPost: function() { diff --git a/app/assets/javascripts/discourse/templates/components/composer-action-title.hbs b/app/assets/javascripts/discourse/templates/components/composer-action-title.hbs new file mode 100644 index 00000000000..fcb2bacfa05 --- /dev/null +++ b/app/assets/javascripts/discourse/templates/components/composer-action-title.hbs @@ -0,0 +1,12 @@ +{{#if isEditing}} + {{d-icon "pencil"}} +{{else}} + {{composer-actions + composerModel=model + options=model.replyOptions + whispering=model.whisper + canWhisper=canWhisper + action=model.action}} +{{/if}} + +{{actionTitle}} diff --git a/app/assets/javascripts/discourse/templates/composer.hbs b/app/assets/javascripts/discourse/templates/composer.hbs index ed0b8c40285..beb60b375aa 100644 --- a/app/assets/javascripts/discourse/templates/composer.hbs +++ b/app/assets/javascripts/discourse/templates/composer.hbs @@ -16,7 +16,7 @@ {{plugin-outlet name="composer-open" args=(hash model=model)}}
- {{{model.actionTitle}}} + {{composer-action-title model=model canWhisper=canWhisper}} {{#unless site.mobileView}} {{#if whisperOrUnlistTopicText}} diff --git a/app/assets/javascripts/select-kit/components/composer-actions.js.es6 b/app/assets/javascripts/select-kit/components/composer-actions.js.es6 new file mode 100644 index 00000000000..d8b3a2be475 --- /dev/null +++ b/app/assets/javascripts/select-kit/components/composer-actions.js.es6 @@ -0,0 +1,132 @@ +import DropdownSelectBoxComponent from "select-kit/components/dropdown-select-box"; +import { default as computed } from "ember-addons/ember-computed-decorators"; +import { default as Composer, REPLY, EDIT } from "discourse/models/composer"; + +export default DropdownSelectBoxComponent.extend({ + composerController: Ember.inject.controller("composer"), + pluginApiIdentifiers: ["composer-actions"], + classNames: "composer-actions", + fullWidthOnMobile: true, + collectionHeight: "auto", + autofilterable: false, + filterable: false, + allowInitialValueMutation: false, + allowAutoSelectFirst: false, + showFullTitle: false, + + computeHeaderContent() { + let content = this.baseHeaderComputedContent(); + + switch (this.get("action")) { + case REPLY: + content.icon = "mail-forward"; + break; + case EDIT: + content.icon = "pencil"; + break; + }; + + return content; + }, + + @computed("options", "canWhisper", "whispering", "composerModel.post.username") + content(options, canWhisper, whispering, postUsername) { + let items = [ + { + name: I18n.t("composer.composer_actions.reply_as_new_topic.label"), + description: I18n.t("composer.composer_actions.reply_as_new_topic.desc"), + icon: "plus", + id: "reply_as_new_topic" + } + ]; + + if (postUsername && postUsername !== this.currentUser.get("username")) { + items.push({ + name: I18n.t("composer.composer_actions.reply_as_private_message.label"), + description: I18n.t("composer.composer_actions.reply_as_private_message.desc"), + icon: "envelope", + id: "reply_as_private_message" + }); + } + + if (Ember.get(options, "postLink")) { + items.push({ + name: I18n.t("composer.composer_actions.reply_to_topic.label"), + description: I18n.t("composer.composer_actions.reply_to_topic.desc"), + icon: "mail-forward", + id: "reply_to_topic" + }); + } + + 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" + }); + } + } + + return items; + }, + + _replyFromExisting(options) { + const topicTitle = this.get("composerModel.topic.title"); + let url = this.get("composerModel.post.url") || this.get("composerModel.topic.url"); + + this.get("composerController").open(options).then(() => { + url = `${location.protocol}//${location.host}${url}`; + const link = `[${Handlebars.escapeExpression(topicTitle)}](${url})`; + this.get("composerController").get("model").prependText(`${I18n.t("post.continue_discussion", { postLink: link })}`, {new_line: true}); + }); + }, + + 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(); + break; + + case "reply_to_topic": + this.set("composerModel.post", null); + this.get("composerController").save(); + break; + + case "reply_as_new_topic": + const replyAsNewTopicOpts = { + action: Composer.CREATE_TOPIC, + draftKey: Composer.REPLY_AS_NEW_TOPIC_KEY, + categoryId: this.get("composerModel.topic.category.id") + }; + this._replyFromExisting(replyAsNewTopicOpts); + break; + + case "reply_as_private_message": + const replyAsPrivateMsgOpts = { + action: Composer.PRIVATE_MESSAGE, + archetypeId: "private_message", + draftKey: Composer.REPLY_AS_NEW_PRIVATE_MESSAGE_KEY, + usernames: this.get("composerModel.post.username") + }; + this._replyFromExisting(replyAsPrivateMsgOpts); + break; + } + } + } +}); diff --git a/app/assets/stylesheets/common/base/compose.scss b/app/assets/stylesheets/common/base/compose.scss index bd343963b35..5160d934ddb 100644 --- a/app/assets/stylesheets/common/base/compose.scss +++ b/app/assets/stylesheets/common/base/compose.scss @@ -11,7 +11,7 @@ max-width: 1475px; width: 100%; &.hide-preview { - max-width:740px; + max-width:740px; } @media screen and (max-width: 1200px) { min-width: 0; @@ -29,7 +29,7 @@ .saving-text, .draft-text { display: none; - padding-left: 10px; + padding-left: 10px; .spinner { margin-left: 5px; border-color: $secondary; @@ -96,11 +96,25 @@ color: $primary-high; } .reply-details { - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; max-width: calc(100% - 100px); } + .composer-action-title { + display: inline-flex; + align-items: center; + justify-content: space-between; + + .topic-link, .user-link, .username { + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + max-width: calc(100%-125px); + margin-right: 5px; + } + + .d-icon { + margin-right: 5px; + } + } .composer-controls { margin-left: auto; margin-right: -5px; @@ -378,4 +392,4 @@ div.ac-wrap { .md-table { overflow-y: auto; -} \ No newline at end of file +} diff --git a/app/assets/stylesheets/common/select-kit/composer-actions.scss b/app/assets/stylesheets/common/select-kit/composer-actions.scss new file mode 100644 index 00000000000..a2dace01076 --- /dev/null +++ b/app/assets/stylesheets/common/select-kit/composer-actions.scss @@ -0,0 +1,22 @@ +.select-kit { + &.dropdown-select-box { + &.composer-actions { + margin: 0; + .select-kit-header { + background: none; + outline: none; + padding: 0; + + .d-icon { + border: 1px solid $primary-low; + padding: 5px; + margin: 0; + + &:hover { + background: $primary-low; + } + } + } + } + } +} diff --git a/config/locales/client.ar.yml b/config/locales/client.ar.yml index dfe5b65c70d..fcbc996ac85 100644 --- a/config/locales/client.ar.yml +++ b/config/locales/client.ar.yml @@ -1855,8 +1855,6 @@ ar: many: لقد حدّدت {{count}} منشور. other: لقد حدّدت {{count}} منشور. post: - reply: " {{replyAvatar}} {{usernameLink}}" - reply_topic: " {{link}}" quote_reply: "اقتبس" edit_reason: "السبب:" post_number: "المنشور {{number}}" diff --git a/config/locales/client.ca.yml b/config/locales/client.ca.yml index bd1bb04b051..7abb2bad4da 100644 --- a/config/locales/client.ca.yml +++ b/config/locales/client.ca.yml @@ -1505,8 +1505,6 @@ ca: one: Has seleccionat 1 publicació other: Has seleccionat {{count}} publicacions. post: - reply: " {{replyAvatar}} {{usernameLink}}" - reply_topic: " {{link}}" quote_reply: "Cita" edit_reason: "Motiu:" post_number: "publicació {{number}}" diff --git a/config/locales/client.cs.yml b/config/locales/client.cs.yml index b4aff067586..1ccb8cd93ce 100644 --- a/config/locales/client.cs.yml +++ b/config/locales/client.cs.yml @@ -1542,8 +1542,6 @@ cs: few: Máte označeny {{count}} příspěvky. other: Máte označeno {{count}} příspěvků. post: - reply: " {{replyAvatar}} {{usernameLink}}" - reply_topic: " {{link}}" quote_reply: "Cituj" edit_reason: "Důvod: " post_number: "příspěvek č. {{number}}" diff --git a/config/locales/client.da.yml b/config/locales/client.da.yml index a48aaee063b..b652bd9ad8f 100644 --- a/config/locales/client.da.yml +++ b/config/locales/client.da.yml @@ -1540,8 +1540,6 @@ da: one: Du har valgt 1 indlæg. other: Du har valgt {{count}} indlæg. post: - reply: " {{replyAvatar}} {{usernameLink}}" - reply_topic: " {{link}}" quote_reply: "Citér" edit_reason: "Reason: " post_number: "indlæg {{number}}" diff --git a/config/locales/client.de.yml b/config/locales/client.de.yml index 16fc0a2d619..c1fde58866d 100644 --- a/config/locales/client.de.yml +++ b/config/locales/client.de.yml @@ -1695,8 +1695,6 @@ de: one: Du hast 1 Beitrag ausgewählt. other: Du hast {{count}} Beiträge ausgewählt. post: - reply: " {{replyAvatar}} {{usernameLink}}" - reply_topic: " {{link}}" quote_reply: "Zitat" edit: " {{link}} {{replyAvatar}} {{username}}" edit_reason: "Grund: " diff --git a/config/locales/client.el.yml b/config/locales/client.el.yml index 51d9a38c548..5dee9bb3a9c 100644 --- a/config/locales/client.el.yml +++ b/config/locales/client.el.yml @@ -1654,8 +1654,6 @@ el: one: Έχεις επιλέξει 1 ανάρτηση. other: Έχεις επιλέξει {{count}} αναρτήσεις. post: - reply: " {{replyAvatar}} {{usernameLink}}" - reply_topic: " {{link}}" quote_reply: "Παράθεση" edit_reason: "Αιτία:" post_number: "ανάρτηση {{number}}" diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 2cfdb0e1d14..2a0127f39d7 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -1291,6 +1291,23 @@ en: admin_options_title: "Optional staff settings for this topic" + composer_actions: + reply_as_new_topic: + label: Reply as linked topic + desc: Create a new topic + reply_as_private_message: + label: New message + desc: Create a private message + 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 whipser + desc: This message will only be visible by staff members + reply_as_not_whisper: + label: Reply as not whisher + desc: This message will be visible by anyone + notifications: tooltip: regular: @@ -1882,8 +1899,6 @@ en: other: "You have selected {{count}} posts." post: - reply: " {{replyAvatar}} {{usernameLink}}" - reply_topic: " {{link}}" quote_reply: "Quote" edit: " {{link}} {{replyAvatar}} {{username}}" edit_reason: "Reason: " diff --git a/config/locales/client.es.yml b/config/locales/client.es.yml index 7d90c9c29da..5c3311303bb 100644 --- a/config/locales/client.es.yml +++ b/config/locales/client.es.yml @@ -1702,8 +1702,6 @@ es: one: Has seleccionado 1 post. other: Has seleccionado {{count}} posts. post: - reply: " {{replyAvatar}} {{usernameLink}}" - reply_topic: " {{link}}" quote_reply: "Citar" edit: "{{link}} {{replyAvatar}} {{username}} " edit_reason: "Motivo:" diff --git a/config/locales/client.et.yml b/config/locales/client.et.yml index b5af3416329..081d116139b 100644 --- a/config/locales/client.et.yml +++ b/config/locales/client.et.yml @@ -1599,8 +1599,6 @@ et: one: Oled valinud 1 postituse. other: Oled valinud {{count}} postitust. post: - reply: " {{replyAvatar}} {{usernameLink}}" - reply_topic: " {{link}}" quote_reply: "Tsitaat" edit_reason: "Põhjus:" post_number: "postitus {{number}}" diff --git a/config/locales/client.fa_IR.yml b/config/locales/client.fa_IR.yml index 7324b3d6e5e..6af668a8b9d 100644 --- a/config/locales/client.fa_IR.yml +++ b/config/locales/client.fa_IR.yml @@ -1512,8 +1512,6 @@ fa_IR: description: other: شما {{count}} نوشته انتخاب کرده اید post: - reply: " {{replyAvatar}} {{usernameLink}}" - reply_topic: " {{link}}" quote_reply: "نقل‌قول" edit_reason: "دلیل:" post_number: "نوشته {{number}}" diff --git a/config/locales/client.fi.yml b/config/locales/client.fi.yml index 80ff33b64e6..e900163c6dc 100644 --- a/config/locales/client.fi.yml +++ b/config/locales/client.fi.yml @@ -1699,8 +1699,6 @@ fi: one: Olet valinnut yhden viestin. other: Olet valinnut {{count}} viestiä. post: - reply: " {{replyAvatar}} {{usernameLink}}" - reply_topic: " {{link}}" quote_reply: "Lainaa" edit: " {{link}} {{replyAvatar}} {{username}}" edit_reason: "Syy:" diff --git a/config/locales/client.fr.yml b/config/locales/client.fr.yml index fb23784f140..3ca5f14f9c0 100644 --- a/config/locales/client.fr.yml +++ b/config/locales/client.fr.yml @@ -1695,8 +1695,6 @@ fr: one: vous avez sélectionné 1 message. other: Vous avez sélectionné {{count}} messages. post: - reply: " {{replyAvatar}} {{usernameLink}}" - reply_topic: " {{link}}" quote_reply: "Citer" edit: " {{link}} {{replyAvatar}} {{username}}" edit_reason: "Raison :" diff --git a/config/locales/client.gl.yml b/config/locales/client.gl.yml index b982402abaa..a70d651147b 100644 --- a/config/locales/client.gl.yml +++ b/config/locales/client.gl.yml @@ -1188,8 +1188,6 @@ gl: one: Seleccionaches unha publicación. other: Seleccionaches {{count}} publicacións. post: - reply: " {{replyAvatar}} {{usernameLink}}" - reply_topic: " {{link}}" edit_reason: "Razón:" post_number: "publicación {{number}}" last_edited_on: "última edición da publicación" diff --git a/config/locales/client.he.yml b/config/locales/client.he.yml index 3e7e7ddf0c7..c3a9655f087 100644 --- a/config/locales/client.he.yml +++ b/config/locales/client.he.yml @@ -1561,8 +1561,6 @@ he: one: בחרתם פוסט אחד. other: בחרתם {{count}} פוסטים. post: - reply: " {{replyAvatar}} {{usernameLink}}" - reply_topic: " {{link}}" quote_reply: "ציטוט" edit_reason: "סיבה: " post_number: "פוסט {{number}}" diff --git a/config/locales/client.it.yml b/config/locales/client.it.yml index a6466033990..d42929dd86d 100644 --- a/config/locales/client.it.yml +++ b/config/locales/client.it.yml @@ -1691,8 +1691,6 @@ it: one: Hai selezionato 1 messaggio. other: Hai selezionato {{count}} messaggi. post: - reply: " {{replyAvatar}} {{usernameLink}}" - reply_topic: " {{link}}" quote_reply: "Cita" edit_reason: "Motivo:" post_number: "messaggio {{number}}" diff --git a/config/locales/client.ja.yml b/config/locales/client.ja.yml index 2db0766819e..f39726ff713 100644 --- a/config/locales/client.ja.yml +++ b/config/locales/client.ja.yml @@ -1567,8 +1567,6 @@ ja: description: other: {{count}}個の投稿を選択中。 post: - reply: " {{replyAvatar}} {{usernameLink}}" - reply_topic: " {{link}}" quote_reply: "引用" edit_reason: "理由: " post_number: "投稿{{number}}" diff --git a/config/locales/client.ko.yml b/config/locales/client.ko.yml index 4a726211067..90581f22b43 100644 --- a/config/locales/client.ko.yml +++ b/config/locales/client.ko.yml @@ -1578,8 +1578,6 @@ ko: description: other: {{count}}개의 개시글을 선택하셨어요. post: - reply: " {{replyAvatar}} {{usernameLink}}" - reply_topic: " {{link}}" quote_reply: "인용하기" edit_reason: "Reason: " post_number: "{{number}}번째 글" diff --git a/config/locales/client.lv.yml b/config/locales/client.lv.yml index ed00ec83da5..df3d7e95919 100644 --- a/config/locales/client.lv.yml +++ b/config/locales/client.lv.yml @@ -1623,8 +1623,6 @@ lv: one: Jūs esat izvēlējies 1 ierakstu. other: Jūs esat izvēlējies {{count}} ierakstus. post: - reply: " {{replyAvatar}} {{usernameLink}}" - reply_topic: " {{link}}" quote_reply: "Citāts" edit_reason: "Iemesls:" post_number: "ieraksts {{number}}" diff --git a/config/locales/client.nb_NO.yml b/config/locales/client.nb_NO.yml index 6c5b33a3f24..57258dd4199 100644 --- a/config/locales/client.nb_NO.yml +++ b/config/locales/client.nb_NO.yml @@ -1702,8 +1702,6 @@ nb_NO: one: Du har valgt 1 innlegg. other: Du har valgt {{count}} innlegg. post: - reply: " {{replyAvatar}} {{usernameLink}}" - reply_topic: " {{link}}" quote_reply: "Sitat" edit: " {{link}} {{replyAvatar}} {{username}}" edit_reason: "Begrunnelse:" diff --git a/config/locales/client.nl.yml b/config/locales/client.nl.yml index c50421b1a15..05d96910efd 100644 --- a/config/locales/client.nl.yml +++ b/config/locales/client.nl.yml @@ -1623,8 +1623,6 @@ nl: one: U hebt 1 bericht geselecteerd. other: U hebt {{count}} berichten geselecteerd. post: - reply: " {{replyAvatar}} {{usernameLink}}" - reply_topic: " {{link}}" quote_reply: "Citeren" edit_reason: "Reden: " post_number: "bericht {{number}}" diff --git a/config/locales/client.pl_PL.yml b/config/locales/client.pl_PL.yml index 44980ea0d07..373ccc956c8 100644 --- a/config/locales/client.pl_PL.yml +++ b/config/locales/client.pl_PL.yml @@ -1784,8 +1784,6 @@ pl_PL: many: Wybrano {{count}} wpisów. other: Wybrano {{count}} wpisów. post: - reply: " {{replyAvatar}} {{usernameLink}}" - reply_topic: " {{link}}" quote_reply: "Cytuj" edit_reason: "Powód" post_number: "wpis {{number}}" diff --git a/config/locales/client.pt.yml b/config/locales/client.pt.yml index fd667b5ac22..641d809ba4a 100644 --- a/config/locales/client.pt.yml +++ b/config/locales/client.pt.yml @@ -1514,8 +1514,6 @@ pt: one: Selecionou 1 publicação. other: Selecionou {{count}} publicações. post: - reply: " {{replyAvatar}} {{usernameLink}}" - reply_topic: " {{link}}" quote_reply: "Citar" edit_reason: "Motivo:" post_number: "publicação {{number}}" diff --git a/config/locales/client.pt_BR.yml b/config/locales/client.pt_BR.yml index f94403a25e3..95838a2e05b 100644 --- a/config/locales/client.pt_BR.yml +++ b/config/locales/client.pt_BR.yml @@ -1581,8 +1581,6 @@ pt_BR: one: 1 resposta selecionada. other: {{count}} respostas selecionadas. post: - reply: " {{replyAvatar}} {{usernameLink}}" - reply_topic: " {{link}}" quote_reply: "Citação" edit_reason: "Motivo:" post_number: "resposta {{number}}" diff --git a/config/locales/client.ro.yml b/config/locales/client.ro.yml index 11a6e9f587b..795e66f6503 100644 --- a/config/locales/client.ro.yml +++ b/config/locales/client.ro.yml @@ -1487,8 +1487,6 @@ ro: few: Ai selectat {{count}} mesaje. other: Ai selectat {{count}} de mesaje. post: - reply: " {{replyAvatar}} {{usernameLink}}" - reply_topic: " {{link}}" quote_reply: "Citează" edit_reason: "Motivul edit[rii: " post_number: "postarea {{number}}" diff --git a/config/locales/client.ru.yml b/config/locales/client.ru.yml index f0421e01e98..211f98c3bb8 100644 --- a/config/locales/client.ru.yml +++ b/config/locales/client.ru.yml @@ -1687,8 +1687,6 @@ ru: many: Вы выбрали {{count}} сообщений. other: Вы выбрали {{count}} сообщений. post: - reply: " {{replyAvatar}} {{usernameLink}}" - reply_topic: " {{link}}" quote_reply: "Цитата" edit_reason: "Причина:" post_number: "сообщение {{number}}" diff --git a/config/locales/client.sk.yml b/config/locales/client.sk.yml index 928dea873a5..873a2d0353f 100644 --- a/config/locales/client.sk.yml +++ b/config/locales/client.sk.yml @@ -1428,8 +1428,6 @@ sk: few: Označili ste {{count}} príspevky other: Označili ste {{count}} príspevkov post: - reply: " {{replyAvatar}} {{usernameLink}}" - reply_topic: " {{link}}" quote_reply: "Citácia" edit_reason: "Dôvod:" post_number: "príspevok {{number}}" diff --git a/config/locales/client.sq.yml b/config/locales/client.sq.yml index 665b5e622b8..ceca48bba6b 100644 --- a/config/locales/client.sq.yml +++ b/config/locales/client.sq.yml @@ -1391,8 +1391,6 @@ sq: one: Keni përzgjedhur 1 postim. other: Keni përzgjedhur {{count}} postime. post: - reply: " {{replyAvatar}} {{usernameLink}}" - reply_topic: " {{link}}" edit_reason: "Arsyeja:" post_number: "postimi {{number}}" last_edited_on: "redaktimi i fundit u krye më" diff --git a/config/locales/client.sv.yml b/config/locales/client.sv.yml index f2bcf7ae5e0..bbb3959bf5c 100644 --- a/config/locales/client.sv.yml +++ b/config/locales/client.sv.yml @@ -1485,8 +1485,6 @@ sv: one: Du har markerat 1 inlägg. other: Du har markerat {{count}} inlägg. post: - reply: " {{replyAvatar}} {{usernameLink}}" - reply_topic: " {{link}}" quote_reply: "Citat" edit_reason: "Anledning:" post_number: "inlägg {{number}}" diff --git a/config/locales/client.th.yml b/config/locales/client.th.yml index 4b4130e1ae2..d78a454e767 100644 --- a/config/locales/client.th.yml +++ b/config/locales/client.th.yml @@ -1129,8 +1129,6 @@ th: description: other: คุณได้เลือก {{count}} โพสต์. post: - reply: " {{replyAvatar}} {{usernameLink}}" - reply_topic: " {{link}}" edit_reason: "เหตุผล:" post_number: "โพสต์ {{number}}" last_edited_on: "โพสแก้ไขล่าสุดเมื่อ" diff --git a/config/locales/client.tr_TR.yml b/config/locales/client.tr_TR.yml index 0b5a6255f29..c5a7a4275c3 100644 --- a/config/locales/client.tr_TR.yml +++ b/config/locales/client.tr_TR.yml @@ -1501,8 +1501,6 @@ tr_TR: description: other: {{count}} gönderi seçtiniz. post: - reply: " {{replyAvatar}} {{usernameLink}}" - reply_topic: " {{link}}" quote_reply: "Alıntı" edit_reason: "Neden: " post_number: "gönderi {{number}}" diff --git a/config/locales/client.ur.yml b/config/locales/client.ur.yml index 21604d91b50..0e7c1899e3e 100644 --- a/config/locales/client.ur.yml +++ b/config/locales/client.ur.yml @@ -1443,8 +1443,6 @@ ur: one: آپ نے 1 پوسٹ منتخب کی ہے۔ other: آپ نے {{count}} پوسٹس منتخب کی ہیں۔ post: - reply: " {{replyAvatar}} {{usernameLink}}" - reply_topic: " {{link}}" quote_reply: "اقتباس کریں" edit_reason: "وجہ:" post_number: "پوسٹ {{number}}" diff --git a/config/locales/client.vi.yml b/config/locales/client.vi.yml index 143b0a6fad4..30a91db4cd2 100644 --- a/config/locales/client.vi.yml +++ b/config/locales/client.vi.yml @@ -1414,8 +1414,6 @@ vi: description: other: Bạn đã chọn {{count}} bài viết. post: - reply: " {{replyAvatar}} {{usernameLink}}" - reply_topic: " {{link}}" quote_reply: "Trích dẫn" edit_reason: "Lý do: " post_number: "bài viết {{number}}" diff --git a/config/locales/client.zh_CN.yml b/config/locales/client.zh_CN.yml index 35835966f2e..e2e11312579 100644 --- a/config/locales/client.zh_CN.yml +++ b/config/locales/client.zh_CN.yml @@ -1623,8 +1623,6 @@ zh_CN: description: other: 已选择 {{count}} 个帖子。 post: - reply: " {{replyAvatar}} {{usernameLink}}" - reply_topic: " {{link}}" quote_reply: "引用" edit: " {{link}} {{replyAvatar}} {{username}}" edit_reason: "理由:" diff --git a/config/locales/client.zh_TW.yml b/config/locales/client.zh_TW.yml index 6fd464b20e9..0a26c393e2a 100644 --- a/config/locales/client.zh_TW.yml +++ b/config/locales/client.zh_TW.yml @@ -1404,8 +1404,6 @@ zh_TW: description: other: 你已選擇了 {{count}} 篇文章。 post: - reply: " {{replyAvatar}} {{usernameLink}}" - reply_topic: " {{link}}" quote_reply: "引用" edit_reason: "原因: " post_number: "文章 {{number}}" diff --git a/test/javascripts/acceptance/composer-actions-test.js.es6 b/test/javascripts/acceptance/composer-actions-test.js.es6 new file mode 100644 index 00000000000..f8b848389ae --- /dev/null +++ b/test/javascripts/acceptance/composer-actions-test.js.es6 @@ -0,0 +1,101 @@ +import { acceptance } from 'helpers/qunit-helpers'; + +acceptance('Composer Actions', { + loggedIn: true, + settings: { + enable_whispers: true + } +}); + +QUnit.test('replying to post', assert => { + const composerActions = selectKit('.composer-actions'); + + visit('/t/internationalization-localization/280'); + click('article#post_3 button.reply'); + + composerActions.expand(); + + andThen(() => { + 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'); + }); +}); + +QUnit.test('replying to post - reply_as_private_message', assert => { + const composerActions = selectKit('.composer-actions'); + + visit('/t/internationalization-localization/280'); + click('article#post_3 button.reply'); + + composerActions.expand().selectRowByValue('reply_as_private_message'); + + andThen(() => { + assert.equal(find('.users-input .item:eq(0)').text(), 'codinghorror'); + assert.ok(find('.d-editor-input').val().indexOf('Continuing the discussion') >= 0); + }); +}); + +QUnit.test('replying to post - reply_to_topic', assert => { + const composerActions = selectKit('.composer-actions'); + + visit('/t/internationalization-localization/280'); + click('article#post_3 button.reply'); + fillIn('.d-editor-input', 'test replying to topic when intially replied to post'); + composerActions.expand().selectRowByValue('reply_to_topic'); + + andThen(() => { + assert.equal(find('.topic-post:last .cooked p').html().trim(), 'test replying to topic when intially replied to post'); + assert.notOk(exists(find('.topic-post:last .reply-to-tab'))); + }); +}); + +QUnit.test('replying to post - reply_as_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'); + + 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'); + }); +}); + +QUnit.test('replying to post - reply_as_new_topic', assert => { + const composerActions = selectKit('.composer-actions'); + const categoryChooser = selectKit('.title-wrapper .category-chooser'); + const categoryChooserReplyArea = selectKit('.reply-area .category-chooser'); + + visit('/t/internationalization-localization/280'); + + click('#topic-title .d-icon-pencil'); + categoryChooser.expand().selectRowByValue(4); + click('#topic-title .submit-edit'); + + click('article#post_3 button.reply'); + composerActions.expand().selectRowByValue('reply_as_new_topic'); + + andThen(() => { + assert.equal(categoryChooserReplyArea.header().name(), 'faq'); + assert.ok(find('.d-editor-input').val().indexOf('Continuing the discussion') >= 0); + }); +});