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
Move News widget to Overiew module and let it inherit from WidgetComponent
Henriette Darge4f4830f64e55
diff --git a/modules/grids/app/components/grids/widget_box_component.rb b/modules/grids/app/components/grids/widget_box_component.rbindex 5922380b52b..2812d862f3e 100644--- a/modules/grids/app/components/grids/widget_box_component.rb+++ b/modules/grids/app/components/grids/widget_box_component.rb@@ -97,6 +97,7 @@ module Gridsdef before_renderreturn unless header+@list_arguments[:aria] = { labelledby: @header_id }endenddiff --git a/modules/grids/app/views/grids/widgets/news/show.html.erb b/modules/grids/app/views/grids/widgets/news/show.html.erbindex f308a9bf7a8..d0a19d13267 100644--- a/modules/grids/app/views/grids/widgets/news/show.html.erb+++ b/modules/grids/app/views/grids/widgets/news/show.html.erb@@ -27,4 +27,4 @@ See COPYRIGHT and LICENSE files for more details.++#%>-<%= render Grids::Widgets::NewsComponent.new(project: @project, current_user:) %>+<%= render Overviews::Widgets::NewsComponent.new(@project) %>diff --git a/modules/overviews/app/components/overviews/overview_grid_component.html.erb b/modules/overviews/app/components/overviews/overview_grid_component.html.erbindex dd9a8f2ff28..9afccac1ecc 100644--- a/modules/overviews/app/components/overviews/overview_grid_component.html.erb+++ b/modules/overviews/app/components/overviews/overview_grid_component.html.erb@@ -30,7 +30,10 @@ See COPYRIGHT and LICENSE files for more details.<%=render(Grids::WidgetGridComponent.new) do |grid|grid.with_widget(Overviews::Widgets::DescriptionComponent, @project)- grid.with_widget(Overviews::Widgets::SubitemsComponent, @project)grid.with_widget(Overviews::Widgets::ProjectStatusComponent, @project)+ grid.with_widget(Overviews::Widgets::SubitemsComponent, @project)+ if OpenProject::FeatureDecisions.beta_widgets_active?+ grid.with_widget(Overviews::Widgets::NewsComponent, @project)+ endend%>diff --git a/modules/grids/app/components/grids/widgets/news_component.html.erb b/modules/overviews/app/components/overviews/widgets/news_component.html.erbsimilarity index 82%rename from modules/grids/app/components/grids/widgets/news_component.html.erbrename to modules/overviews/app/components/overviews/widgets/news_component.html.erbindex fee146598e3..ebb09bf6d88 100644--- a/modules/grids/app/components/grids/widgets/news_component.html.erb+++ b/modules/overviews/app/components/overviews/widgets/news_component.html.erb@@ -28,18 +28,19 @@ See COPYRIGHT and LICENSE files for more details.++#%><%=- component_wrapper tag: :"turbo-frame" do+ widget_wrapper do |container|if @newest.empty?render(Primer::Beta::Text.new(color: :subtle)) { t(:"js.grid.widgets.news.no_results") }else- render(OpPrimer::ListComponent.new(m: 0)) do- render(- ItemComponent.with_collection(- @newest,- project:,- spacer_component: OpPrimer::ListComponent::Divider.new(border: :bottom)+ @newest.each do |item|+ container.with_row do+ render(+ ItemComponent.new(+ item:,+ project:+ ))- )+ endendendenddiff --git a/modules/grids/app/components/grids/widgets/news_component.rb b/modules/overviews/app/components/overviews/widgets/news_component.rbsimilarity index 91%rename from modules/grids/app/components/grids/widgets/news_component.rbrename to modules/overviews/app/components/overviews/widgets/news_component.rbindex 8b0529fb3bb..4765f842dbe 100644--- a/modules/grids/app/components/grids/widgets/news_component.rb+++ b/modules/overviews/app/components/overviews/widgets/news_component.rb@@ -28,9 +28,9 @@# See COPYRIGHT and LICENSE files for more details.#++-module Grids+module Overviewsmodule Widgets- class NewsComponent < ApplicationComponent+ class NewsComponent < Grids::WidgetComponentNEWS_LIMIT = 5include ApplicationHelper@@ -39,7 +39,7 @@ module Gridsattr_reader :project, :current_user- def initialize(project:, current_user:)+ def initialize(project)super()@project = project@@ -56,6 +56,11 @@ module Grids@newest = @news.limit(NEWS_LIMIT).to_aend++ def title+ Project.human_attribute_name(:news)+ end+endendenddiff --git a/modules/grids/app/components/grids/widgets/news_component/item_component.html.erb b/modules/overviews/app/components/overviews/widgets/news_component/item_component.html.erbsimilarity index 56%rename from modules/grids/app/components/grids/widgets/news_component/item_component.html.erbrename to modules/overviews/app/components/overviews/widgets/news_component/item_component.html.erbindex 911c5f5bf92..ed0be9a0b55 100644--- a/modules/grids/app/components/grids/widgets/news_component/item_component.html.erb+++ b/modules/overviews/app/components/overviews/widgets/news_component/item_component.html.erb@@ -28,35 +28,33 @@ See COPYRIGHT and LICENSE files for more details.++#%><%=- render(OpPrimer::ListComponent::Item.new) do- render(Primer::Box.new(mt: 2, pb: 2)) do- component_collection do |body|- body.with_component(- flex_layout do |layout|- unless project- layout.with_column do- render(- Primer::Beta::Link.new(- font_weight: :bold,- scheme: :secondary,- href: project_path(item.project)- )- ) { "#{item.project.name}:" }- end- end-+ render(Primer::Box.new) do+ component_collection do |body|+ body.with_component(+ flex_layout do |layout|+ unless projectlayout.with_column do- render(Primer::Beta::Link.new(ml: 1, font_weight: :bold, href: news_path(item))) { item.title }+ render(+ Primer::Beta::Link.new(+ font_weight: :bold,+ scheme: :secondary,+ href: project_path(item.project)+ )+ ) { "#{item.project.name}:" }endend- )- body.with_component(- render(Primer::Beta::Text.new(tag: :p, color: :subtle)) { helpers.authoring_at(format_time(item.created_at), item.author) }- )- body.with_component(- render(Primer::Beta::Text.new) { item.summary }- )- end++ layout.with_column do+ render(Primer::Beta::Link.new(ml: 1, font_weight: :bold, href: news_path(item))) { item.title }+ end+ end+ )+ body.with_component(+ render(Primer::Beta::Text.new(tag: :p, color: :subtle)) { helpers.authoring_at(format_time(item.created_at), item.author) }+ )+ body.with_component(+ render(Primer::Beta::Text.new) { item.summary }+ )endend%>diff --git a/modules/grids/app/components/grids/widgets/news_component/item_component.rb b/modules/overviews/app/components/overviews/widgets/news_component/item_component.rbsimilarity index 96%rename from modules/grids/app/components/grids/widgets/news_component/item_component.rbrename to modules/overviews/app/components/overviews/widgets/news_component/item_component.rbindex 058934e3537..da19bcc9905 100644--- a/modules/grids/app/components/grids/widgets/news_component/item_component.rb+++ b/modules/overviews/app/components/overviews/widgets/news_component/item_component.rb@@ -28,9 +28,9 @@# See COPYRIGHT and LICENSE files for more details.#++-module Grids+module Overviewsmodule Widgets- class NewsComponent < ApplicationComponent+ class NewsComponent < Grids::WidgetComponentclass ItemComponent < ApplicationComponentinclude ApplicationHelperinclude OpPrimer::ComponentHelpersdiff --git a/modules/grids/spec/components/grids/widgets/news_component_spec.rb b/modules/overviews/spec/components/overviews/widgets/news_component_spec.rbsimilarity index 98%rename from modules/grids/spec/components/grids/widgets/news_component_spec.rbrename to modules/overviews/spec/components/overviews/widgets/news_component_spec.rbindex e99f435460f..9960530ac0b 100644--- a/modules/grids/spec/components/grids/widgets/news_component_spec.rb+++ b/modules/overviews/spec/components/overviews/widgets/news_component_spec.rb@@ -30,7 +30,7 @@require "rails_helper"-RSpec.describe Grids::Widgets::NewsComponent, type: :component do+RSpec.describe Overviews::Widgets::NewsComponent, type: :component doinclude Rails.application.routes.url_helpersdef render_component(...)