Skip to content

Commit

Permalink
Use the tenant URL as a link to the tenant
Browse files Browse the repository at this point in the history
In general, we don't use links inside admin tables because we don't know
where the link will point to, and use "view" actions/links instead.

However, in this case, we're showing a URL, so it's perfectly obvious
where the link will point to. And so it makes sense to use the URL as a
link instead of using a "view" action/link.
  • Loading branch information
javierm committed Dec 14, 2022
1 parent 09b9d2b commit 7bcdb6a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 15 deletions.
6 changes: 2 additions & 4 deletions app/components/admin/tenants/index_component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@
<tr id="<%= dom_id(tenant) %>">
<td><%= tenant.name %></td>
<td><%= tenant.schema %></td>
<td><%= tenant.host %></td>
<td><%= link_to tenant.host, root_url(host: tenant.host) %></td>
<td>
<%= render Admin::TableActionsComponent.new(tenant, actions: [:edit]) do |actions| %>
<%= actions.action(:show, text: t("admin.shared.view"), path: root_url(host: tenant.host)) %>
<% end %>
<%= render Admin::TableActionsComponent.new(tenant, actions: [:edit]) %>
</td>
</tr>
<% end %>
Expand Down
14 changes: 3 additions & 11 deletions spec/system/admin/tenants_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@

expect(page).to have_content "Tenant created successfully"

within("tr", text: "earth") do
expect(page).to have_content "earth.lvh.me"

click_link "View"
end
click_link "earth.lvh.me"

expect(current_host).to eq "http://earth.lvh.me"
expect(page).to have_current_path root_path
Expand All @@ -38,11 +34,7 @@
fill_in "Name", with: "Earthlings"
click_button "Create tenant"

within("tr", text: "earth") do
expect(page).to have_content "earth.lvh.me"

click_link "View"
end
click_link "earth.lvh.me"

expect(current_host).to eq "http://earth.lvh.me"
expect(page).to have_current_path root_path
Expand All @@ -65,7 +57,7 @@

expect(page).to have_content "Tenant updated successfully"

within("tr", text: "the-moon") { click_link "View" }
click_link "the-moon.lvh.me"

expect(current_host).to eq "http://the-moon.lvh.me"
expect(page).to have_current_path root_path
Expand Down

0 comments on commit 7bcdb6a

Please sign in to comment.