diff --git a/app/components/dashboard/default_resource_component.html.erb b/app/components/dashboard/default_resource_component.html.erb
new file mode 100644
index 000000000..c11691553
--- /dev/null
+++ b/app/components/dashboard/default_resource_component.html.erb
@@ -0,0 +1,10 @@
+
+
+
<%= t("dashboard.menu.#{resource}") %>
+
<%= resource_description %>
+
+
+ <%= link_to t("dashboard.resource.view_resource"), resource_path, class: "button expanded" %>
+
+
+
diff --git a/app/components/dashboard/default_resource_component.rb b/app/components/dashboard/default_resource_component.rb
new file mode 100644
index 000000000..ae14d7e89
--- /dev/null
+++ b/app/components/dashboard/default_resource_component.rb
@@ -0,0 +1,29 @@
+class Dashboard::DefaultResourceComponent < ApplicationComponent
+ attr_reader :resource, :proposal
+ use_helpers :can?
+
+ def initialize(resource, proposal)
+ @resource = resource
+ @proposal = proposal
+ end
+
+ def render?
+ can?(:"manage_#{resource}", proposal)
+ end
+
+ def resource_description
+ if resource == "mailing"
+ Setting["proposals.email_short_title"]
+ else
+ Setting["proposals.#{resource}_short_title"]
+ end
+ end
+
+ def resource_path
+ if resource == "polls"
+ proposal_dashboard_polls_path(proposal)
+ else
+ send("new_proposal_dashboard_#{resource}_path", proposal)
+ end
+ end
+end
diff --git a/app/components/dashboard/resources_component.html.erb b/app/components/dashboard/resources_component.html.erb
index 60c731f01..c2c367920 100644
--- a/app/components/dashboard/resources_component.html.erb
+++ b/app/components/dashboard/resources_component.html.erb
@@ -2,9 +2,9 @@
<%= t("dashboard.resources.available_resources") %>
- <%= render "poll_resource" %>
- <%= render "mailing_resource" %>
- <%= render "poster_resource" %>
+ <% default_resources.each do |resource| %>
+ <%= render Dashboard::DefaultResourceComponent.new(resource, proposal) %>
+ <% end %>
<%= render partial: "resource", collection: active_resources %>
diff --git a/app/components/dashboard/resources_component.rb b/app/components/dashboard/resources_component.rb
index 0ed5ac6ba..90a880f3d 100644
--- a/app/components/dashboard/resources_component.rb
+++ b/app/components/dashboard/resources_component.rb
@@ -1,7 +1,14 @@
class Dashboard::ResourcesComponent < ApplicationComponent
- attr_reader :active_resources
+ attr_reader :active_resources, :proposal
- def initialize(active_resources)
+ def initialize(active_resources, proposal)
@active_resources = active_resources
+ @proposal = proposal
end
+
+ private
+
+ def default_resources
+ %w[polls mailing poster]
+ end
end
diff --git a/app/views/dashboard/_mailing_resource.html.erb b/app/views/dashboard/_mailing_resource.html.erb
deleted file mode 100644
index 2ec0beb40..000000000
--- a/app/views/dashboard/_mailing_resource.html.erb
+++ /dev/null
@@ -1,16 +0,0 @@
-<% if can?(:manage_mailing, proposal) %>
-
-
-
<%= t("dashboard.menu.mailing") %>
-
- <%= Setting["proposals.email_short_title"] %>
-
-
-
- <%= link_to t("dashboard.resource.view_resource"),
- new_proposal_dashboard_mailing_path(proposal.to_param),
- class: "button expanded" %>
-
-
-
-<% end %>
diff --git a/app/views/dashboard/_poll_resource.html.erb b/app/views/dashboard/_poll_resource.html.erb
deleted file mode 100644
index 39d21ea8e..000000000
--- a/app/views/dashboard/_poll_resource.html.erb
+++ /dev/null
@@ -1,16 +0,0 @@
-<% if can?(:manage_polls, proposal) %>
-
-
-
<%= t("dashboard.menu.polls") %>
-
- <%= Setting["proposals.poll_short_title"] %>
-
-
-
- <%= link_to t("dashboard.resource.view_resource"),
- proposal_dashboard_polls_path(proposal.to_param),
- class: "button expanded" %>
-
-
-
-<% end %>
diff --git a/app/views/dashboard/_poster_resource.html.erb b/app/views/dashboard/_poster_resource.html.erb
deleted file mode 100644
index 0f47d6c32..000000000
--- a/app/views/dashboard/_poster_resource.html.erb
+++ /dev/null
@@ -1,16 +0,0 @@
-<% if can?(:manage_poster, proposal) %>
-
-
-
<%= t("dashboard.menu.poster") %>
-
- <%= Setting["proposals.poster_short_title"] %>
-
-
-
- <%= link_to t("dashboard.resource.view_resource"),
- new_proposal_dashboard_poster_path(proposal.to_param),
- class: "button expanded" %>
-
-
-
-<% end %>
diff --git a/app/views/dashboard/progress.html.erb b/app/views/dashboard/progress.html.erb
index e6824663f..e4378e7f7 100644
--- a/app/views/dashboard/progress.html.erb
+++ b/app/views/dashboard/progress.html.erb
@@ -38,4 +38,4 @@
<%= render "summary_recommended_actions" %>
<% end %>
-<%= render Dashboard::ResourcesComponent.new(active_resources) %>
+<%= render Dashboard::ResourcesComponent.new(active_resources, proposal) %>