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

change segmented control to action menu

Klaus Zandersc7b5cdb1301f
diff --git a/modules/costs/app/components/my/time_tracking/mode_switcher_component.rb b/modules/costs/app/components/my/time_tracking/mode_switcher_component.rb
index 6c08ba78a7b..32a14bc2c99 100644
--- a/modules/costs/app/components/my/time_tracking/mode_switcher_component.rb
+++ b/modules/costs/app/components/my/time_tracking/mode_switcher_component.rb
@@ -36,17 +36,20 @@ module My
:date
def call
- render(Primer::Alpha::SegmentedControl.new("aria-label": I18n.t(:label_meeting_date_time))) do |control|
- %i[day week workweek month].each do |mode|
- control.with_item(
- tag: :a,
- href: my_time_tracking_path(date:, view_mode:, mode:),
- icon: icon_for_mode(mode),
- label: t("label_#{mode}"),
- title: t("label_#{mode}"),
- selected: (current_mode == mode)
- )
+ render(Primer::Alpha::ActionMenu.new(menu_id: "my-time-tracking-mode-switch")) do |menu|
+ menu.with_show_button do |button|
+ button.with_leading_visual_icon(icon: icon_for_mode(current_mode))
+ button.with_trailing_action_icon(icon: :"triangle-down")
+ t("label_#{current_mode}")
end
+
+ %i[day week workweek month].each { menu_item_for_mode(menu, it) }
+ end
+ end
+
+ def menu_item_for_mode(menu, mode)
+ menu.with_item(tag: :a, href: my_time_tracking_path(date:, view_mode:, mode:), label: t("label_#{mode}")) do |item|
+ item.with_leading_visual_icon(icon: icon_for_mode(mode))
end
end
diff --git a/modules/costs/app/components/my/time_tracking/view_mode_switcher_component.rb b/modules/costs/app/components/my/time_tracking/view_mode_switcher_component.rb
index 1a3accefbc2..225dce321ae 100644
--- a/modules/costs/app/components/my/time_tracking/view_mode_switcher_component.rb
+++ b/modules/costs/app/components/my/time_tracking/view_mode_switcher_component.rb
@@ -36,7 +36,7 @@ module My
:date
def call
- render(Primer::Alpha::TabNav.new(label: I18n.l(:label_view_mode_switcher))) do |component|
+ render(Primer::Alpha::TabNav.new(label: I18n.t(:label_view_mode_switcher))) do |component|
component.with_tab(selected: view_mode == :calendar, href: link(:calendar)) do |tab|
tab.with_text { I18n.t(:label_calendar) }
tab.with_icon(icon: :calendar)