From 72d54a8a57dfb21f39db40bb7cd464b2efb497f5 Mon Sep 17 00:00:00 2001 From: Mir Bhatia Date: Fri, 13 Mar 2026 16:11:18 +0100 Subject: [PATCH] Update role selector --- .../edit_sub_header_component.html.erb | 21 +++++++++++++- .../workflows/edit_sub_header_component.rb | 5 ++-- app/views/workflows/edit.html.erb | 29 +------------------ config/locales/en.yml | 3 ++ 4 files changed, 27 insertions(+), 31 deletions(-) diff --git a/app/components/workflows/edit_sub_header_component.html.erb b/app/components/workflows/edit_sub_header_component.html.erb index df3411ae7fb..c6903766e74 100644 --- a/app/components/workflows/edit_sub_header_component.html.erb +++ b/app/components/workflows/edit_sub_header_component.html.erb @@ -29,12 +29,31 @@ See COPYRIGHT and LICENSE files for more details. <%= render Primer::OpenProject::SubHeader.new do |subheader| + if @type && @available_roles.any? + subheader.with_filter_component do + render(Primer::Alpha::ActionMenu.new(select_variant: :single)) do |menu| + menu.with_show_button(scheme: :secondary) do |button| + button.with_trailing_visual_icon(icon: :"triangle-down") + @current_role ? t("admin.workflows.role_selector.label", role: @current_role.name) : t("admin.workflows.role_selector.no_role") + end + @available_roles.each do |role| + menu.with_item( + label: role.name, + tag: :a, + href: helpers.edit_workflow_path(@type, role_id: role.id, tab: @tab || "always"), + active: role == @current_role + ) + end + end + end + end + subheader.with_action_button( tag: :a, scheme: :secondary, leading_icon: :plus, label: t("admin.workflows.status_button"), - href: helpers.status_dialog_workflows_path(role_id: @role&.id, type_id: @type&.id, tab: @tab), + href: helpers.status_dialog_workflows_path(role_id: @current_role&.id, type_id: @type&.id, tab: @tab), data: { controller: "async-dialog" } ) do t("admin.workflows.status_button") diff --git a/app/components/workflows/edit_sub_header_component.rb b/app/components/workflows/edit_sub_header_component.rb index 6aa0b1ac9e1..9113f4a9ccc 100644 --- a/app/components/workflows/edit_sub_header_component.rb +++ b/app/components/workflows/edit_sub_header_component.rb @@ -32,11 +32,12 @@ module Workflows class EditSubHeaderComponent < ApplicationComponent include OpPrimer::ComponentHelpers - def initialize(tab:, role: nil, type: nil) + def initialize(tab:, current_role: nil, type: nil, available_roles: []) super @tab = tab - @role = role + @current_role = current_role @type = type + @available_roles = available_roles end end end diff --git a/app/views/workflows/edit.html.erb b/app/views/workflows/edit.html.erb index dcfe085726e..114c7214690 100644 --- a/app/views/workflows/edit.html.erb +++ b/app/views/workflows/edit.html.erb @@ -32,34 +32,7 @@ See COPYRIGHT and LICENSE files for more details. <%= render Workflows::EditPageHeaderComponent.new(@type, tabs: workflow_tabs(@type)) %> <% end %> -<%= styled_form_tag({}, method: "get") do %> - <%= hidden_field_tag "tab", params[:tab] || "always" %> - -
- <%= t(:text_workflow_edit) %> - -
-<% end %> - -<%= render Workflows::EditSubHeaderComponent.new(tab: params[:tab], role: @role, type: @type) %> +<%= render Workflows::EditSubHeaderComponent.new(tab: params[:tab], current_role: @role, type: @type, available_roles: @roles) %> <% if @type && @role %> <%= turbo_frame_tag "workflow-table" do %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 7868df69f8f..09f63b328cf 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -415,6 +415,9 @@ en: other: "Remove %{count} statuses?" description: "Removing these statuses will make them unavailable to this type and delete existing workflows. Are you sure you want to proceed?" confirm: "Remove" + role_selector: + label: "Role: %{role}" + no_role: "Select role" authentication: login_and_registration: "Login and registration"