Fix condition to show the "see results" link
This condition was obsolete since we introduced the `results_enabled`
field in commit 4f4dc2c2a.
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
<div class="budgets-links">
|
||||
<% if budget.has_winning_investments? %>
|
||||
<%= action(:results,
|
||||
text: t("budgets.show.see_results"),
|
||||
path: budget_results_path(budget)) %>
|
||||
<% if can?(:read_results, budget) %>
|
||||
<%= action(:results, text: results_text, path: budget_results_path(budget)) %>
|
||||
<% end %>
|
||||
|
||||
<%= action(:preview, text: t("admin.budgets.actions.preview"), path: budget_path(budget), target: "_blank") %>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
class Admin::Budgets::LinksComponent < ApplicationComponent
|
||||
attr_reader :budget
|
||||
delegate :can?, to: :helpers
|
||||
|
||||
def initialize(budget)
|
||||
@budget = budget
|
||||
@@ -10,4 +11,12 @@ class Admin::Budgets::LinksComponent < ApplicationComponent
|
||||
def action(action_name, **options)
|
||||
render Admin::ActionComponent.new(action_name, budget, **options)
|
||||
end
|
||||
|
||||
def results_text
|
||||
if Abilities::Everyone.new(User.new).can?(:read_results, budget)
|
||||
t("budgets.show.see_results")
|
||||
else
|
||||
t("admin.budgets.actions.preview_results")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user