OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
[#67336] Rework Homescreen blocks as Widget Grid
Alexander Brandon Colesa3252add490f
diff --git a/app/views/homescreen/blocks/_administration.html.erb b/app/components/homescreen/blocks/administration.html.erbsimilarity index 94%rename from app/views/homescreen/blocks/_administration.html.erbrename to app/components/homescreen/blocks/administration.html.erbindex 68fa55a3261..5f9a2015346 100644--- a/app/views/homescreen/blocks/_administration.html.erb+++ b/app/components/homescreen/blocks/administration.html.erb@@ -1,4 +1,4 @@-<%= render Grids::WidgetBoxComponent.new(title: t(:label_administration), classes: "administration") do %>+<%= widget_wrapper do %><ul class="widget-box--arrow-links"><li><%= link_to t(:label_project_plural), projects_path,diff --git a/app/components/homescreen/blocks/administration.rb b/app/components/homescreen/blocks/administration.rbnew file mode 100644index 00000000000..017afadfb47--- /dev/null+++ b/app/components/homescreen/blocks/administration.rb@@ -0,0 +1,42 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+# ++++module Homescreen+ module Blocks+ class Administration < Grids::WidgetComponent+ include HookHelper+ include SecurityBadgeHelper++ def title+ I18n.t(:label_administration)+ end+ end+ end+enddiff --git a/app/views/homescreen/blocks/_community.html.erb b/app/components/homescreen/blocks/community.html.erbsimilarity index 95%rename from app/views/homescreen/blocks/_community.html.erbrename to app/components/homescreen/blocks/community.html.erbindex 1e26077a0e7..7613ce53859 100644--- a/app/views/homescreen/blocks/_community.html.erb+++ b/app/components/homescreen/blocks/community.html.erb@@ -1,4 +1,4 @@-<%= render Grids::WidgetBoxComponent.new(title: t("homescreen.blocks.community"), classes: "community") do %>+<%= widget_wrapper do %><ul class="widget-box--arrow-links"><li><%= static_link_to :user_guides %>diff --git a/app/components/homescreen/blocks/community.rb b/app/components/homescreen/blocks/community.rbnew file mode 100644index 00000000000..72e4d0e1c32--- /dev/null+++ b/app/components/homescreen/blocks/community.rb@@ -0,0 +1,41 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+# ++++module Homescreen+ module Blocks+ class Community < Grids::WidgetComponent+ include StaticLinksHelper++ def title+ I18n.t(:"homescreen.blocks.community")+ end+ end+ end+enddiff --git a/app/views/homescreen/blocks/_my_account.html.erb b/app/components/homescreen/blocks/my_account.html.erbsimilarity index 77%rename from app/views/homescreen/blocks/_my_account.html.erbrename to app/components/homescreen/blocks/my_account.html.erbindex 7c5f141364d..187ef52c216 100644--- a/app/views/homescreen/blocks/_my_account.html.erb+++ b/app/components/homescreen/blocks/my_account.html.erb@@ -1,4 +1,4 @@-<%= render Grids::WidgetBoxComponent.new(title: t("label_my_account"), classes: "my_account") do %>+<%= widget_wrapper do %><ul class="widget-box--arrow-links"><li><%= link_to t(:label_profile), my_account_path, title: t(:label_profile) %>@@ -11,4 +11,4 @@<%= link_to t(:button_change_password), my_password_path, title: t(:button_change_password) %></li></ul>- <% end %>+<% end %>diff --git a/app/components/homescreen/blocks/my_account.rb b/app/components/homescreen/blocks/my_account.rbnew file mode 100644index 00000000000..dc4fc4afc96--- /dev/null+++ b/app/components/homescreen/blocks/my_account.rb@@ -0,0 +1,39 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+# ++++module Homescreen+ module Blocks+ class MyAccount < Grids::WidgetComponent+ def title+ I18n.t(:label_my_account)+ end+ end+ end+enddiff --git a/app/components/homescreen/blocks/new_features.html.erb b/app/components/homescreen/blocks/new_features.html.erbnew file mode 100644index 00000000000..f3276de7f14--- /dev/null+++ b/app/components/homescreen/blocks/new_features.html.erb@@ -0,0 +1,24 @@+<%= widget_wrapper do %>+ <div class="op-new-features">+ <p class="widget-box--additional-info">+ <%= new_features_header %>+ </p>+ <div class="widget-box--description">+ <div>+ <p><%= new_features_title %></p>+ <ul>+ <% new_features.values.each do |line| %>+ <li><%= line %></li>+ <% end %>+ </ul>+ </div>+ <img+ class="widget-box--teaser-image op-new-features--teaser-image"+ role="presentation"+ src="<%= asset_path(feature_teaser_image) %>"+ alt="">+ </div>++ <%= helpers.static_link_to :current_release_notes, label: learn_more_link_text %>+ </div>+<% end %>diff --git a/app/components/homescreen/blocks/new_features.rb b/app/components/homescreen/blocks/new_features.rbnew file mode 100644index 00000000000..90e173c7733--- /dev/null+++ b/app/components/homescreen/blocks/new_features.rb@@ -0,0 +1,68 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+# ++++module Homescreen+ module Blocks+ class NewFeatures < Grids::WidgetComponent+ def title+ I18n.t(:label_new_features)+ end++ def feature_teaser_image+ "#{feature_version}_features.svg"+ end++ def new_features_header+ I18n.t("homescreen.blocks.new_features.header")+ end++ def learn_more_link_text+ I18n.t("homescreen.blocks.new_features.learn_about")+ end++ def new_features_title+ I18n.t("homescreen.blocks.new_features.#{feature_version}.new_features_title")+ end++ def new_features+ I18n.t("homescreen.blocks.new_features.#{feature_version}.new_features_list")+ end++ private++ def feature_version+ [+ OpenProject::VERSION::MAJOR,+ OpenProject::VERSION::MINOR+ ].join("_")+ end+ end+ end+enddiff --git a/app/views/homescreen/blocks/_news.html.erb b/app/components/homescreen/blocks/news.html.erbsimilarity index 87%rename from app/views/homescreen/blocks/_news.html.erbrename to app/components/homescreen/blocks/news.html.erbindex c50d1a30dc4..748bad0a290 100644--- a/app/views/homescreen/blocks/_news.html.erb+++ b/app/components/homescreen/blocks/news.html.erb@@ -1,4 +1,4 @@-<%= render Grids::WidgetBoxComponent.new(title: t(:label_news_latest), classes: "news") do %>+<% widget_wrapper do %><% unless @news.empty? %><ul class="widget-box--arrow-links"><% @news.each do |news| %>diff --git a/app/components/homescreen/blocks/news.rb b/app/components/homescreen/blocks/news.rbnew file mode 100644index 00000000000..cd8ebd988d7--- /dev/null+++ b/app/components/homescreen/blocks/news.rb@@ -0,0 +1,52 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+# ++++module Homescreen+ module Blocks+ class News < Grids::WidgetComponent+ include AvatarHelper+ include ApplicationHelper++ def initialize(*)+ super++ @news = ::News.latest(count: 3)+ end++ def title+ I18n.t(:label_news_latest)+ end++ def render?+ @news.any?+ end+ end+ end+enddiff --git a/app/views/homescreen/blocks/_projects.html.erb b/app/components/homescreen/blocks/projects.html.erbsimilarity index 92%rename from app/views/homescreen/blocks/_projects.html.erbrename to app/components/homescreen/blocks/projects.html.erbindex 86733893c26..23edb54e32b 100644--- a/app/views/homescreen/blocks/_projects.html.erb+++ b/app/components/homescreen/blocks/projects.html.erb@@ -1,4 +1,4 @@-<%= render Grids::WidgetBoxComponent.new(title: t(:label_project_plural), classes: "projects") do %>+<% widget_wrapper do %><% if @favorite_projects.any? %><p class="widget-box--additional-info"><%= t("projects.lists.favorited") %></p><ul class="widget-box--arrow-links">@@ -37,7 +37,7 @@<% end %><div class="widget-box--blocks--buttons">- <% if User.current.allowed_globally?(:add_project) %>+ <% if current_user.allowed_globally?(:add_project) %><%= link_to new_project_path,{ class: "button -primary",aria: { label: t(:label_project_new) },diff --git a/app/components/homescreen/blocks/projects.rb b/app/components/homescreen/blocks/projects.rbnew file mode 100644index 00000000000..5e707bacf63--- /dev/null+++ b/app/components/homescreen/blocks/projects.rb@@ -0,0 +1,50 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+# ++++module Homescreen+ module Blocks+ class Projects < Grids::WidgetComponent+ include IconsHelper+ include ProjectsHelper+ include Redmine::I18n++ def initialize(*)+ super++ @favorite_projects = Project.visible.active.favorited_by(current_user)+ @newest_projects = Project.visible.newest.take(3)+ end++ def title+ I18n.t(:label_project_plural)+ end+ end+ end+enddiff --git a/app/components/homescreen/blocks/upsell.html.erb b/app/components/homescreen/blocks/upsell.html.erbnew file mode 100644index 00000000000..33bbaeb2bea--- /dev/null+++ b/app/components/homescreen/blocks/upsell.html.erb@@ -0,0 +1,39 @@+<%= widget_wrapper do %>+ <div class="widget-box--blocks--upsell-container">+ <div class="widget-box--blocks--upsell-text">+ <%=+ render(Primer::OpenProject::FlexLayout.new(align_items: :center, mb: 3)) do |title_flex|+ title_flex.with_column do+ render(+ Primer::Beta::Octicon.new(+ icon: :"op-enterprise-addons",+ size: :medium,+ classes: "upsell-colored"+ )+ )+ end++ title_flex.with_column(ml: 2) do+ render(Primer::Beta::Heading.new(tag: :h2)) { t("ee.upsell.plans_title") }+ end+ end+ %>++ <div class="widget-box--blocks--upsell-description">+ <p>+ <%= link_translate(+ "ee.upsell.homescreen_description",+ links: { enterprise_url: OpenProject::Static::Links.url_for(:enterprise_features, :feature_comparison) }+ ) %>+ </p>+ <p>+ <%= t("ee.upsell.homescreen_subline") %>+ </p>+ </div>++ <%= render EnterpriseEdition::UpsellButtonsComponent.new(nil) %>+ </div>+ <div class="widget-box--blocks--upsell-image"+ style="background-image: url(<%= image_path("enterprise/homescreen.png") %>)"></div>+ </div>+<% end %>diff --git a/app/components/homescreen/blocks/upsell.rb b/app/components/homescreen/blocks/upsell.rbnew file mode 100644index 00000000000..f6bf6fc5104--- /dev/null+++ b/app/components/homescreen/blocks/upsell.rb@@ -0,0 +1,45 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+# ++++module Homescreen+ module Blocks+ class Upsell < Grids::WidgetComponent+ include Redmine::I18n++ def title+ nil+ end++ def wrapper_arguments+ { content_padding: :none }+ end+ end+ end+enddiff --git a/app/views/homescreen/blocks/_users.html.erb b/app/components/homescreen/blocks/users.html.erbsimilarity index 82%rename from app/views/homescreen/blocks/_users.html.erbrename to app/components/homescreen/blocks/users.html.erbindex 098e6c083b8..f88f3887caf 100644--- a/app/views/homescreen/blocks/_users.html.erb+++ b/app/components/homescreen/blocks/users.html.erb@@ -1,4 +1,4 @@-<%= render Grids::WidgetBoxComponent.new(title: t(:label_user_plural), classes: "users") do %>+<%= widget_wrapper do %><p class="widget-box--additional-info"><%= t("homescreen.additional.users") %></p><% unless @newest_users.empty? %>@@ -13,7 +13,7 @@<% end %><div class="widget-box--buttons">- <% if User.current.admin? %>+ <% if current_user.admin? %><%= link_to new_user_path, class: "button -primary" do %><%= op_icon("button--icon icon-add") %><span class="button--text"><%= t(:label_invite_user) %></span>diff --git a/app/components/homescreen/blocks/users.rb b/app/components/homescreen/blocks/users.rbnew file mode 100644index 00000000000..55ebe7d798b--- /dev/null+++ b/app/components/homescreen/blocks/users.rb@@ -0,0 +1,49 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+# ++++module Homescreen+ module Blocks+ class Users < Grids::WidgetComponent+ include IconsHelper+ include OpenProject::ObjectLinking+ include Redmine::I18n++ def initialize(*)+ super++ @newest_users = User.active.newest.take(3)+ end++ def title+ I18n.t(:label_user_plural)+ end+ end+ end+enddiff --git a/app/components/homescreen/blocks/welcome.html.erb b/app/components/homescreen/blocks/welcome.html.erbnew file mode 100644index 00000000000..c53fd0f7d08--- /dev/null+++ b/app/components/homescreen/blocks/welcome.html.erb@@ -0,0 +1,5 @@+<%= widget_wrapper do %>+ <div class="wiki op-uc-container">+ <%= format_text(Setting.welcome_text, headings: false) %>+ </div>+<% end %>diff --git a/app/components/homescreen/blocks/welcome.rb b/app/components/homescreen/blocks/welcome.rbnew file mode 100644index 00000000000..8c94ec2196c--- /dev/null+++ b/app/components/homescreen/blocks/welcome.rb@@ -0,0 +1,42 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+# ++++module Homescreen+ module Blocks+ class Welcome < Grids::WidgetComponent+ include OpenProject::TextFormatting+ include HomescreenHelper++ def title+ Setting.welcome_title.presence || organization_name+ end+ end+ end+enddiff --git a/app/components/homescreen/blocks_grid_component.html.erb b/app/components/homescreen/blocks_grid_component.html.erbnew file mode 100644index 00000000000..4f61964e928--- /dev/null+++ b/app/components/homescreen/blocks_grid_component.html.erb@@ -0,0 +1,36 @@+<%#-- copyright+OpenProject is an open source project management software.+Copyright (C) the OpenProject GmbH++This program is free software; you can redistribute it and/or+modify it under the terms of the GNU General Public License version 3.++OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+Copyright (C) 2006-2013 Jean-Philippe Lang+Copyright (C) 2010-2013 the ChiliProject Team++This program is free software; you can redistribute it and/or+modify it under the terms of the GNU General Public License+as published by the Free Software Foundation; either version 2+of the License, or (at your option) any later version.++This program is distributed in the hope that it will be useful,+but WITHOUT ANY WARRANTY; without even the implied warranty of+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+GNU General Public License for more details.++You should have received a copy of the GNU General Public License+along with this program; if not, write to the Free Software+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.++See COPYRIGHT and LICENSE files for more details.++++#%>++<%=+ render(Grids::WidgetGridComponent.new) do |grid|+ blocks.each do |block|+ grid.with_widget(block)+ end+ end+%>diff --git a/app/components/homescreen/new_features_component.rb b/app/components/homescreen/blocks_grid_component.rbsimilarity index 66%rename from app/components/homescreen/new_features_component.rbrename to app/components/homescreen/blocks_grid_component.rbindex 41ea62bbbf7..c0f8bba65fd 100644--- a/app/components/homescreen/new_features_component.rb+++ b/app/components/homescreen/blocks_grid_component.rb@@ -27,31 +27,22 @@## See COPYRIGHT and LICENSE files for more details.#++-class Homescreen::NewFeaturesComponent < ApplicationComponent- def feature_version- [- OpenProject::VERSION::MAJOR,- OpenProject::VERSION::MINOR- ].join("_")- end-- def feature_teaser_image- "#{feature_version}_features.svg"- end- def new_features_header- I18n.t("homescreen.blocks.new_features.header")- end+module Homescreen+ class BlocksGridComponent < ApplicationComponent+ attr_reader :blocks- def learn_more_link_text- I18n.t("homescreen.blocks.new_features.learn_about")- end+ def initialize(homescreen:)+ super- def new_features_title- I18n.t("homescreen.blocks.new_features.#{feature_version}.new_features_title")- end+ @blocks = (homescreen[:blocks] || [])+ .select { |block| block[:if].nil? || block[:if].call }+ .filter_map { it[:name] }+ .filter_map { "homescreen/blocks/#{it}".camelize.safe_constantize }+ end- def new_features- I18n.t("homescreen.blocks.new_features.#{feature_version}.new_features_list")+ def render?+ blocks.any?+ endendenddiff --git a/app/components/homescreen/new_features_component.html.erb b/app/components/homescreen/new_features_component.html.erbdeleted file mode 100644index 1ec1c73a1f3..00000000000--- a/app/components/homescreen/new_features_component.html.erb+++ /dev/null@@ -1,23 +0,0 @@-<div class="op-new-features">- <p class="widget-box--additional-info">- <%= new_features_header %>- </p>- <div class="widget-box--description">- <div>- <p><%= new_features_title %></p>- <ul>- <% new_features.values.each do |line| %>- <li><%= line %></li>- <% end %>- </ul>- </div>- <img- class="widget-box--teaser-image op-new-features--teaser-image"- role="presentation"- src="<%= asset_path(feature_teaser_image) %>"- alt=""- />- </div>-- <%= helpers.static_link_to :current_release_notes, label: learn_more_link_text %>-</div>diff --git a/app/controllers/homescreen_controller.rb b/app/controllers/homescreen_controller.rbindex aaa7e6090f5..f62ea511c59 100644--- a/app/controllers/homescreen_controller.rb+++ b/app/controllers/homescreen_controller.rb@@ -36,12 +36,7 @@ class HomescreenController < ApplicationControllerlayout "global"def index- @newest_projects = Project.visible.newest.take(3)- @favorite_projects = Project.visible.active.favorited_by(User.current)- @newest_users = User.active.newest.take(3)- @news = News.latest(count: 3)@announcement = Announcement.active_and_current-@homescreen = OpenProject::Static::Homescreenenddiff --git a/app/views/homescreen/blocks/_new_features.html.erb b/app/views/homescreen/blocks/_new_features.html.erbdeleted file mode 100644index b7b3a36bbdc..00000000000--- a/app/views/homescreen/blocks/_new_features.html.erb+++ /dev/null@@ -1,3 +0,0 @@-<%= render Grids::WidgetBoxComponent.new(title: t(:label_new_features), classes: "new_features") do %>- <%= render Homescreen::NewFeaturesComponent.new %>-<% end %>diff --git a/app/views/homescreen/blocks/_upsell.html.erb b/app/views/homescreen/blocks/_upsell.html.erbdeleted file mode 100644index de56f869141..00000000000--- a/app/views/homescreen/blocks/_upsell.html.erb+++ /dev/null@@ -1,37 +0,0 @@-<div class="widget-box--blocks--upsell-container">- <div class="widget-box--blocks--upsell-text">- <%=- render(Primer::OpenProject::FlexLayout.new(align_items: :center, mb: 3)) do |title_flex|- title_flex.with_column do- render(- Primer::Beta::Octicon.new(- icon: :"op-enterprise-addons",- size: :medium,- classes: "upsell-colored"- )- )- end-- title_flex.with_column(ml: 2) do- render(Primer::Beta::Heading.new(tag: :h2)) { t("ee.upsell.plans_title") }- end- end- %>-- <div class="widget-box--blocks--upsell-description">- <p>- <%= link_translate(- "ee.upsell.homescreen_description",- links: { enterprise_url: OpenProject::Static::Links.url_for(:enterprise_features, :feature_comparison) }- ) %>- </p>- <p>- <%= t("ee.upsell.homescreen_subline") %>- </p>- </div>-- <%= render EnterpriseEdition::UpsellButtonsComponent.new(nil) %>- </div>- <div class="widget-box--blocks--upsell-image"- style="background-image: url(<%= image_path("enterprise/homescreen.png") %>)"></div>-</div>diff --git a/app/views/homescreen/blocks/_welcome.html.erb b/app/views/homescreen/blocks/_welcome.html.erbdeleted file mode 100644index cdd0ac788f7..00000000000--- a/app/views/homescreen/blocks/_welcome.html.erb+++ /dev/null@@ -1,5 +0,0 @@-<%= render Grids::WidgetBoxComponent.new(title: Setting.welcome_title.presence || organization_name, classes: "welcome") do %>- <div class="wiki op-uc-container">- <%= format_text(Setting.welcome_text, headings: false) %>- </div>-<% end %>diff --git a/app/views/homescreen/index.html.erb b/app/views/homescreen/index.html.erbindex f89cdeaa538..8368979ecd5 100644--- a/app/views/homescreen/index.html.erb+++ b/app/views/homescreen/index.html.erb@@ -35,15 +35,7 @@ See COPYRIGHT and LICENSE files for more details.<%= render partial: "announcements/show" %>-<% if @homescreen[:blocks].any? %>- <section class="widget-boxes -flex">- <% @homescreen[:blocks].each do |block| %>- <% if block[:if].nil? || instance_eval(&block[:if]) %>- <%= render partial: "homescreen/blocks/#{block[:partial]}", locals: block[:locals] || {} %>- <% end %>- <% end %>- </section>-<% end %>+<%= render Homescreen::BlocksGridComponent.new(homescreen: @homescreen) %><% if show_homescreen_links? && @homescreen[:links].any? %><section class="homescreen--links">diff --git a/config/initializers/homescreen.rb b/config/initializers/homescreen.rbindex 9a5f20f9224..d7cddebfe6b 100644--- a/config/initializers/homescreen.rb+++ b/config/initializers/homescreen.rb@@ -34,38 +34,37 @@ require "open_project/static/links"OpenProject::Static::Homescreen.manage :blocks do |blocks|blocks.push({- partial: "welcome",+ name: "welcome",if: Proc.new { Setting.welcome_on_homescreen? && Setting.welcome_text.present? }},{- partial: "projects"+ name: "projects"},{- partial: "new_features",+ name: "new_features",if: Proc.new { OpenProject::Configuration.show_community_links? }},{- partial: "users",+ name: "users",if: Proc.new { User.current.admin? }},{- partial: "my_account",+ name: "my_account",if: Proc.new { User.current.logged? }},{- partial: "news",- if: Proc.new { [email protected]? }+ name: "news"},{- partial: "community",+ name: "community",if: Proc.new { OpenProject::Configuration.show_community_links? }},{- partial: "administration",+ name: "administration",if: Proc.new { User.current.admin? }},{- partial: "upsell",+ name: "upsell",if: Proc.new { !(EnterpriseToken.active? || EnterpriseToken.hide_banners?) || EnterpriseToken.trial_only? }})diff --git a/spec/controllers/homescreen_controller_spec.rb b/spec/controllers/homescreen_controller_spec.rbindex 7b30e8d5ab1..f875e03494e 100644--- a/spec/controllers/homescreen_controller_spec.rb+++ b/spec/controllers/homescreen_controller_spec.rb@@ -31,107 +31,23 @@require "spec_helper"RSpec.describe HomescreenController do+ let(:user) { build(:user) }+before dologin_as(user)# assume anonymous may access the pageallow(Setting).to receive(:login_required?).and_return(false)- allow(Setting).to receive(:welcome_on_homescreen?).and_return(show_welcome)- get :index- end-- let(:all_blocks) do- %w(administration community my_account projects users)- end-- let(:show_welcome) { false }-- shared_examples "renders blocks" do- it "renders a response" do- expect(response).to have_http_status(:ok)- end-- describe "with rendered views" do- render_views-- it "renders the given blocks" do- shown.each do |block|- expect(response).to render_template(partial: "homescreen/blocks/_#{block}")- end- end-- it "does not render the other blocks" do- (all_blocks - shown).each do |block|- expect(response).not_to render_template(partial: "homescreen/blocks/_#{block}")- end- end-- it "does not render news when empty" do- expect(response).not_to render_template(partial: "homescreen/blocks/_news")- end-- it "shows the news when available" do- expect(News).to receive(:latest).with(any_args)- .and_return(build_stubbed_list(:news, 5, created_at: Time.now))-- get :index- expect(response).to render_template(partial: "homescreen/blocks/_news")- end-- it "does not render the welcome block" do- expect(response).not_to render_template(partial: "homescreen/blocks/_welcome")- end-- context "with enabled announcement" do- let!(:announcement) { create(:active_announcement) }-- it "renders the announcement" do- expect(response).to render_template(partial: "announcements/_show")- end- end-- context "with enabled welcome block" do- before do- allow(Setting).to receive(:welcome_text).and_return("h1. foobar")- allow(Setting).to receive(:welcome_title).and_return("Woohoo!")- get :index- end-- let(:show_welcome) { true }-- it "renders the block" do- expect(response).to render_template(partial: "homescreen/blocks/_welcome")- end-- it "renders the text" do- expect(response.body).to have_css('[data-test-selector="op-widget-box--header"]',- text: "Woohoo!")- end- end- endend- context "with admin" do- let(:user) { build(:admin) }-- it_behaves_like "renders blocks" do- let(:shown) { all_blocks }+ describe "#index" do+ before do+ get :indexend- end-- context "regular user" do- let(:user) { build(:user) }-- it_behaves_like "renders blocks" do- let(:shown) { all_blocks - %w(administration users) }- end- end-- context "anonymous user" do- let(:user) { User.anonymous }- it_behaves_like "renders blocks" do- let(:shown) { all_blocks - %w(administration users my_account) }+ it "renders 'index'" do+ expect(response).to be_successful+ expect(response).to render_template :indexendendend