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

@@ -44,6 +44,8 @@ describe Admin::Budgets::LinksComponent, controller: Admin::BaseController do
expect(page).to have_link "Preview results"
expect(page).not_to have_link "See results"
expect(page).not_to have_link "View"
expect(page).not_to have_link "Preview"
end
it "is not shown while balloting" do
@@ -56,4 +58,24 @@ describe Admin::Budgets::LinksComponent, controller: Admin::BaseController do
end
end
end
describe "preview/view link" do
it "shows a link to preview an unpublished budget" do
budget = create(:budget, :drafting)
render_inline Admin::Budgets::LinksComponent.new(budget)
expect(page).to have_link "Preview"
expect(page).not_to have_link "View"
end
it "shows a link to view a published budget" do
budget = create(:budget, :informing)
render_inline Admin::Budgets::LinksComponent.new(budget)
expect(page).to have_link "View"
expect(page).not_to have_link "Preview"
end
end
end