FIX: Change bookmarks-with-reminders URL back to bookmarks for user activity (#9566)

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.
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-with-reminders.js
deleted file mode 100644
index a24269d..0000000
--- a/app/assets/javascripts/discourse/app/controllers/user-activity-bookmarks-with-reminders.js
+++ /dev/null
@@ -1,106 +0,0 @@
-import Controller from "@ember/controller";
-import showModal from "discourse/lib/show-modal";
-import { Promise } from "rsvp";
-import { inject } from "@ember/controller";
-import { action } from "@ember/object";
-import discourseComputed from "discourse-common/utils/decorators";
-import Bookmark from "discourse/models/bookmark";
-
-export default Controller.extend({
-  application: inject(),
-  user: inject(),
-
-  content: null,
-  loading: false,
-  noResultsHelp: null,
-
-  loadItems() {
-    this.setProperties({
-      content: [],
-      loading: true,
-      noResultsHelp: null
-    });
-
-    return this.model
-      .loadItems()
-      .then(response => this._processLoadResponse(response))
-      .catch(() => this._bookmarksListDenied())
-      .finally(() =>
-        this.setProperties({
-          loaded: true,
-          loading: false
-        })
-      );
-  },
-
-  @discourseComputed("loaded", "content.length", "noResultsHelp")
-  noContent(loaded, contentLength, noResultsHelp) {
-    return loaded && contentLength === 0 && noResultsHelp;
-  },
-
-  @action
-  removeBookmark(bookmark) {
-    bootbox.confirm(I18n.t("bookmarks.confirm_delete"), result => {
-      if (result) {
-        return bookmark.destroy().then(() => this.loadItems());
-      }
-    });
-  },
-
-  @action
-  editBookmark(bookmark) {
-    let controller = showModal("bookmark", {
-      model: {
-        postId: bookmark.post_id,
-        id: bookmark.id,
-        reminderAt: bookmark.reminder_at,
-        name: bookmark.name
-      },
-      title: "post.bookmarks.edit",
-      modalClass: "bookmark-with-reminder"
-    });
-    controller.setProperties({
-      afterSave: () => this.loadItems()
-    });
-  },
-
-  @action
-  loadMore() {
-    if (this.loadingMore) {
-      return Promise.resolve();
-    }
-
-    this.set("loadingMore", true);
-
-    return this.model
-      .loadMore()
-      .then(response => this._processLoadResponse(response))
-      .catch(() => this._bookmarksListDenied())
-      .finally(() => this.set("loadingMore", false));
-  },
-
-  _bookmarksListDenied() {
-    this.set("noResultsHelp", I18n.t("bookmarks.list_permission_denied"));
-  },
-
-  _processLoadResponse(response) {
-    if (!response) {
-      this._bookmarksListDenied();
-      return;
-    }
-
-    if (response.no_results_help) {
-      this.set("noResultsHelp", response.no_results_help);
-      return;
-    }
-
-    response = response.user_bookmark_list;
-    this.model.more_bookmarks_url = response.more_bookmarks_url;
-
-    if (response.bookmarks) {
-      this.content.pushObjects(
-        response.bookmarks.map(bookmark => Bookmark.create(bookmark))
-      );
-    }
-  }
-});
diff --git a/app/assets/javascripts/discourse/app/controllers/user-activity-bookmarks.js b/app/assets/javascripts/discourse/app/controllers/user-activity-bookmarks.js
new file mode 100644
index 0000000..a24269d
--- /dev/null
+++ b/app/assets/javascripts/discourse/app/controllers/user-activity-bookmarks.js
@@ -0,0 +1,106 @@
+import Controller from "@ember/controller";
+import showModal from "discourse/lib/show-modal";
+import { Promise } from "rsvp";
+import { inject } from "@ember/controller";
+import { action } from "@ember/object";
+import discourseComputed from "discourse-common/utils/decorators";
+import Bookmark from "discourse/models/bookmark";
+
+export default Controller.extend({
+  application: inject(),
+  user: inject(),
+
+  content: null,
+  loading: false,
+  noResultsHelp: null,
+
+  loadItems() {
+    this.setProperties({
+      content: [],
+      loading: true,
+      noResultsHelp: null
+    });
+
+    return this.model
+      .loadItems()
+      .then(response => this._processLoadResponse(response))
+      .catch(() => this._bookmarksListDenied())
+      .finally(() =>
+        this.setProperties({
+          loaded: true,
+          loading: false
+        })
+      );
+  },
+
+  @discourseComputed("loaded", "content.length", "noResultsHelp")
+  noContent(loaded, contentLength, noResultsHelp) {
+    return loaded && contentLength === 0 && noResultsHelp;
+  },
+
+  @action
+  removeBookmark(bookmark) {
+    bootbox.confirm(I18n.t("bookmarks.confirm_delete"), result => {
+      if (result) {
+        return bookmark.destroy().then(() => this.loadItems());
+      }
+    });
+  },
+
+  @action
+  editBookmark(bookmark) {
+    let controller = showModal("bookmark", {
+      model: {
+        postId: bookmark.post_id,
+        id: bookmark.id,
+        reminderAt: bookmark.reminder_at,
+        name: bookmark.name
+      },
+      title: "post.bookmarks.edit",
+      modalClass: "bookmark-with-reminder"
+    });
+    controller.setProperties({
+      afterSave: () => this.loadItems()
+    });
+  },
+
+  @action
+  loadMore() {
+    if (this.loadingMore) {
+      return Promise.resolve();
+    }
+
+    this.set("loadingMore", true);
+
+    return this.model
+      .loadMore()
+      .then(response => this._processLoadResponse(response))
+      .catch(() => this._bookmarksListDenied())
+      .finally(() => this.set("loadingMore", false));
+  },
+
+  _bookmarksListDenied() {
+    this.set("noResultsHelp", I18n.t("bookmarks.list_permission_denied"));
+  },
+
+  _processLoadResponse(response) {
+    if (!response) {
+      this._bookmarksListDenied();
+      return;
+    }
+
+    if (response.no_results_help) {
+      this.set("noResultsHelp", response.no_results_help);
+      return;
+    }
+
+    response = response.user_bookmark_list;
+    this.model.more_bookmarks_url = response.more_bookmarks_url;
+
+    if (response.bookmarks) {
+      this.content.pushObjects(
+        response.bookmarks.map(bookmark => Bookmark.create(bookmark))
+      );
+    }
+  }
+});
diff --git a/app/assets/javascripts/discourse/app/routes/discovery.js b/app/assets/javascripts/discourse/app/routes/discovery.js
index f7bd4a5..e4cff5e 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 fc8bd07..7c5cf81 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 too long, it was truncated ...]

GitHub sha: 6cf31f16

This commit appears in #9566 which was merged by martin.