Open admin links in the same window
In the admin section, when clicking on a link that leads to a page in the public area, sometimes the page was opened in the same window and sometimes it would open in a new window, with no clear criteria regarding when either scenario would take place. This was really confusing, so now we're more consistent and open (almost) every link in the same window. The main reason behind it is simple: if we add `target: _blank`, people who want to open those links in the same window can no longer do so, so we're taking control away from them. However, if we don't add this attribute, people can choose whether to open the link on the same tab or to open it on a new one, since all browsers implement a method to do so. More reasons behind this decision can be found in "Opening Links in New Browser Windows and Tabs" [1]. We're keeping some exceptions, though: * Opening the link to edit an investment on the same tab would result in losing all the investment filters already applied when searching for investments, so until we implement a way to keep these filters, we're also opening the link to edit an investment in a new tab * For now, we're also opening links to download files in a new window; we'll deal with this case in the future [1] https://www.nngroup.com/articles/new-browser-windows-and-tabs/
This commit is contained in:
@@ -33,8 +33,7 @@
|
|||||||
<% if page.status == "published" %>
|
<% if page.status == "published" %>
|
||||||
<%= actions.action(:show,
|
<%= actions.action(:show,
|
||||||
text: t("admin.site_customization.pages.index.see_page"),
|
text: t("admin.site_customization.pages.index.see_page"),
|
||||||
path: page.url,
|
path: page.url) %>
|
||||||
target: "_blank") %>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
@@ -12,8 +12,7 @@
|
|||||||
<!-- remove conditional once specs have image validations -->
|
<!-- remove conditional once specs have image validations -->
|
||||||
<td>
|
<td>
|
||||||
<% if card.image.present? %>
|
<% if card.image.present? %>
|
||||||
<%= link_to t("admin.shared.show_image"), card.image.variant(:large),
|
<%= link_to t("admin.shared.show_image"), card.image.variant(:large), title: card.image.title %>
|
||||||
title: card.image.title, target: "_blank" %>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<%= link_to administrator_task.source.proposal.title,
|
<%= link_to administrator_task.source.proposal.title,
|
||||||
proposal_path(administrator_task.source.proposal), target: "_blank" %>
|
proposal_path(administrator_task.source.proposal) %>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<%= administrator_task.source.action.title %>
|
<%= administrator_task.source.action.title %>
|
||||||
|
|||||||
@@ -40,8 +40,7 @@
|
|||||||
</td>
|
</td>
|
||||||
<td class="small">
|
<td class="small">
|
||||||
<%= link_to t("admin.milestones.index.show_image"),
|
<%= link_to t("admin.milestones.index.show_image"),
|
||||||
milestone.image.variant(:large),
|
milestone.image.variant(:large) if milestone.image.present? %>
|
||||||
target: :_blank if milestone.image.present? %>
|
|
||||||
</td>
|
</td>
|
||||||
<td class="small">
|
<td class="small">
|
||||||
<% if milestone.documents.present? %>
|
<% if milestone.documents.present? %>
|
||||||
|
|||||||
@@ -24,8 +24,7 @@
|
|||||||
<% if question.proposal.present? %>
|
<% if question.proposal.present? %>
|
||||||
<small>
|
<small>
|
||||||
<%= link_to t("admin.polls.show.see_proposal"),
|
<%= link_to t("admin.polls.show.see_proposal"),
|
||||||
proposal_path(question.proposal),
|
proposal_path(question.proposal) %>
|
||||||
target: "_blank" %>
|
|
||||||
</small>
|
</small>
|
||||||
<% end %>
|
<% end %>
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
@@ -23,10 +23,10 @@
|
|||||||
<% @users.each do |user| %>
|
<% @users.each do |user| %>
|
||||||
<tr>
|
<tr>
|
||||||
<% if @current_filter == "erased" %>
|
<% if @current_filter == "erased" %>
|
||||||
<td><%= link_to user.id, user_path(user), target: "_blank" %></td>
|
<td><%= link_to user.id, user_path(user) %></td>
|
||||||
<td><%= user.erase_reason %></td>
|
<td><%= user.erase_reason %></td>
|
||||||
<% else %>
|
<% else %>
|
||||||
<td><%= link_to user.name, user_path(user), target: "_blank" %></td>
|
<td><%= link_to user.name, user_path(user) %></td>
|
||||||
<td><%= user.email %></td>
|
<td><%= user.email %></td>
|
||||||
<td><%= user.document_number %></td>
|
<td><%= user.document_number %></td>
|
||||||
<td><%= display_user_roles(user) %></td>
|
<td><%= display_user_roles(user) %></td>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td><%= link_to user.name, user_path(user), target: "_blank" %></td>
|
<td><%= link_to user.name, user_path(user) %></td>
|
||||||
<td><%= user.email %></td>
|
<td><%= user.email %></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
|
|||||||
@@ -18,10 +18,10 @@ describe "Admin users" do
|
|||||||
scenario "The username links to their public profile" do
|
scenario "The username links to their public profile" do
|
||||||
visit admin_users_path
|
visit admin_users_path
|
||||||
|
|
||||||
within_window(window_opened_by { click_link user.name }) do
|
click_link user.name
|
||||||
|
|
||||||
expect(page).to have_current_path(user_path(user))
|
expect(page).to have_current_path(user_path(user))
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
scenario "Show active or erased users using filters" do
|
scenario "Show active or erased users using filters" do
|
||||||
erased_user = create(:user, username: "Erased")
|
erased_user = create(:user, username: "Erased")
|
||||||
|
|||||||
Reference in New Issue
Block a user