From c3ecb409d4ea2700d7855153daf3fa6918710682 Mon Sep 17 00:00:00 2001 From: Ashwani Yadav Date: Tue, 24 Dec 2019 16:51:21 +0530 Subject: [PATCH 1/2] User gets UI feedback when message is pinned or unpinned --- app/message-pin/client/pinMessage.js | 10 ++++++++++ packages/rocketchat-i18n/i18n/en.i18n.json | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/app/message-pin/client/pinMessage.js b/app/message-pin/client/pinMessage.js index 7822c2875a2d..9bd28afd575a 100644 --- a/app/message-pin/client/pinMessage.js +++ b/app/message-pin/client/pinMessage.js @@ -1,4 +1,6 @@ import { Meteor } from 'meteor/meteor'; +import toastr from 'toastr'; +import { TAPi18n } from 'meteor/rocketchat:tap-i18n'; import { settings } from '../../settings'; import { ChatMessage, Subscriptions } from '../../models'; @@ -6,14 +8,18 @@ import { ChatMessage, Subscriptions } from '../../models'; Meteor.methods({ pinMessage(message) { if (!Meteor.userId()) { + toastr.error(TAPi18n.__('error-pinning-message')); return false; } if (!settings.get('Message_AllowPinning')) { + toastr.error(TAPi18n.__('error-pinning-message')); return false; } if (Subscriptions.findOne({ rid: message.rid }) == null) { + toastr.error(TAPi18n.__('error-pinning-message')); return false; } + toastr.success(TAPi18n.__('Message_has_been_pinned')); return ChatMessage.update({ _id: message._id, }, { @@ -24,14 +30,18 @@ Meteor.methods({ }, unpinMessage(message) { if (!Meteor.userId()) { + toastr.error(TAPi18n.__('error-unpinning-message')); return false; } if (!settings.get('Message_AllowPinning')) { + toastr.error(TAPi18n.__('error-unpinning-message')); return false; } if (Subscriptions.findOne({ rid: message.rid }) == null) { + toastr.error(TAPi18n.__('error-unpinning-message')); return false; } + toastr.success(TAPi18n.__('Message_has_been_unpinned')); return ChatMessage.update({ _id: message._id, }, { diff --git a/packages/rocketchat-i18n/i18n/en.i18n.json b/packages/rocketchat-i18n/i18n/en.i18n.json index 0d90522e8fd4..b377b480b050 100644 --- a/packages/rocketchat-i18n/i18n/en.i18n.json +++ b/packages/rocketchat-i18n/i18n/en.i18n.json @@ -1336,6 +1336,8 @@ "error-password-policy-not-met-oneSpecial": "Password does not meet the server's policy of at least one special character", "error-password-policy-not-met-oneUppercase": "Password does not meet the server's policy of at least one uppercase character", "error-password-policy-not-met-repeatingCharacters": "Password not not meet the server's policy of forbidden repeating characters (you have too many of the same characters next to each other)", + "error-pinning-message": "Message could not be pinned", + "error-unpinning-message": "Message could not be unpinned", "error-push-disabled": "Push is disabled", "error-remove-last-owner": "This is the last owner. Please set a new owner before removing this one.", "error-tags-must-be-assigned-before-closing-chat": "Tag(s) must be assigned before closing the chat", @@ -2184,6 +2186,8 @@ "Message_GlobalSearch": "Global Search", "Message_GroupingPeriod": "Grouping Period (in seconds)", "Message_GroupingPeriodDescription": "Messages will be grouped with previous message if both are from the same user and the elapsed time was less than the informed time in seconds.", + "Message_has_been_pinned": "Message has been pinned", + "Message_has_been_unpinned": "Message has been unpinned", "Message_HideType_au": "Hide \"User Added\" messages", "Message_HideType_mute_unmute": "Hide \"User Muted / Unmuted\" messages", "Message_HideType_ru": "Hide \"User Removed\" messages", From 24cc1a6b733ba35c62d64002c3d26d4787f73f61 Mon Sep 17 00:00:00 2001 From: Ashwani Yadav Date: Tue, 4 Feb 2020 03:58:46 +0530 Subject: [PATCH 2/2] added error variable in i18 --- app/message-pin/client/pinMessage.js | 8 ++++---- packages/rocketchat-i18n/i18n/en.i18n.json | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/message-pin/client/pinMessage.js b/app/message-pin/client/pinMessage.js index 9bd28afd575a..9fbc2f778edc 100644 --- a/app/message-pin/client/pinMessage.js +++ b/app/message-pin/client/pinMessage.js @@ -8,11 +8,11 @@ import { ChatMessage, Subscriptions } from '../../models'; Meteor.methods({ pinMessage(message) { if (!Meteor.userId()) { - toastr.error(TAPi18n.__('error-pinning-message')); + toastr.error(TAPi18n.__('error-not-authorized')); return false; } if (!settings.get('Message_AllowPinning')) { - toastr.error(TAPi18n.__('error-pinning-message')); + toastr.error(TAPi18n.__('pinning-not-allowed')); return false; } if (Subscriptions.findOne({ rid: message.rid }) == null) { @@ -30,11 +30,11 @@ Meteor.methods({ }, unpinMessage(message) { if (!Meteor.userId()) { - toastr.error(TAPi18n.__('error-unpinning-message')); + toastr.error(TAPi18n.__('error-not-authorized')); return false; } if (!settings.get('Message_AllowPinning')) { - toastr.error(TAPi18n.__('error-unpinning-message')); + toastr.error(TAPi18n.__('unpinning-not-allowed')); return false; } if (Subscriptions.findOne({ rid: message.rid }) == null) { diff --git a/packages/rocketchat-i18n/i18n/en.i18n.json b/packages/rocketchat-i18n/i18n/en.i18n.json index b377b480b050..bab0e71f285b 100644 --- a/packages/rocketchat-i18n/i18n/en.i18n.json +++ b/packages/rocketchat-i18n/i18n/en.i18n.json @@ -2461,6 +2461,7 @@ "Pin_Message": "Pin Message", "Pinned_a_message": "Pinned a message:", "Pinned_Messages": "Pinned Messages", + "pinning-not-allowed": "Pinning is not allowed", "PiwikAdditionalTrackers": "Additional Piwik Sites", "PiwikAdditionalTrackers_Description": "Enter addtitional Piwik website URLs and SiteIDs in the following format, if you wnat to track the same data into different websites: [ { \"trackerURL\" : \"https://my.piwik.domain2/\", \"siteId\" : 42 }, { \"trackerURL\" : \"https://my.piwik.domain3/\", \"siteId\" : 15 } ]", "PiwikAnalytics_cookieDomain": "All Subdomains", @@ -3223,6 +3224,7 @@ "Unnamed": "Unnamed", "Unpin": "Unpin", "Unpin_Message": "Unpin Message", + "unpinning-not-allowed": "Unpinning is not allowed", "Unread": "Unread", "Unread_Count": "Unread Count", "Unread_Count_DM": "Unread Count for Direct Messages",