Don't show preview link for budgets with results

We currently don't have any links in the public area pointing to past
budgets, so having links in the admin section to both the budget and its
results seemed a bit redundant. We're going to add more links to the
budget actions soon, so we need to make room for them; otherwise we'll
have too many.

We're also changing the "Preview" text for a published budget. Since the
budget is already public, we aren't previewing it anymore but simply
viewing it.

And, to be consistent with the "See results" link, we're opening the
"Preview" link in the current tab. Opening links in a new tab is
generally a bad idea because takes control away from users, breaks the
back button and makes navigation particularly hard on mobile browsers.
It could be argued that in this case it's useful when users are editing
the budget in one tab and previewing it in another one, so we might add
this behavior back as long as we make it clear that the link opens in a
new tab [1].

[1] https://www.nngroup.com/articles/new-browser-windows-and-tabs/
This commit is contained in:
Javi Martín
2021-08-30 18:12:50 +02:00
parent 7d818e24ca
commit 0cc3f04096
4 changed files with 38 additions and 9 deletions

View File

@@ -115,13 +115,12 @@ describe "Admin budgets", :admin do
scenario "Can preview budget before it is published" do
visit admin_budget_path(budget)
click_link "Preview"
within_window(window_opened_by { click_link "Preview" }) do
expect(page).to have_current_path budget_path(budget)
end
expect(page).to have_current_path budget_path(budget)
end
scenario "Can preview a budget after it is published" do
scenario "Can view a budget after it is published" do
visit admin_budget_path(budget)
accept_confirm { click_button "Publish budget" }
@@ -130,9 +129,9 @@ describe "Admin budgets", :admin do
expect(page).not_to have_content "This participatory budget is in draft mode"
expect(page).not_to have_button "Publish budget"
within_window(window_opened_by { click_link "Preview" }) do
expect(page).to have_current_path budget_path(budget)
end
click_link "View"
expect(page).to have_current_path budget_path(budget)
end
end