From 6cf31f16f713eb42850c10b8629c45a4ffe43d10 Mon Sep 17 00:00:00 2001 From: Martin Brennan Date: Wed, 29 Apr 2020 10:53:37 +1000 Subject: [PATCH] FIX: Change bookmarks-with-reminders URL back to bookmarks for user activity (#9566) * Bookmarks with reminders is a core feature now, no need to have a separate URL * Keep around the old /u/:username/activity/bookmarks-with-reminders route for backwards compat in Ember but just redirect to user activity bookmarks. --- ...eminders.js => user-activity-bookmarks.js} | 0 .../discourse/app/routes/discovery.js | 5 +--- .../user-activity-bookmarks-with-reminders.js | 26 ++----------------- .../app/routes/user-activity-bookmarks.js | 25 ++++++++++++++---- .../discourse/app/templates/user/activity.hbs | 2 +- .../discourse/app/templates/user/summary.hbs | 2 +- .../app/widgets/quick-access-bookmarks.js | 2 +- .../discourse/app/widgets/user-menu.js | 2 +- .../new_user_narrative.rb | 2 +- .../new_user_narrative_spec.rb | 2 +- .../acceptance/user-bookmarks-test.js | 6 ++--- 11 files changed, 32 insertions(+), 42 deletions(-) rename app/assets/javascripts/discourse/app/controllers/{user-activity-bookmarks-with-reminders.js => user-activity-bookmarks.js} (100%) diff --git a/app/assets/javascripts/discourse/app/controllers/user-activity-bookmarks-with-reminders.js b/app/assets/javascripts/discourse/app/controllers/user-activity-bookmarks.js similarity index 100% rename from app/assets/javascripts/discourse/app/controllers/user-activity-bookmarks-with-reminders.js rename to app/assets/javascripts/discourse/app/controllers/user-activity-bookmarks.js diff --git a/app/assets/javascripts/discourse/app/routes/discovery.js b/app/assets/javascripts/discourse/app/routes/discovery.js index f7bd4a5a06f..e4cff5e115c 100644 --- a/app/assets/javascripts/discourse/app/routes/discovery.js +++ b/app/assets/javascripts/discourse/app/routes/discovery.js @@ -18,10 +18,7 @@ export default DiscourseRoute.extend(OpenComposer, { // and being based on a different model. better to just redirect const url = transition.intent.url; if (url === "/bookmarks") { - this.transitionTo( - "userActivity.bookmarksWithReminders", - this.currentUser - ); + this.transitionTo("userActivity.bookmarks", this.currentUser); } if ( diff --git a/app/assets/javascripts/discourse/app/routes/user-activity-bookmarks-with-reminders.js b/app/assets/javascripts/discourse/app/routes/user-activity-bookmarks-with-reminders.js index fc8bd078264..7c5cf81ec61 100644 --- a/app/assets/javascripts/discourse/app/routes/user-activity-bookmarks-with-reminders.js +++ b/app/assets/javascripts/discourse/app/routes/user-activity-bookmarks-with-reminders.js @@ -1,29 +1,7 @@ import DiscourseRoute from "discourse/routes/discourse"; export default DiscourseRoute.extend({ - noContentHelpKey: "user_activity.no_bookmarks", - - queryParams: { - acting_username: { refreshModel: true } - }, - - model() { - return this.modelFor("user").get("bookmarks"); - }, - - renderTemplate() { - this.render("user_bookmarks"); - }, - - setupController(controller, model) { - controller.set("model", model); - controller.loadItems(); - }, - - actions: { - didTransition() { - this.controllerFor("user-activity")._showFooter(); - return true; - } + redirect() { + this.transitionTo("userActivity.bookmarks"); } }); diff --git a/app/assets/javascripts/discourse/app/routes/user-activity-bookmarks.js b/app/assets/javascripts/discourse/app/routes/user-activity-bookmarks.js index 9ea0b7240eb..fc8bd078264 100644 --- a/app/assets/javascripts/discourse/app/routes/user-activity-bookmarks.js +++ b/app/assets/javascripts/discourse/app/routes/user-activity-bookmarks.js @@ -1,13 +1,28 @@ -import UserActivityStreamRoute from "discourse/routes/user-activity-stream"; -import UserAction from "discourse/models/user-action"; +import DiscourseRoute from "discourse/routes/discourse"; -export default UserActivityStreamRoute.extend({ - userActionType: UserAction.TYPES["bookmarks"], +export default DiscourseRoute.extend({ noContentHelpKey: "user_activity.no_bookmarks", + queryParams: { + acting_username: { refreshModel: true } + }, + + model() { + return this.modelFor("user").get("bookmarks"); + }, + + renderTemplate() { + this.render("user_bookmarks"); + }, + + setupController(controller, model) { + controller.set("model", model); + controller.loadItems(); + }, + actions: { didTransition() { - this.controllerFor("application").set("showFooter", true); + this.controllerFor("user-activity")._showFooter(); return true; } } diff --git a/app/assets/javascripts/discourse/app/templates/user/activity.hbs b/app/assets/javascripts/discourse/app/templates/user/activity.hbs index 15b868def22..6ccc09bd667 100644 --- a/app/assets/javascripts/discourse/app/templates/user/activity.hbs +++ b/app/assets/javascripts/discourse/app/templates/user/activity.hbs @@ -19,7 +19,7 @@ {{#if user.showBookmarks}}
  • - {{#link-to 'userActivity.bookmarksWithReminders'}}{{i18n 'user_action_groups.3'}}{{/link-to}} + {{#link-to "userActivity.bookmarks"}}{{i18n "user_action_groups.3"}}{{/link-to}}
  • {{/if}} {{plugin-outlet diff --git a/app/assets/javascripts/discourse/app/templates/user/summary.hbs b/app/assets/javascripts/discourse/app/templates/user/summary.hbs index ff9c7520f90..ddd89595c52 100644 --- a/app/assets/javascripts/discourse/app/templates/user/summary.hbs +++ b/app/assets/javascripts/discourse/app/templates/user/summary.hbs @@ -27,7 +27,7 @@ {{#if model.bookmark_count}}
  • - {{#link-to "userActivity.bookmarksWithReminders"}} + {{#link-to "userActivity.bookmarks"}} {{user-stat value=model.bookmark_count label="user.summary.bookmark_count"}} {{/link-to}}
  • diff --git a/app/assets/javascripts/discourse/app/widgets/quick-access-bookmarks.js b/app/assets/javascripts/discourse/app/widgets/quick-access-bookmarks.js index 787fce384d9..3782b3e67ce 100644 --- a/app/assets/javascripts/discourse/app/widgets/quick-access-bookmarks.js +++ b/app/assets/javascripts/discourse/app/widgets/quick-access-bookmarks.js @@ -16,7 +16,7 @@ createWidgetFrom(QuickAccessPanel, "quick-access-bookmarks", { }, showAllHref() { - return `${this.attrs.path}/activity/bookmarks-with-reminders`; + return `${this.attrs.path}/activity/bookmarks`; }, emptyStatePlaceholderItem() { diff --git a/app/assets/javascripts/discourse/app/widgets/user-menu.js b/app/assets/javascripts/discourse/app/widgets/user-menu.js index 08792c4130c..6f4b5c323c7 100644 --- a/app/assets/javascripts/discourse/app/widgets/user-menu.js +++ b/app/assets/javascripts/discourse/app/widgets/user-menu.js @@ -62,7 +62,7 @@ createWidget("user-menu-links", { label: "user.bookmarks", className: "user-bookmarks-link", icon: "bookmark", - href: `${this.attrs.path}/activity/bookmarks-with-reminders` + href: `${this.attrs.path}/activity/bookmarks` }; }, diff --git a/plugins/discourse-narrative-bot/lib/discourse_narrative_bot/new_user_narrative.rb b/plugins/discourse-narrative-bot/lib/discourse_narrative_bot/new_user_narrative.rb index 072c54beafb..5e9a1f38a54 100644 --- a/plugins/discourse-narrative-bot/lib/discourse_narrative_bot/new_user_narrative.rb +++ b/plugins/discourse-narrative-bot/lib/discourse_narrative_bot/new_user_narrative.rb @@ -238,7 +238,7 @@ module DiscourseNarrativeBot return unless @post.user_id == self.discobot_user.id profile_page_url = url_helpers(:user_url, username: @user.username) - bookmark_url = "#{profile_page_url}/activity/bookmarks-with-reminders" + bookmark_url = "#{profile_page_url}/activity/bookmarks" raw = <<~RAW #{I18n.t("#{I18N_KEY}.bookmark.reply", i18n_post_args(bookmark_url: bookmark_url))} diff --git a/plugins/discourse-narrative-bot/spec/discourse_narrative_bot/new_user_narrative_spec.rb b/plugins/discourse-narrative-bot/spec/discourse_narrative_bot/new_user_narrative_spec.rb index d875de3b100..ce65b15463b 100644 --- a/plugins/discourse-narrative-bot/spec/discourse_narrative_bot/new_user_narrative_spec.rb +++ b/plugins/discourse-narrative-bot/spec/discourse_narrative_bot/new_user_narrative_spec.rb @@ -256,7 +256,7 @@ describe DiscourseNarrativeBot::NewUserNarrative do profile_page_url = "#{Discourse.base_url}/u/#{user.username}" expected_raw = <<~RAW - #{I18n.t('discourse_narrative_bot.new_user_narrative.bookmark.reply', bookmark_url: "#{profile_page_url}/activity/bookmarks-with-reminders", base_uri: '')} + #{I18n.t('discourse_narrative_bot.new_user_narrative.bookmark.reply', bookmark_url: "#{profile_page_url}/activity/bookmarks", base_uri: '')} #{I18n.t('discourse_narrative_bot.new_user_narrative.onebox.instructions', base_uri: '')} RAW diff --git a/test/javascripts/acceptance/user-bookmarks-test.js b/test/javascripts/acceptance/user-bookmarks-test.js index e9655101296..3a276810c8f 100644 --- a/test/javascripts/acceptance/user-bookmarks-test.js +++ b/test/javascripts/acceptance/user-bookmarks-test.js @@ -15,13 +15,13 @@ acceptance("User's bookmarks", { }); test("listing user bookmarks", async assert => { - await visit("/u/eviltrout/activity/bookmarks-with-reminders"); + await visit("/u/eviltrout/activity/bookmarks"); assert.ok(find(".bookmark-list-item").length); }); test("removing a bookmark", async assert => { - await visit("/u/eviltrout/activity/bookmarks-with-reminders"); + await visit("/u/eviltrout/activity/bookmarks"); const dropdown = selectKit(".bookmark-actions-dropdown"); await dropdown.expand(); @@ -44,7 +44,7 @@ test("listing users bookmarks - no bookmarks", async assert => { } ]); - await visit("/u/eviltrout/activity/bookmarks-with-reminders"); + await visit("/u/eviltrout/activity/bookmarks"); assert.equal(find(".alert.alert-info").text(), "no bookmarks"); });