From 12491fa8d519a05551868ce031729f2f1f1635f2 Mon Sep 17 00:00:00 2001 From: Pranav Raj S Date: Tue, 19 Jan 2021 19:28:40 +0530 Subject: [PATCH] feat: Add "Enter to send" option on format mode (#1671) --- .../assets/scss/widgets/_reply-box.scss | 11 +++--- .../widgets/WootWriter/ReplyBottomPanel.vue | 37 ++++++++++++++++++- .../widgets/conversation/CannedResponse.vue | 11 +++++- .../widgets/conversation/ReplyBox.vue | 31 +++++++++++++--- .../i18n/locale/en/conversation.json | 3 +- 5 files changed, 78 insertions(+), 15 deletions(-) diff --git a/app/javascript/dashboard/assets/scss/widgets/_reply-box.scss b/app/javascript/dashboard/assets/scss/widgets/_reply-box.scss index 870a60c1b..f1d31af09 100644 --- a/app/javascript/dashboard/assets/scss/widgets/_reply-box.scss +++ b/app/javascript/dashboard/assets/scss/widgets/_reply-box.scss @@ -9,16 +9,15 @@ .reply-box__top { .canned { - @include elegant-card; - background: $color-white; - border-bottom: $space-small solid $color-white; - border-top: $space-small solid $color-white; + background: var(--white); + border-bottom: var(--space-small) solid var(--white); + border-top: 1px solid var(--color-border); left: 0; - max-height: 14rem; overflow: auto; + padding-top: var(--space-small); position: absolute; - width: 24rem; + width: 100%; z-index: 100; .active a { diff --git a/app/javascript/dashboard/components/widgets/WootWriter/ReplyBottomPanel.vue b/app/javascript/dashboard/components/widgets/WootWriter/ReplyBottomPanel.vue index e6a229169..c8dffd6d0 100644 --- a/app/javascript/dashboard/components/widgets/WootWriter/ReplyBottomPanel.vue +++ b/app/javascript/dashboard/components/widgets/WootWriter/ReplyBottomPanel.vue @@ -31,6 +31,17 @@
+
+ + +
@@ -115,7 +117,13 @@ export default { }; }, computed: { - ...mapGetters({ currentChat: 'getSelectedChat' }), + ...mapGetters({ + currentChat: 'getSelectedChat', + uiSettings: 'getUISettings', + }), + enterToSendEnabled() { + return !!this.uiSettings.enter_to_send_enabled; + }, isPrivate() { if (this.currentChat.can_reply) { return this.replyType === REPLY_EDITOR_MODES.NOTE; @@ -209,6 +217,12 @@ export default { watch: { currentChat(conversation) { const { can_reply: canReply } = conversation; + const isUserReplyingOnPrivate = + this.replyType === REPLY_EDITOR_MODES.NOTE; + if (isUserReplyingOnPrivate) { + return; + } + if (canReply) { this.replyType = REPLY_EDITOR_MODES.REPLY; } else { @@ -216,9 +230,6 @@ export default { } }, message(updatedMessage) { - if (this.isPrivate) { - return; - } const isSlashCommand = updatedMessage[0] === '/'; const hasNextWord = updatedMessage.includes(' '); const isShortCodeActive = isSlashCommand && !hasNextWord; @@ -247,14 +258,24 @@ export default { this.hideEmojiPicker(); this.hideCannedResponse(); } else if (isEnter(e)) { + const hasSendOnEnterEnabled = + (this.isFormatMode && this.enterToSendEnabled) || !this.isFormatMode; const shouldSendMessage = - !this.isFormatMode && !hasPressedShift(e) && this.isFocused; + hasSendOnEnterEnabled && !hasPressedShift(e) && this.isFocused; if (shouldSendMessage) { e.preventDefault(); this.sendMessage(); } } }, + toggleEnterToSend(enterToSendEnabled) { + this.$store.dispatch('updateUISettings', { + uiSettings: { + ...this.uiSettings, + enter_to_send_enabled: enterToSendEnabled, + }, + }); + }, async sendMessage() { if (this.isReplyButtonDisabled) { return; diff --git a/app/javascript/dashboard/i18n/locale/en/conversation.json b/app/javascript/dashboard/i18n/locale/en/conversation.json index 19bc5235b..2ca98e96a 100644 --- a/app/javascript/dashboard/i18n/locale/en/conversation.json +++ b/app/javascript/dashboard/i18n/locale/en/conversation.json @@ -44,7 +44,8 @@ "TWEET": "Tweet", "TIP_FORMAT_ICON": "Show rich text editor", "TIP_EMOJI_ICON": "Show emoji selector", - "TIP_ATTACH_ICON": "Attach files" + "TIP_ATTACH_ICON": "Attach files", + "ENTER_TO_SEND": "Enter to send" }, "VISIBLE_TO_AGENTS": "Private Note: Only visible to you and your team", "CHANGE_STATUS": "Conversation status changed",