Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ See COPYRIGHT and LICENSE files for more details.

<%= component_wrapper(tag: :section) do %>
<%= render(Primer::Beta::BorderBox.new(**@system_arguments)) do |border_box| %>
<% border_box.with_header do %>
<% border_box.with_header(id: dom_target(sprint, :header)) do %>
<%= render(Backlogs::SprintHeaderComponent.new(sprint:, folded: folded?)) %>
<% end %>
<% if stories.empty? %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ See COPYRIGHT and LICENSE files for more details.
++# %>

<%=
render(Primer::Alpha::ActionMenu.new(anchor_align: :end, classes: "hide-when-print")) do |menu|
render(Primer::Alpha::ActionMenu.new(**@system_arguments)) do |menu|
menu.with_show_button(
scheme: :invisible,
icon: :"kebab-horizontal",
Expand All @@ -38,6 +38,7 @@ See COPYRIGHT and LICENSE files for more details.

if user_allowed?(:create_sprints)
menu.with_item(
id: dom_target(sprint, :menu, :edit_sprint),
label: t(".action_menu.edit_sprint"),
href: edit_dialog_project_sprint_path(project, sprint),
content_arguments: { data: { controller: "async-dialog" } }
Expand All @@ -48,6 +49,7 @@ See COPYRIGHT and LICENSE files for more details.

if user_allowed?(:manage_sprint_items)
menu.with_item(
id: dom_target(sprint, :menu, :new_story),
label: t(".action_menu.new_story"),
href: new_project_work_packages_dialog_path(
project,
Expand All @@ -66,6 +68,7 @@ See COPYRIGHT and LICENSE files for more details.

menu.with_item(
# TODO: sprint_id filter does not exist for work packages. Add?
id: dom_target(sprint, :menu, :stories_tasks),
scheme: :danger,
label: t(".action_menu.stories_tasks"),
tag: :a,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,20 @@ class SprintMenuComponent < ApplicationComponent

attr_reader :sprint, :project, :current_user

def initialize(sprint:, project:, current_user: User.current)
def initialize(sprint:, project:, current_user: User.current, **system_arguments)
super()

@sprint = sprint
@project = project
@current_user = current_user

@system_arguments = system_arguments
@system_arguments[:menu_id] = dom_target(sprint, :menu)
@system_arguments[:anchor_align] = :end
@system_arguments[:classes] = class_names(
@system_arguments[:classes],
"hide-when-print"
)
end

def stories
Expand Down
5 changes: 4 additions & 1 deletion modules/backlogs/app/controllers/rb_sprints_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,10 @@ def update_header_component_via_turbo_stream(state: :show)
end

def update_sprint_header_component_via_turbo_stream(sprint:)
update_via_turbo_stream(component: Backlogs::SprintHeaderComponent.new(sprint:))
update_via_turbo_stream(
component: Backlogs::SprintHeaderComponent.new(sprint:),
method: :morph
)
end

def update_new_sprint_form_component_via_turbo_stream(sprint:, base_errors: nil)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ def render_component
expect(page).to have_css(".Box-header h3", text: "Sprint 1")
end

it "renders a stable id on the sprint header" do
render_component

expect(page).to have_element(:div, class: "Box-header", id: /\Aagile_sprint_#{sprint.id}_header\z/)
end

it "renders StoryComponent for each story" do
render_component

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,12 @@ def render_component(folded: false)

expect(page).to have_css("action-menu")
end

it "renders a stable id on the sprint menu trigger" do
render_component

expect(page).to have_element(:button, id: /\Aagile_sprint_#{sprint.id}_menu-button\z/)
end
end

context "with no stories" do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,14 @@ def render_component
describe "always-visible items" do
let(:permissions) { [:view_sprints] }

it "renders stable ids on the action menu and stories/tasks item" do
render_component

expect(page).to have_element(:button, id: /\Aagile_sprint_#{sprint.id}_menu-button\z/)
expect(page).to have_element(:ul, id: /\Aagile_sprint_#{sprint.id}_menu-list\z/)
expect(page).to have_element(:a, id: /\Aagile_sprint_#{sprint.id}_menu_stories_tasks\z/)
end

it "shows Stories/Tasks link" do
render_component

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,8 @@
expect(response).to be_successful
expect(response).to have_http_status :ok
expect(response.body).to have_turbo_stream action: "flash"
expect(response.body).to have_turbo_stream action: "update", target: "backlogs-sprint-header-component-#{sprint.id}"
assert_select %(turbo-stream[action="update"][target="backlogs-sprint-header-component-#{sprint.id}"][method="morph"])
expect(response.body).to include("Successful update.")
expect(sprint.reload.name).to eq("Changed sprint name")
end
Expand Down
Loading