Repository navigation
Carry the message menu once per room instead of in every message #357
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
namespaceMarcello
wants to merge
2
commits into
basecamp:main
Choose a base branch
from
namespaceMarcello:build-message-menus-from-one-template
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,62 +1,16 @@ | ||
| <%# Be sure to check/update messages/_template.html.erb when changing this file %> | ||
|
|
||
| <%= cache_message_actions(message) do %> | ||
| <div class="message__actions" data-controller="soft-keyboard"> | ||
| <%= tag.details class: "position-relative", | ||
| data: { controller: "popup", action: "keydown.esc->popup#close toggle->popup#toggle click@document->popup#closeOnClickOutside", popup_orientation_top_class: "popup-orientation-top" } do %> | ||
| data: { controller: "popup", action: "keydown.esc->popup#close toggle->messages#addActionsMenu toggle->popup#toggle click@document->popup#closeOnClickOutside", popup_orientation_top_class: "popup-orientation-top" } do %> | ||
| <summary class="btn message__action-btn message__options-btn"> | ||
| <%= image_tag "menu-dots-horizontal.svg", size: 20, class: "colorize--black", aria: { hidden: "true" } %> | ||
| <span class="for-screen-reader">Message options</span> | ||
| </summary> | ||
|
|
||
| <div class="message__actions-menu border shadow" data-popup-target="menu"> | ||
| <div class="quick-boosts"> | ||
| <% boost_path = message_boosts_path(message) %> | ||
| <% boost_frame = dom_id(message, :boosting) %> | ||
| <% EmojiHelper::REACTIONS.each do |character, title| %> | ||
| <form data-turbo-frame="<%= boost_frame %>" data-action="popup#close" action="<%= boost_path %>" accept-charset="UTF-8" method="post"> | ||
| <%= hidden_field_tag "boost[content]", character %> | ||
| <button name="button" type="submit" title="<%= title %>" class="btn message__action-btn" data-emoji="<%= character %>"> | ||
| <figure class="margin-none boost-character"><%= character %></figure> | ||
| <span class="for-screen-reader"><%= title %></span> | ||
| </button> | ||
| </form> | ||
| <% end %> | ||
|
|
||
| <%= link_to new_message_boost_path(message), | ||
| class: "btn message__action-btn message__boost-btn", | ||
| data: { turbo_frame: dom_id(message, :new_boost), action: "soft-keyboard#open popup#close" } do %> | ||
| <%= image_tag "boost.svg", class: "colorize--black", size: 20, aria: { hidden: "true" } %> | ||
| <span class="for-screen-reader">New boost</span> | ||
| <% end %> | ||
| </div> | ||
|
|
||
| <div class="flex flex-wrap border-top margin-block-start-half pad-block-start-half message__actions-grid"> | ||
| <% if message.attachment? %> | ||
| <%= link_to rails_blob_path(message.attachment, disposition: "attachment", only_path: true), class: "btn message__action-btn center full-width hide-in-ios-pwa", title: "Download", aria: { label: "Download" } do %> | ||
| <%= image_tag "download.svg", class: "colorize--black", size: 20, aria: { hidden: "true" } %> | ||
| <% end %> | ||
|
|
||
| <%= tag.button class: "btn message__action-btn center full-width", | ||
| data: { controller: "web-share", action: "web-share#share", web_share_files_value: rails_blob_path(message.attachment, only_path: true), web_share_title_value: message.attachment.filename.to_s }, title: "Share", aria: { label: "Share" } do %> | ||
| <%= image_tag "share.svg", class: "colorize--black", size: 20, aria: { hidden: "true" } %> | ||
| <% end %> | ||
| <% else %> | ||
| <%= tag.button class: "btn message__action-btn center full-width", data: { action: "reply#reply" }, title: "Reply", aria: { label: "Reply" } do %> | ||
| <%= image_tag "reply.svg", class: "colorize--black", size: 20, aria: { hidden: "true" } %> | ||
| <% end %> | ||
| <% end %> | ||
|
|
||
| <%= tag.button class: "btn message__action-btn center full-width", title: "Copy link", aria: { label: "Copy link" }, data: { controller: "copy-to-clipboard", action: "copy-to-clipboard#copy", copy_to_clipboard_success_class: "btn--success", copy_to_clipboard_content_value: url } do %> | ||
| <%= image_tag "link.svg", class: "colorize--black", size: 20, aria: { hidden: "true" } %> | ||
| <% end %> | ||
|
|
||
| <%= link_to edit_room_message_path(message.room, message), class: "btn message__action-btn center full-width message__edit-btn", | ||
| data: { turbo_frame: dom_id(message, :edit) }, title: "Edit", aria: { label: "Edit"} do %> | ||
| <%= image_tag "pencil.svg", class: "colorize--black", size: 20, aria: { hidden: "true" } %> | ||
| <% end %> | ||
| </div> | ||
| </div> | ||
| <%# The menu is the same for every message but for the message's id, so a message travels without it and the room adds it when the menu is first opened. Only a message with a file brings its own, which points at the file. %> | ||
| <% if message.attachment? %> | ||
| <%= render "messages/actions_menu", message_id: message.id, room: message.room, attachment: message.attachment %> | ||
| <% end %> | ||
| <% end %> | ||
| </div> | ||
| <% end %> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| <%# The menu behind a message's options button. Rendered for a message with a file, and once per room in messages/_actions_menu_template.html.erb for all the others, where $messageId$ stands in for message_id. %> | ||
|
|
||
| <div class="message__actions-menu border shadow" data-popup-target="menu"> | ||
| <div class="quick-boosts"> | ||
| <% boost_path = message_boosts_path(message_id) %> | ||
| <% boost_frame = "boosting_message_#{message_id}" %> | ||
| <% EmojiHelper::REACTIONS.each do |character, title| %> | ||
| <form data-turbo-frame="<%= boost_frame %>" data-action="popup#close" action="<%= boost_path %>" accept-charset="UTF-8" method="post"> | ||
| <%= hidden_field_tag "boost[content]", character %> | ||
| <button name="button" type="submit" title="<%= title %>" class="btn message__action-btn" data-emoji="<%= character %>"> | ||
| <figure class="margin-none boost-character"><%= character %></figure> | ||
| <span class="for-screen-reader"><%= title %></span> | ||
| </button> | ||
| </form> | ||
| <% end %> | ||
|
|
||
| <%= link_to new_message_boost_path(message_id), | ||
| class: "btn message__action-btn message__boost-btn", | ||
| data: { turbo_frame: "new_boost_message_#{message_id}", action: "soft-keyboard#open popup#close" } do %> | ||
| <%= image_tag "boost.svg", class: "colorize--black", size: 20, aria: { hidden: "true" } %> | ||
| <span class="for-screen-reader">New boost</span> | ||
| <% end %> | ||
| </div> | ||
|
|
||
| <div class="flex flex-wrap border-top margin-block-start-half pad-block-start-half message__actions-grid"> | ||
| <% if attachment %> | ||
| <%= link_to rails_blob_path(attachment, disposition: "attachment", only_path: true), class: "btn message__action-btn center full-width hide-in-ios-pwa", title: "Download", aria: { label: "Download" } do %> | ||
| <%= image_tag "download.svg", class: "colorize--black", size: 20, aria: { hidden: "true" } %> | ||
| <% end %> | ||
|
|
||
| <%= tag.button class: "btn message__action-btn center full-width", | ||
| data: { controller: "web-share", action: "web-share#share", web_share_files_value: rails_blob_path(attachment, only_path: true), web_share_title_value: attachment.filename.to_s }, title: "Share", aria: { label: "Share" } do %> | ||
| <%= image_tag "share.svg", class: "colorize--black", size: 20, aria: { hidden: "true" } %> | ||
| <% end %> | ||
| <% else %> | ||
| <%= tag.button class: "btn message__action-btn center full-width", data: { action: "reply#reply" }, title: "Reply", aria: { label: "Reply" } do %> | ||
| <%= image_tag "reply.svg", class: "colorize--black", size: 20, aria: { hidden: "true" } %> | ||
| <% end %> | ||
| <% end %> | ||
|
|
||
| <%= tag.button class: "btn message__action-btn center full-width", title: "Copy link", aria: { label: "Copy link" }, data: { controller: "copy-to-clipboard", action: "copy-to-clipboard#copy", copy_to_clipboard_success_class: "btn--success", copy_to_clipboard_content_value: room_at_message_url(room, message_id) } do %> | ||
| <%= image_tag "link.svg", class: "colorize--black", size: 20, aria: { hidden: "true" } %> | ||
| <% end %> | ||
|
|
||
| <%= link_to edit_room_message_path(room, message_id), class: "btn message__action-btn center full-width message__edit-btn", | ||
| data: { turbo_frame: "edit_message_#{message_id}" }, title: "Edit", aria: { label: "Edit"} do %> | ||
| <%= image_tag "pencil.svg", class: "colorize--black", size: 20, aria: { hidden: "true" } %> | ||
| <% end %> | ||
| </div> | ||
| </div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| <%# The one menu the room's messages share. The messages controller copies it into a message, with the message's id for $messageId$, when the message's menu is first opened. %> | ||
| <script type="text/template" data-messages-target="actionsMenuTemplate"> | ||
| <%= render "messages/actions_menu", message_id: "$messageId$", room: room, attachment: nil %> | ||
| </script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The menu does depend on the room page's controller and template, and those two views have neither. Neither of them puts the button within reach, though, on
mainor here:.searches .message__actions { display: none !important; visibility: hidden !important; }insidebar.css.messages/showis the source of a message's edit frame: the redirect after an update and the editor's close link both load it inside the frame. Opened on its own, the message staysvisibility: hidden, because a message only becomes visible once the messages or the search results controller formats it (.message--formatted), and that page has neither.So no click gets to an empty
<details>there. 10795f5 adds a system test that holds both pages to it: the message is there and its options button can't be reached. It fails if the search rule is removed, or if a message is made visible without being formatted, which is when those pages would need the template too.Written by Claude Code (AI assistant) on behalf of @namespaceMarcello, who directs this work.