Skip to content

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

[#58160] show icons in life cycle list headers

Tobias Dillmann3ccf62532e77
diff --git a/app/components/projects/table_component.html.erb b/app/components/projects/table_component.html.erb
index a114faeff84..9f33feb4aee 100644
--- a/app/components/projects/table_component.html.erb
+++ b/app/components/projects/table_component.html.erb
@@ -56,7 +56,7 @@ See COPYRIGHT and LICENSE files for more details.
</th>
<% else %>
<% if use_quick_action_table_headers? %>
- <%= quick_action_table_header column.attribute, order_options(column, turbo: true) %>
+ <%= quick_action_table_header column, order_options(column, turbo: true) %>
<% else %>
<th>
<div class="generic-table--sort-header-outer">
diff --git a/app/helpers/sort_helper.rb b/app/helpers/sort_helper.rb
index e0a557d56b1..daf2c395ae0 100644
--- a/app/helpers/sort_helper.rb
+++ b/app/helpers/sort_helper.rb
@@ -331,8 +331,8 @@ module SortHelper
# This is a more specific version of #sort_header_tag.
# For "filter by" to work properly, you must pass a Hash for `filter_column_mapping`.
def sort_header_with_action_menu(column, all_columns, filter_column_mapping = {}, allowed_params: nil, **options)
- with_sort_header_options(column, allowed_params:, **options) do |col, cap, default_order, **opts|
- action_menu(col, all_columns, cap, default_order, filter_column_mapping, **opts)
+ with_sort_header_options(column.attribute, allowed_params:, **options) do |_col, cap, default_order, **opts|
+ action_menu(column, all_columns, cap, default_order, filter_column_mapping, **opts)
end
end
@@ -392,9 +392,11 @@ module SortHelper
# Some of the method arguments are only needed for specific actions.
def action_menu(column, table_columns, caption, default_order, filter_column_mapping = {},
allowed_params: nil, **html_options)
- caption ||= column.to_s.humanize
- filter = find_filter_for_column(column, filter_column_mapping)
+ attribute = column.attribute
+ caption ||= attribute.to_s.humanize
+
+ filter = find_filter_for_column(attribute, filter_column_mapping)
sortable = html_options.delete(:sortable)
# `param` is not needed in the `content_arguments`, but should remain in the `html_options`.
@@ -402,25 +404,27 @@ module SortHelper
# the action menu.
content_args = html_options.merge(rel: :nofollow, param: nil)
- render Primer::Alpha::ActionMenu.new(menu_id: "menu-#{column}") do |menu|
- action_button(menu, caption, favorite: column == :favored)
+ render Primer::Alpha::ActionMenu.new(menu_id: "menu-#{attribute}") do |menu|
+ action_button(menu, column, caption, favorite: column == :favored)
# Some columns are not sortable or do not offer a suitable filter. Omit those actions for them.
- sort_actions(menu, column, default_order, content_args:, allowed_params:, **html_options) if sortable
- filter_action(menu, column, filter, content_args:) if filter
+ sort_actions(menu, attribute, default_order, content_args:, allowed_params:, **html_options) if sortable
+ filter_action(menu, attribute, filter, content_args:) if filter
- move_column_actions(menu, column, table_columns, content_args:, allowed_params:, **html_options)
- add_and_remove_column_actions(menu, column, table_columns, content_args:, allowed_params:, **html_options)
+ move_column_actions(menu, attribute, table_columns, content_args:, allowed_params:, **html_options)
+ add_and_remove_column_actions(menu, attribute, table_columns, content_args:, allowed_params:, **html_options)
end
end
- def action_button(menu, caption, favorite: false)
+ def action_button(menu, column, caption, favorite: false)
menu.with_show_button(scheme: :link, color: :default, text_transform: :uppercase,
underline: false, display: :inline_flex,
classes: "generic-table--action-menu-button") do |button|
if favorite
# This column only shows an icon, no text.
render Primer::Beta::Octicon.new(icon: "star-fill", color: :subtle, "aria-label": I18n.t(:label_favorite))
+ elsif column.respond_to?(:action_menu_header)
+ column.action_menu_header(button)
else
button.with_trailing_action_icon(icon: :"triangle-down")
diff --git a/app/models/queries/projects/selects/life_cycle_step.rb b/app/models/queries/projects/selects/life_cycle_step.rb
index 55725c05345..6143283809b 100644
--- a/app/models/queries/projects/selects/life_cycle_step.rb
+++ b/app/models/queries/projects/selects/life_cycle_step.rb
@@ -57,4 +57,12 @@ class Queries::Projects::Selects::LifeCycleStep < Queries::Selects::Base
def available?
life_cycle_step.present?
end
+
+ def action_menu_header(button)
+ icon = life_cycle_step.is_a?(Project::StageDefinition) ? :"git-commit" : :diamond
+ button.with_leading_visual_icon(icon:)
+ button.with_trailing_action_icon(icon: :"triangle-down")
+
+ caption.to_s
+ end
end