-
Notifications
You must be signed in to change notification settings - Fork 653
AO3-7214 AO3-7215 Bookmark Javascript Improvement #5499
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
ReverM
wants to merge
12
commits into
otwcode:master
Choose a base branch
from
ReverM:AO3-7215
base: master
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
Show all changes
12 commits
Select commit
Hold shift + click to select a range
69ca95a
First batch of change
ReverM 3af400b
Merge branch 'otwcode:master' into AO3-7215
ReverM 3f055af
Added test and translation
ReverM df354d9
Added tests
ReverM 9146e6d
Adressed style issues
ReverM 3678690
Fixed translation
ReverM 3affd95
Remove leftover test
ReverM dc7d11b
These spaces thought we wouldn't see them
ReverM d2dfbd3
Normalizing
ReverM 9c90fe5
Changed an id to class
ReverM b4bbe6e
fixed linter issue
ReverM 7a33cf6
Normalized
ReverM 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,12 @@ | ||
| <% # expects "bookmark" %> | ||
| <% bookmark_form_id = (bookmark.bookmarkable.blank? ? "#{bookmark.id}" : "#{bookmark.bookmarkable.id}") %> | ||
| <ul class="actions" role="menu"> | ||
| <li><%= link_to ts("Edit"), edit_bookmark_path(bookmark), id: "bookmark_form_trigger_for_#{bookmark_form_id}", remote: true %></li> | ||
| <li><%= link_to ts("Delete"), confirm_delete_bookmark_path(bookmark), data: {confirm: ts('Are you sure you want to delete this bookmark?')} %></li> | ||
| <li><%= link_to t(".edit"), edit_bookmark_path(bookmark), class: "bookmark_form_trigger_for_#{bookmark_form_id}", remote: true %></li> | ||
| <li><%= link_to t(".delete"), confirm_delete_bookmark_path(bookmark), data: { confirm: t(".delete_confirmation") } %></li> | ||
| <li id="add_collection_link"><%= collection_link(bookmark) %></li> | ||
| <% if bookmark.bookmarkable.is_a?(Work) && !bookmark.bookmarkable.unrevealed? %> | ||
| <li class="share hidden"> | ||
| <%= link_to_modal ts("Share"), for: share_bookmark_path(bookmark), title: ts("Share Bookmark") %> | ||
| <%= link_to_modal t(".share"), for: share_bookmark_path(bookmark), title: t(".share_bookmark") %> | ||
| </li> | ||
| <% end %> | ||
| </ul> |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| @bookmarks | ||
| Feature: Edit bookmarks with javascript enabled | ||
| In order to have a good user experience | ||
| As a humble user | ||
| I want to be able to edit bookmarks with javascript enabled | ||
|
|
||
| Background: | ||
| Given a canonical fandom "The Bookmarks" | ||
| And the work "Bookmark: The Beginnings" by "bookmarker" with fandom "The Bookmarks" | ||
| And the work "Bookmark: The Sequel" by "bookmarker" with fandom "The Bookmarks" | ||
| And all indexing jobs have been run | ||
| And the dashboard counts have expired | ||
| And I am logged in as "bookmarker" | ||
|
|
||
| @javascript | ||
| Scenario: Opening multiple edit forms lets you close all of them (AO3-7214) | ||
| Given I am logged in as "recengine" | ||
| And I bookmark the work "Bookmark: The Beginnings" | ||
| And I bookmark the work "Bookmark: The Sequel" | ||
| And all indexing jobs have been run | ||
| When I follow "Bookmarks" | ||
| And I follow "Edit" | ||
| And I follow "Edit" | ||
| Then I should not see "Edit" | ||
| When I exit the bookmark edit form | ||
| And I exit the bookmark edit form | ||
| Then I should not see "save a bookmark!" | ||
|
|
||
| @javascript | ||
| Scenario: The edit form can be reopened after closing it with "X" on some pages (AO3-7215) | ||
| Given I am logged in as "recengine" | ||
| And I bookmark the work "Bookmark: The Beginnings" | ||
| When I view the work "Bookmark: The Beginnings" | ||
| And I follow "1" | ||
| And I follow "Edit" | ||
| Then I should see "save a bookmark!" | ||
| And I should not see "Edit Bookmark" | ||
| When I exit the bookmark edit form | ||
| Then I should see "Edit Bookmark" | ||
| When I follow "Edit" | ||
| Then I should see "save a bookmark!" |
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.
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.
I was a little confused by this line. It didn't seem necessary at first, but when I removed it, I noticed that it seems to fix an issue introduced by the other changes in this file.
Here's what I noticed:
Currently, if I go to a bookmarks index, press "Save" on something I don't have bookmarked, enter some text in the form, and then use the "x" to close the form without saving, the form opens with my text entered the next time I press "Save."
It seems like that behavior breaks when this line is removed: the second time I press "Save," the form gets reloaded and my text is lost.
Is that indeed what this line is fixing? If so, do you know why that bug happens, and if there is any other way we could avoid it? Removing the original
hrefmeans it's no longer possible to right-click "Save" and open the form in a new window, which is somewhat unfortunate. We can live with it if we have to, but it would be a good idea to have a code comment explaining why this line is needed.Uh oh!
There was an error while loading. Please reload this page.
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.
Which line in particular are you referring to?
As for the href, the reason why it's removed is the route of the bookmark is rendering the form as part of the controller (see line 176 of the bookmark controller). However, hiding with the x goes through the dynamic.js.erb file (above). If we don't do that, 7215 is reintroduced (since it will go through the controller to find the route of the link instead of the javascript watcher).
An alternate solution would be to delete the form instead of hiding it. That way, rendering would always work since the form would not be there already. Is the behavior you mentioned not already occurring if you close and open a bookmark on the works page having written stuff already?
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 line removing the href, sorry! GitHub told me the comment was only on line 12 before I submitted the review, but it appears to have lied.
For me, 7215 remained fixed without this line. The only difference in behavior was the information I had entered in the form was lost upon re-opening it (which would be consistent with opening a new form instead of un-hiding the original). But based on your explanation, I suspect if I had re-opened the form twice instead of just once, I would've run into 7215.
That would mean losing any information you had entered in the form before closing it, so we don't want to do that. While we could store that information somewhere and retrieve it when you re-open the form, it's probably not worth the extra code. If we get complaints about the removal of the right-click functionality, we can reconsider.
The form currently (i.e., on production) keeps what I've written.
Uh oh!
There was an error while loading. Please reload this page.
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.
I believe if you go on the works index, open a bookmark form and close it again you can't open it with a right click anymore.
I've tried changing some stuff to make the right click work, but I'm unsure how to approach it.