diff --git a/app/components/admin/budgets/calculate_winners_button_component.html.erb b/app/components/admin/budgets/calculate_winners_button_component.html.erb
new file mode 100644
index 000000000..ea7fdbf58
--- /dev/null
+++ b/app/components/admin/budgets/calculate_winners_button_component.html.erb
@@ -0,0 +1,13 @@
+<% if display_button? %>
+ <%= link_to text,
+ calculate_winners_admin_budget_path(budget),
+ method: :put,
+ class: html_class %>
+<% elsif from_investments %>
+
+ <%= t("admin.budgets.winners.calculate") %>
+
+
- <% if display_calculate_winners_button?(budget) %>
- <%= link_to calculate_winner_button_text(budget),
- calculate_winners_admin_budget_path(budget),
- method: :put,
- class: "button hollow" %>
- <% end %>
+ <%= render Admin::Budgets::CalculateWinnersButtonComponent.new(budget) %>
<% if budget.has_winning_investments? %>
<%= link_to t("budgets.show.see_results"),
diff --git a/app/components/admin/budgets/form_component.rb b/app/components/admin/budgets/form_component.rb
index 3d57663f0..d57457e7a 100644
--- a/app/components/admin/budgets/form_component.rb
+++ b/app/components/admin/budgets/form_component.rb
@@ -5,10 +5,6 @@ class Admin::Budgets::FormComponent < ApplicationComponent
attr_reader :budget, :wizard
alias_method :wizard?, :wizard
- delegate :display_calculate_winners_button?,
- :calculate_winner_button_text,
- :calculate_winners_admin_budget_path,
- to: :helpers
def initialize(budget, wizard: false)
@budget = budget
diff --git a/app/helpers/budgets_helper.rb b/app/helpers/budgets_helper.rb
index 43afd7ed2..c472a0f35 100644
--- a/app/helpers/budgets_helper.rb
+++ b/app/helpers/budgets_helper.rb
@@ -33,18 +33,6 @@ module BudgetsHelper
budget.published? || current_user&.administrator?
end
- def display_calculate_winners_button?(budget)
- budget.balloting_or_later?
- end
-
- def calculate_winner_button_text(budget)
- if budget.investments.winners.empty?
- t("admin.budgets.winners.calculate")
- else
- t("admin.budgets.winners.recalculate")
- end
- end
-
def budget_subnav_items_for(budget)
{
results: t("budgets.results.link"),
diff --git a/app/views/admin/budget_investments/_investments.html.erb b/app/views/admin/budget_investments/_investments.html.erb
index 890448513..15bbdc216 100644
--- a/app/views/admin/budget_investments/_investments.html.erb
+++ b/app/views/admin/budget_investments/_investments.html.erb
@@ -3,19 +3,7 @@
class: "float-right small clear" %>
<% if params[:advanced_filters].include?("winners") %>
- <% if display_calculate_winners_button?(@budget) %>
- <%= link_to calculate_winner_button_text(@budget),
- calculate_winners_admin_budget_path(@budget),
- method: :put,
- class: "button hollow float-right clear" %>
- <% else %>
-
- <%= t("admin.budgets.winners.calculate") %>
-
-
- <%= t("admin.budget_investments.index.cannot_calculate_winners") %>
-
- <% end %>
+ <%= render Admin::Budgets::CalculateWinnersButtonComponent.new(@budget, from_investments: true) %>
<% end %>
<% if @investments.any? %>