FEATURE: Redesigned bookmark modal and menu (#23071)

Adds the new quick menu for bookmarking. When you bookmark
a post (chat message behaviour will come later) we show this new quick
menu and bookmark the item straight away.

You can then choose a reminder quick option, or choose Custom... to open
the old modal. If you click on an existing bookmark, we show the same quick menu
but with Edit and Delete options.

A later PR will introduce a new bookmark modal, but for now we
are using the old modal for Edit and Custom... options.
This commit is contained in:
Martin Brennan
2024-04-05 09:25:30 +10:00
committed by GitHub
parent 63594fa643
commit 67a8080e33
31 changed files with 825 additions and 135 deletions

View File

@ -5,7 +5,7 @@ import { service } from "@ember/service";
import BookmarkModal from "discourse/components/modal/bookmark";
import FlagModal from "discourse/components/modal/flag";
import { popupAjaxError } from "discourse/lib/ajax-error";
import { BookmarkFormData } from "discourse/lib/bookmark";
import { BookmarkFormData } from "discourse/lib/bookmark-form-data";
import { clipboardCopy } from "discourse/lib/utilities";
import Bookmark from "discourse/models/bookmark";
import getURL from "discourse-common/lib/get-url";
@ -337,12 +337,12 @@ export default class ChatMessageInteractor {
this.message.id
)
),
afterSave: (savedData) => {
const bookmark = Bookmark.create(savedData);
afterSave: (bookmarkFormData) => {
const bookmark = Bookmark.create(bookmarkFormData.saveData);
this.message.bookmark = bookmark;
this.appEvents.trigger(
"bookmarks:changed",
savedData,
bookmarkFormData.saveData,
bookmark.attachedTo()
);
},

View File

@ -6,6 +6,7 @@ describe "Local dates", type: :system do
let(:year) { Time.zone.now.year + 1 }
let(:month) { Time.zone.now.month }
let(:bookmark_modal) { PageObjects::Modals::Bookmark.new }
let(:bookmark_menu) { PageObjects::Components::BookmarkMenu.new }
let(:composer) { PageObjects::Components::Composer.new }
let(:insert_datetime_modal) { PageObjects::Modals::InsertDateTime.new }
@ -163,6 +164,7 @@ describe "Local dates", type: :system do
topic_page.visit_topic(topic)
topic_page.expand_post_actions(topic.first_post)
topic_page.click_post_action_button(topic.first_post, :bookmark)
bookmark_menu.click_menu_option("custom")
bookmark_modal.select_preset_reminder(:post_local_date)
expect(topic_page).to have_post_bookmarked(topic.first_post)
bookmark = Bookmark.find_by(bookmarkable: topic.first_post, user: current_user)
@ -177,6 +179,7 @@ describe "Local dates", type: :system do
topic_page.visit_topic(topic)
topic_page.expand_post_actions(topic.first_post)
topic_page.click_post_action_button(topic.first_post, :bookmark)
bookmark_menu.click_menu_option("custom")
expect(bookmark_modal).to be_open
expect(bookmark_modal).to have_no_preset(:post_local_date)
end