Skip to content

Commit 05e9353

Browse files
committed
Update all remaining components to work with multiple roles
1 parent f9edc9e commit 05e9353

17 files changed

Lines changed: 41 additions & 38 deletions

app/components/workflows/blankslate_component.html.erb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,8 @@ See COPYRIGHT and LICENSE files for more details.
3131
render(Primer::Beta::Blankslate.new(border: true)) do |blankslate|
3232
blankslate.with_heading(tag: :h2).with_content(t("admin.workflows.blankslate.title"))
3333
blankslate.with_description_content(t("admin.workflows.blankslate.description"))
34-
# TODO: pass all roles once BlankslateComponent accepts roles: and StatusDialogComponent supports multi-role natively.
3534
blankslate.with_primary_action(
36-
href: helpers.status_dialog_workflow_tab_path(@type, @tab, role_ids: [@role.id]),
35+
href: helpers.status_dialog_workflow_tab_path(@type, @tab, role_ids: @roles.map(&:id)),
3736
scheme: :secondary,
3837
data: { controller: "async-dialog" }
3938
) do |button|

app/components/workflows/blankslate_component.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ module Workflows
3232
class BlankslateComponent < ApplicationComponent
3333
include OpPrimer::ComponentHelpers
3434

35-
def initialize(role:, type:, tab:)
35+
def initialize(roles:, type:, tab:)
3636
super
37-
@role = role
37+
@roles = roles
3838
@type = type
3939
@tab = tab
4040
end

app/components/workflows/page_headers/edit_component.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
module Workflows::PageHeaders
3232
class EditComponent < BaseComponent
33-
options :tabs, :role
33+
options :tabs, :roles
3434

3535
def type = model
3636

@@ -49,7 +49,7 @@ def add_action_buttons(header)
4949
mobile_icon: :copy,
5050
mobile_label: t(:button_copy),
5151
size: :medium,
52-
href: new_workflow_copy_path(type, source_role_id: role&.id),
52+
href: new_workflow_copy_path(type, source_role_id: roles&.first&.id),
5353
aria: { label: helpers.t(:button_copy) },
5454
title: helpers.t(:button_copy)
5555
) do |button|

app/components/workflows/status_dialog_component.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ See COPYRIGHT and LICENSE files for more details.
4242
Workflows::StatusFormComponent.new(
4343
all_statuses: @all_statuses,
4444
current_statuses: @current_statuses,
45-
role: @role,
45+
roles: @roles,
4646
type: @type,
4747
tab: @tab
4848
)

app/components/workflows/status_dialog_component.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ class StatusDialogComponent < ApplicationComponent
3535

3636
DIALOG_ID = "workflows-status-dialog"
3737

38-
def initialize(all_statuses:, current_statuses:, role:, type:, tab:)
38+
def initialize(all_statuses:, current_statuses:, roles:, type:, tab:)
3939
super
4040
@all_statuses = all_statuses
4141
@current_statuses = current_statuses
42-
@role = role
42+
@roles = roles
4343
@type = type
4444
@tab = tab
4545
end

app/components/workflows/status_form_component.html.erb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,8 @@ See COPYRIGHT and LICENSE files for more details.
2828
++#%>
2929

3030
<%=
31-
# TODO: pass all roles once StatusFormComponent and confirm_statuses support multi-role natively.
3231
primer_form_with(
33-
url: helpers.confirm_statuses_workflow_tab_path(@type, @tab, role_ids: [@role.id]),
32+
url: helpers.confirm_statuses_workflow_tab_path(@type, @tab, role_ids: @roles.map(&:id)),
3433
method: :post,
3534
id: FORM_ID,
3635
data: { turbo_frame: "workflow-table" }
@@ -40,7 +39,6 @@ See COPYRIGHT and LICENSE files for more details.
4039
f,
4140
all_statuses: @all_statuses,
4241
current_statuses: @current_statuses,
43-
role: @role,
4442
type: @type,
4543
tab: @tab,
4644
dialog_id:

app/components/workflows/status_form_component.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ module Workflows
3232
class StatusFormComponent < ApplicationComponent
3333
FORM_ID = "status-selection-form"
3434

35-
def initialize(all_statuses:, current_statuses:, role:, type:, tab:)
35+
def initialize(all_statuses:, current_statuses:, roles:, type:, tab:)
3636
super
3737
@all_statuses = all_statuses
3838
@current_statuses = current_statuses
39-
@role = role
39+
@roles = roles
4040
@type = type
4141
@tab = tab
4242
end

app/components/workflows/status_matrix_form_component.html.erb

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ See COPYRIGHT and LICENSE files for more details.
4444
button.with_trailing_visual_icon(icon: :"triangle-down")
4545
if @roles.many?
4646
t("admin.workflows.role_selector.roles", count: @roles.size)
47-
elsif @role
48-
t("admin.workflows.role_selector.label", role: @role.name)
47+
elsif @roles.one?
48+
t("admin.workflows.role_selector.label", role: @roles.first.name)
4949
else
5050
t("admin.workflows.role_selector.no_role")
5151
end
@@ -66,8 +66,6 @@ See COPYRIGHT and LICENSE files for more details.
6666
scheme: :secondary,
6767
leading_icon: :plus,
6868
label: t("admin.workflows.status_button"),
69-
# TODO: status_dialog and StatusDialogComponent currently work with a single role (@role = @roles.first);
70-
# update when they support multi-role natively.
7169
href: helpers.status_dialog_workflow_tab_path(@type, @tab, role_ids: @roles.map(&:id), status_ids: @statuses.pluck(:id).presence),
7270
data: { controller: "async-dialog" }
7371
) do
@@ -132,6 +130,6 @@ See COPYRIGHT and LICENSE files for more details.
132130
%>
133131
<% end %>
134132
<% else %>
135-
<%= render Workflows::BlankslateComponent.new(role: @role, type: @type, tab: @tab) %>
133+
<%= render Workflows::BlankslateComponent.new(roles: @roles, type: @type, tab: @tab) %>
136134
<% end %>
137135
<% end %>

app/components/workflows/status_matrix_form_component.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ def initialize(tab:, roles:, type:, available_roles:, statuses:, has_status_chan
3737
super
3838
@tab = tab
3939
@roles = roles
40-
@role = @roles.first
4140
@type = type
4241
@available_roles = available_roles
4342
@statuses = statuses

app/components/workflows/status_removal_danger_dialog_component.html.erb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@ See COPYRIGHT and LICENSE files for more details.
4646
# The reason this is done here is because the submit is not a DELETE, and GET form submissions
4747
# strip url params
4848
dialog.with_additional_details do
49-
# TODO: pass all roles once StatusRemovalDangerDialogComponent supports multi-role natively.
50-
concat(hidden_field_tag("role_ids[]", @role.id))
49+
@roles.each { |role| concat(hidden_field_tag("role_ids[]", role.id)) }
5150
@status_ids.each { |id| concat(hidden_field_tag("status_ids[]", id)) }
5251
end
5352
end

0 commit comments

Comments
 (0)