From 2aa1482421920e79cab62d121f828c39d98b97a1 Mon Sep 17 00:00:00 2001 From: Martin Brennan Date: Fri, 21 Aug 2020 11:01:12 +1000 Subject: [PATCH] FIX: Bookmark list showing wrong no content message (#10501) Meta report: https://meta.discourse.org/t/spurious-permissions-error-after-deleting-last-bookmark/161289 When deleting all bookmarks in their list, users were seeing an "access denied" message instead of the regular no content message. This is because when we were calling loadMore and no further results were returned, we were presuming the null response from the resolved promise meant that there was a permissions error. Fixed this and moved the message into a computed property to show the correct message. --- .../app/controllers/user-activity-bookmarks.js | 18 ++++++++++++++---- .../discourse/app/templates/user/bookmarks.hbs | 2 +- config/locales/client.en.yml | 1 + 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/discourse/app/controllers/user-activity-bookmarks.js b/app/assets/javascripts/discourse/app/controllers/user-activity-bookmarks.js index c566b628906..a9b0fd7269d 100644 --- a/app/assets/javascripts/discourse/app/controllers/user-activity-bookmarks.js +++ b/app/assets/javascripts/discourse/app/controllers/user-activity-bookmarks.js @@ -41,9 +41,20 @@ export default Controller.extend({ }); }, - @discourseComputed("loaded", "content.length", "noResultsHelp") - noContent(loaded, contentLength, noResultsHelp) { - return loaded && contentLength === 0 && noResultsHelp; + @discourseComputed("loaded", "content.length") + noContent(loaded, contentLength) { + return loaded && contentLength === 0; + }, + + @discourseComputed("noResultsHelp", "noContent") + noResultsHelpMessage(noResultsHelp, noContent) { + if (noResultsHelp) { + return noResultsHelp; + } + if (noContent) { + return I18n.t("bookmarks.no_user_bookmarks"); + } + return ""; }, @action @@ -78,7 +89,6 @@ export default Controller.extend({ _processLoadResponse(response) { if (!response) { - this._bookmarksListDenied(); return; } diff --git a/app/assets/javascripts/discourse/app/templates/user/bookmarks.hbs b/app/assets/javascripts/discourse/app/templates/user/bookmarks.hbs index d9733ff8857..30dad5498e2 100644 --- a/app/assets/javascripts/discourse/app/templates/user/bookmarks.hbs +++ b/app/assets/javascripts/discourse/app/templates/user/bookmarks.hbs @@ -11,7 +11,7 @@ icon="search"}} {{#if noContent}} -
{{noResultsHelp}}
+
{{noResultsHelpMessage}}
{{else}} {{bookmark-list loadMore=(action "loadMore") diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 4ed06ab689e..e5689d6d578 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -303,6 +303,7 @@ en: no_timezone: 'You have not set a timezone yet. You will not be able to set reminders. Set one up in your profile.' invalid_custom_datetime: "The date and time you provided is invalid, please try again." list_permission_denied: "You do not have permission to view this user's bookmarks." + no_user_bookmarks: "You have no bookmarked posts; bookmarks allow you to quickly refer to specific posts." auto_delete_preference: label: "Automatically delete" never: "Never"