Skip to content

Commit d36799b

Browse files
committed
[DREAM-697] Migrate resource allocations list
Renders the resource allocations list through the shared `BorderBoxListComponent` instead of a bespoke `Primer::Beta::BorderBox`, keeping the list headerless and preserving the existing per-row list item component and its arguments. The surrounding progress row and the `allocations.any?` guard are kept, so an empty allocation set still renders nothing. Adds a component spec. https://community.openproject.org/wp/DREAM-697
1 parent befea6b commit d36799b

2 files changed

Lines changed: 74 additions & 2 deletions

File tree

modules/resource_management/app/components/resource_allocations/list_component.html.erb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,13 @@ See COPYRIGHT and LICENSE files for more details.
3434
<% end %>
3535
<% if allocations.any? %>
3636
<%= body.with_row do %>
37-
<%= render(Primer::Beta::BorderBox.new) do |box| %>
37+
<%= render(
38+
OpenProject::Common::BorderBoxListComponent.new(
39+
container: "resource-allocations-#{work_package.id}"
40+
)
41+
) do |list| %>
3842
<% allocations.each do |allocation| %>
39-
<% box.with_row do %>
43+
<% list.with_item do %>
4044
<%= render ResourceAllocations::ListItemComponent.new(
4145
allocation:,
4246
project:,
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# frozen_string_literal: true
2+
3+
#-- copyright
4+
# OpenProject is an open source project management software.
5+
# Copyright (C) the OpenProject GmbH
6+
#
7+
# This program is free software; you can redistribute it and/or
8+
# modify it under the terms of the GNU General Public License version 3.
9+
#
10+
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
11+
# Copyright (C) 2006-2013 Jean-Philippe Lang
12+
# Copyright (C) 2010-2013 the ChiliProject Team
13+
#
14+
# This program is free software; you can redistribute it and/or
15+
# modify it under the terms of the GNU General Public License
16+
# as published by the Free Software Foundation; either version 2
17+
# of the License, or (at your option) any later version.
18+
#
19+
# This program is distributed in the hope that it will be useful,
20+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
21+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22+
# GNU General Public License for more details.
23+
#
24+
# You should have received a copy of the GNU General Public License
25+
# along with this program; if not, write to the Free Software
26+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
27+
#
28+
# See COPYRIGHT and LICENSE files for more details.
29+
#++
30+
31+
require "rails_helper"
32+
33+
RSpec.describe ResourceAllocations::ListComponent, type: :component do
34+
shared_let(:work_package) { create(:work_package) }
35+
shared_let(:member) { create(:user, firstname: "Sarah", lastname: "Smith") }
36+
37+
before { login_as(create(:admin)) }
38+
39+
subject(:rendered_component) do
40+
render_inline(
41+
described_class.new(
42+
project: work_package.project,
43+
work_package:,
44+
allocations:,
45+
visible_principal_ids: [member.id]
46+
)
47+
)
48+
end
49+
50+
context "with allocations" do
51+
let!(:allocation) { create(:resource_allocation, entity: work_package, principal: member) }
52+
let(:allocations) { [allocation] }
53+
54+
it_behaves_like "rendering Box", row_count: 1, header: false
55+
56+
it "renders a row per allocation" do
57+
expect(rendered_component).to have_css(".Box-row", text: "Sarah Smith")
58+
end
59+
end
60+
61+
context "without allocations" do
62+
let(:allocations) { [] }
63+
64+
it "does not render the list box" do
65+
expect(rendered_component).to have_no_css("#resource-allocations-#{work_package.id}")
66+
end
67+
end
68+
end

0 commit comments

Comments
 (0)