A platform for community discussion. Free, open, simple.
UX: Bookmark removal tweaks (#9635)
Martin Brennan6aa901450972
diff --git a/app/assets/javascripts/discourse/app/controllers/user-activity-bookmarks.js b/app/assets/javascripts/discourse/app/controllers/user-activity-bookmarks.jsindex a24269d235b..0f44eeea8c4 100644--- a/app/assets/javascripts/discourse/app/controllers/user-activity-bookmarks.js+++ b/app/assets/javascripts/discourse/app/controllers/user-activity-bookmarks.js@@ -38,11 +38,23 @@ export default Controller.extend({return loaded && contentLength === 0 && noResultsHelp;},+ _removeBookmarkFromList(bookmark) {+ this.content.removeObject(bookmark);+ },+@actionremoveBookmark(bookmark) {+ const deleteBookmark = () => {+ return bookmark+ .destroy()+ .then(() => this._removeBookmarkFromList(bookmark));+ };+ if (!bookmark.reminder_at) {+ return deleteBookmark();+ }bootbox.confirm(I18n.t("bookmarks.confirm_delete"), result => {if (result) {- return bookmark.destroy().then(() => this.loadItems());+ return deleteBookmark();}});},diff --git a/test/javascripts/acceptance/user-bookmarks-test.js b/test/javascripts/acceptance/user-bookmarks-test.jsindex 3a276810c8f..51dead8606d 100644--- a/test/javascripts/acceptance/user-bookmarks-test.js+++ b/test/javascripts/acceptance/user-bookmarks-test.js@@ -1,6 +1,7 @@import { acceptance } from "helpers/qunit-helpers";import selectKit from "helpers/select-kit-helper";import pretender from "helpers/create-pretender";+import userFixtures from "fixtures/user_fixtures";acceptance("User's bookmarks", {loggedIn: true,@@ -20,16 +21,25 @@ test("listing user bookmarks", async assert => {assert.ok(find(".bookmark-list-item").length);});-test("removing a bookmark", async assert => {+test("removing a bookmark with a reminder shows a confirmation", async assert => {+ let listResponse = _.clone(userFixtures["/u/eviltrout/bookmarks.json"]);+ listResponse.user_bookmark_list.bookmarks[0].reminder_at = "2028-01-01T08:00";+ pretender.get("/u/eviltrout/bookmarks.json", () => [+ 200,+ { "Content-Type": "application/json" },+ listResponse+ ]);await visit("/u/eviltrout/activity/bookmarks");const dropdown = selectKit(".bookmark-actions-dropdown");await dropdown.expand();await dropdown.selectRowByValue("remove");- assert.ok(exists(".bootbox.modal"));+ assert.ok(exists(".bootbox.modal"), "it asks for delete confirmation");- await click(".bootbox.modal .btn-primary");+ await click(".bootbox.modal a.btn-primary");+ assert.not(exists(".bootbox.modal"));+ listResponse.user_bookmark_list.bookmarks[0].reminder_at = null;});test("listing users bookmarks - no bookmarks", async assert => {@@ -48,3 +58,13 @@ test("listing users bookmarks - no bookmarks", async assert => {assert.equal(find(".alert.alert-info").text(), "no bookmarks");});++test("removing a bookmark with no reminder does not show a confirmation", async assert => {+ await visit("/u/eviltrout/activity/bookmarks");++ const dropdown = selectKit(".bookmark-actions-dropdown");+ await dropdown.expand();+ await dropdown.selectRowByValue("remove");++ assert.not(exists(".bootbox.modal"), "it should not show the modal");+});