diff --git a/app/components/portfolios/index_page_header_component.rb b/app/components/portfolios/index_page_header_component.rb index 55b8a128888..c838fa9c3c1 100644 --- a/app/components/portfolios/index_page_header_component.rb +++ b/app/components/portfolios/index_page_header_component.rb @@ -31,7 +31,6 @@ module Portfolios class IndexPageHeaderComponent < ApplicationComponent include OpPrimer::ComponentHelpers - include Primer::FetchOrFallbackHelper include OpTurbo::Streamable attr_accessor :current_user, diff --git a/app/components/portfolios/index_sub_header_component.html.erb b/app/components/portfolios/index_sub_header_component.html.erb index e9d3cfa2fc0..76e15e28ccf 100644 --- a/app/components/portfolios/index_sub_header_component.html.erb +++ b/app/components/portfolios/index_sub_header_component.html.erb @@ -22,12 +22,12 @@ href: new_portfolio_path, scheme: :primary, leading_icon: :plus, - label: new_portfolio_label, + label: t(:label_portfolio), disabled: @disable_buttons, size: :medium, data: { "test-selector": "portfolio-new-button" } ) do - new_portfolio_label + t(:label_portfolio) end subheader.with_bottom_pane_component(mt: 0) do diff --git a/app/components/portfolios/index_sub_header_component.rb b/app/components/portfolios/index_sub_header_component.rb index 2c451922025..b6625f3da1c 100644 --- a/app/components/portfolios/index_sub_header_component.rb +++ b/app/components/portfolios/index_sub_header_component.rb @@ -29,9 +29,7 @@ # ++ module Portfolios - # rubocop:disable OpenProject/AddPreviewForViewComponent class IndexSubHeaderComponent < ApplicationComponent - # rubocop:enable OpenProject/AddPreviewForViewComponent include ApplicationHelper include OpTurbo::Streamable @@ -70,9 +68,5 @@ module Portfolios def clear_button_id "portfolio-filters-form-clear-button" end - - def new_portfolio_label - I18n.t(:label_portfolio) - end end end diff --git a/app/components/portfolios/preview_component.html.erb b/app/components/portfolios/preview_component.html.erb index cee1c64022e..f7be03213b7 100644 --- a/app/components/portfolios/preview_component.html.erb +++ b/app/components/portfolios/preview_component.html.erb @@ -52,7 +52,7 @@ "aria-label": "TODO", mr: 1 ) - ) + content_tag(:span, program_count_label) + ) + content_tag(:span, t("program.count", count: all_subprograms.count)) end footer.with_column(mr: 3) do @@ -63,7 +63,7 @@ "aria-label": "TODO", mr: 1 ) - ) + content_tag(:span, project_count_label) + ) + content_tag(:span, t("project.count", count: all_subprojects.count)) end # TODO: WP-68872 render budget @@ -75,7 +75,7 @@ # "aria-label": "TODO", # mr: 1 # ) - # ) + content_tag(:span, budget_label) + # ) + content_tag(:span, "34,000 EUR budget - 12,000 EUR spent") # end footer.with_column do @@ -85,7 +85,7 @@ data: { test_selector: "op-portfolios--updated-at" } ) ) do - updated_at_label + t(:label_updated_time, value: distance_of_time_in_words(Time.current, portfolio.updated_at)) end end end diff --git a/app/components/portfolios/preview_component.rb b/app/components/portfolios/preview_component.rb index 12d69d1a0e5..ba897a3d417 100644 --- a/app/components/portfolios/preview_component.rb +++ b/app/components/portfolios/preview_component.rb @@ -46,21 +46,12 @@ module Portfolios @currently_favorited ||= favorited_project_ids.include?(portfolio.id) end - def program_count_label - I18n.t("program.count", count: all_subprograms.count) + def all_subprograms + all_descendants.filter { it.workspace_type == "program" } end - def project_count_label - I18n.t("project.count", count: all_subprojects.count) - end - - def budget_label - # TODO: WP-68872 replace dummy text - "34,000 EUR budget - 12,000 EUR spent" - end - - def updated_at_label - I18n.t(:label_updated_time, value: distance_of_time_in_words(Time.current, portfolio.updated_at)) + def all_subprojects + all_descendants.filter { it.workspace_type == "project" } end private @@ -84,13 +75,5 @@ module Portfolios @descendants end - - def all_subprograms - all_descendants.filter { it.workspace_type == "program" } - end - - def all_subprojects - all_descendants.filter { it.workspace_type == "project" } - end end end diff --git a/app/menus/portfolios/menu.rb b/app/menus/portfolios/menu.rb index ac891ad7b48..bd87d747696 100644 --- a/app/menus/portfolios/menu.rb +++ b/app/menus/portfolios/menu.rb @@ -39,7 +39,7 @@ module Portfolios @controller_path = controller_path @current_user = current_user - super(view_type:, project:, params:) + super(view_type:, params:, project: nil) end def menu_items @@ -64,10 +64,6 @@ module Portfolios end end - def favorited?(query_params) - query_params[:query_id].in?(favorited_ids) - end - def query_path(query_params) portfolios_path(query_params) end @@ -75,12 +71,14 @@ module Portfolios private def main_static_filters - static_filters [ + main_filters = [ ProjectQueries::Static::ACTIVE_PORTFOLIOS, current_user.logged? ? ProjectQueries::Static::MY_PORTFOLIOS : nil, current_user.logged? ? ProjectQueries::Static::FAVORITED_PORTFOLIOS : nil, current_user.admin? ? ProjectQueries::Static::ARCHIVED_PORTFOLIOS : nil - ].compact + ] + + static_filters(main_filters.compact) end def static_filters(ids) @@ -89,17 +87,6 @@ module Portfolios end end - def persisted_filters - @persisted_filters ||= ::ProjectQuery - .visible(current_user) - .with_favorited_by_user(current_user) - .order(favorited: :desc, name: :asc) - end - - def favorited_ids - @favorited_ids ||= persisted_filters.select(&:favorited).to_set(&:id) - end - def modification_params? params.values_at(:filters, :sortBy).any? end