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
4 changes: 2 additions & 2 deletions app/components/_index.sass
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
@import "open_project/common/inplace_edit_fields/index"
@import "open_project/common/submenu_component"
@import "open_project/common/main_menu_toggle_component"
@import "open_project/common/work_package_card_box_component"
@import "open_project/common/work_package_card_box_component/header"
@import "open_project/common/work_package_card_list_component"
@import "open_project/common/work_package_card_list_component/header"
@import "open_project/common/work_package_card_component"
@import "portfolios/details_component"
@import "projects/row_component"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

module OpenProject
module Common
class WorkPackageCardBoxComponent < ApplicationComponent
class WorkPackageCardListComponent < ApplicationComponent
include Primer::AttributesHelper
include OpPrimer::ComponentHelpers

Expand Down Expand Up @@ -68,12 +68,13 @@ class WorkPackageCardBoxComponent < ApplicationComponent
}

# @!parse
# # Adds a work package item row to the box. When at least one item is
# # added manually, the box does not build rows from `work_packages:`.
# # Adds a work package item row to the list. When at least one item
# # is added manually, the list does not build rows from
# # `work_packages:`.
# #
# # @param work_package [WorkPackage] the work package rendered in the row.
# # @param component_klass [Class] row bridge class used instead of the
# # default item class. Defaults to the box's configured
# # default item class. Defaults to the list's configured
# # `item_component_klass`. It must accept the arguments documented on
# # `#build_item`, expose `#row_args` with valid
# # `Primer::Beta::BorderBox#with_row` keyword arguments, and expose
Expand All @@ -88,7 +89,7 @@ class WorkPackageCardBoxComponent < ApplicationComponent
# end

# @!parse
# # Adds a custom empty item row to the box. This can be used instead of
# # Adds a custom empty item row to the list. This can be used instead of
# # the `empty_state` slot when the caller owns item iteration. It cannot
# # be combined with `work_packages:`, `with_work_package_item`, or
# # `with_item`.
Expand All @@ -99,8 +100,8 @@ class WorkPackageCardBoxComponent < ApplicationComponent
# end

# @!parse
# # Adds a generic item to the box. When at least one item is added
# # manually, the box does not build rows from `work_packages:`.
# # Adds a generic item to the list. When at least one item is added
# # manually, the list does not build rows from `work_packages:`.
# #
# # @param system_arguments [Hash] forwarded to
# # `Primer::Beta::BorderBox#with_row`.
Expand Down Expand Up @@ -140,11 +141,11 @@ class WorkPackageCardBoxComponent < ApplicationComponent
:params,
:current_user

# @param project [Project] the project this card box is rendered in. May
# @param project [Project] the project this card list is rendered in. May
# differ from individual `work_package.project` values when sprints or
# buckets are shared across projects.
# @param container [Symbol, String, Class, ApplicationRecord] drives the box
# DOM id and related ids via `dom_target`.
# @param container [Symbol, String, Class, ApplicationRecord] drives the
# list DOM id and related ids via `dom_target`.
# @param work_packages [Enumerable<WorkPackage>] the work packages to render
# as cards.
# @param drag_and_drop [Hash, NilClass] optional generic drag-and-drop
Expand Down Expand Up @@ -194,9 +195,9 @@ def before_render
validate_empty_state!
end

# Builds a new work package item without adding it to the box. Use this
# Builds a new work package item without adding it to the list. Use this
# instead of the `#with_work_package_item` slot when rendering additional
# items outside this box, such as in a separately-loaded page.
# items outside this list, such as in a separately-loaded page.
#
# @param work_package [WorkPackage] the work package rendered in the row.
# @param component_klass [Class] item class used instead of the configured
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.op-work-package-card-box
.op-work-package-card-list
&--show-more-row
border-top: var(--borderWidth-thick) solid var(--borderColor-default)
border-bottom: var(--borderWidth-thick) solid var(--borderColor-default)
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

module OpenProject
module Common
class WorkPackageCardBoxComponent
class WorkPackageCardListComponent
# Item bridge for caller-provided content.
class ContentItem < ApplicationComponent
def initialize(**system_arguments)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

module OpenProject
module Common
class WorkPackageCardBoxComponent
class WorkPackageCardListComponent
# Row bridge for caller-provided empty content.
class EmptyItem < ContentItem
include Primer::AttributesHelper
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ See COPYRIGHT and LICENSE files for more details.

++# %>

<%= grid_layout("op-work-package-card-box-header", tag: :div) do |grid| %>
<%= grid_layout("op-work-package-card-list-header", tag: :div) do |grid| %>
<% grid.with_area(:collapsible) do %>
<%=
render(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

module OpenProject
module Common
class WorkPackageCardBoxComponent
class WorkPackageCardListComponent
class Header < ApplicationComponent
include OpPrimer::ComponentHelpers

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
// See COPYRIGHT and LICENSE files for more details.
//++

.op-work-package-card-box-header
.op-work-package-card-list-header
display: grid
grid-template-columns: 1fr minmax(5rem, max-content) auto
grid-template-areas: "collapsible actions menu"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@

module OpenProject
module Common
class WorkPackageCardBoxComponent
# Internal row bridge between the card box and the visual card. It owns the
# surrounding BorderBox row arguments while `WorkPackageCardComponent`
class WorkPackageCardListComponent
# Internal row bridge between the card list and the visual card. It owns
# the surrounding BorderBox row arguments while `WorkPackageCardComponent`
# renders the card body.
class Item < ApplicationComponent
include ActionView::RecordIdentifier
Expand Down
2 changes: 1 addition & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4904,7 +4904,7 @@ en:
work_package_card_component:
menu:
label_actions: "Work package actions"
work_package_card_box_component:
work_package_card_list_component:
header:
label_actions: "Open menu"
label_work_package_count:
Comment thread
myabc marked this conversation as resolved.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
module OpenProject
module Common
# @logical_path OpenProject/Common
class WorkPackageCardBoxComponentPreview < ViewComponent::Preview
class WorkPackageCardListComponentPreview < ViewComponent::Preview
include ActionView::RecordIdentifier

def sprint_with_cards
Expand All @@ -40,16 +40,16 @@ def sprint_with_cards
return preview_message("No sprints in the database.") unless sprint && project

work_packages = sprint.work_packages_for(project).limit(3)
render OpenProject::Common::WorkPackageCardBoxComponent.new(
render OpenProject::Common::WorkPackageCardListComponent.new(
work_packages:,
project:,
container: sprint
) do |box|
box.with_header(title: sprint.name, count: work_packages.size) do |header|
) do |list|
list.with_header(title: sprint.name, count: work_packages.size) do |header|
points = work_packages.sum { |w| w.story_points || 0 }
header.with_description { "#{points} points" }
end
box.with_empty_state(title: "Sprint is empty", description: "Drag work packages here")
list.with_empty_state(title: "Sprint is empty", description: "Drag work packages here")
end
end

Expand All @@ -58,26 +58,26 @@ def empty_sprint
project = sprint&.project
return preview_message("No sprints in the database.") unless sprint && project

render OpenProject::Common::WorkPackageCardBoxComponent.new(
render OpenProject::Common::WorkPackageCardListComponent.new(
work_packages: [], project:, container: sprint
) do |box|
box.with_header(title: sprint.name, count: 0) do |header|
) do |list|
list.with_header(title: sprint.name, count: 0) do |header|
header.with_description { "0 points" }
end
box.with_empty_state(title: "Sprint is empty", description: "Drag work packages here")
list.with_empty_state(title: "Sprint is empty", description: "Drag work packages here")
end
end

def inbox
project = Project.first
return preview_message("No project in the database.") unless project

render OpenProject::Common::WorkPackageCardBoxComponent.new(
render OpenProject::Common::WorkPackageCardListComponent.new(
work_packages: [],
project:,
container: dom_target(:inbox, project)
) do |box|
box.with_empty_state(title: "Inbox is empty", description: "All caught up",
) do |list|
list.with_empty_state(title: "Inbox is empty", description: "All caught up",
icon: :"op-backlogs")
end
end
Expand All @@ -87,13 +87,13 @@ def manual_item
project = work_package&.project
return preview_message("No work packages in the database.") unless work_package && project

render OpenProject::Common::WorkPackageCardBoxComponent.new(
render OpenProject::Common::WorkPackageCardListComponent.new(
project:,
container: :manual_item_demo
) do |box|
box.with_empty_state(title: "No items", description: "Manual items can be added by callers")
box.with_work_package_item(work_package:)
box.with_item(scheme: :neutral) { "Caller-provided item" }
) do |list|
list.with_empty_state(title: "No items", description: "Manual items can be added by callers")
list.with_work_package_item(work_package:)
list.with_item(scheme: :neutral) { "Caller-provided item" }
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,21 @@ See COPYRIGHT and LICENSE files for more details.

<%= component_wrapper(tag: :section) do %>
<%= render(
OpenProject::Common::WorkPackageCardBoxComponent.new(
OpenProject::Common::WorkPackageCardListComponent.new(
work_packages:,
project:,
container: backlog_bucket,
drag_and_drop: {
target_id: "backlog_bucket:#{backlog_bucket.id}",
allowed_drag_type: "story"
},
item_component_klass: Backlogs::WorkPackageCardBoxItemComponent,
item_component_klass: Backlogs::WorkPackageCardListItemComponent,
params: all_backlogs_params,
current_user:,
data: { test_selector: "backlog-bucket-#{backlog_bucket.id}" }
)
) do |box| %>
<% box.with_header(title: backlog_bucket.name, count: work_packages.size) do |header| %>
) do |list| %>
<% list.with_header(title: backlog_bucket.name, count: work_packages.size) do |header| %>
<% if show_menu? %>
<% header.with_menu(button_aria_label: t(".label_actions")) do |menu| %>
<% with_item_group(menu) do %>
Expand All @@ -70,7 +70,7 @@ See COPYRIGHT and LICENSE files for more details.
<% end %>
<% end %>

<% box.with_empty_state(
<% list.with_empty_state(
title: t(".blankslate_title"),
description: t(".blankslate_description")
) %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,33 +29,33 @@ See COPYRIGHT and LICENSE files for more details.

<%= component_wrapper(tag: :section) do %>
<%= render(
OpenProject::Common::WorkPackageCardBoxComponent.new(
OpenProject::Common::WorkPackageCardListComponent.new(
project:,
container: dom_target(:inbox, project),
drag_and_drop: {
target_id: "inbox",
allowed_drag_type: "story"
},
item_component_klass: Backlogs::WorkPackageCardBoxItemComponent,
item_component_klass: Backlogs::WorkPackageCardListItemComponent,
params: all_backlogs_params,
current_user:,
data: { test_selector: "backlog-inbox" }
)
) do |box| %>
<% box.with_empty_state(
) do |list| %>
<% list.with_empty_state(
title: t(".blankslate_title"),
description: t(".blankslate_description"),
icon: :"op-backlogs",
spacious: true
) %>

<% visible_work_packages.each.with_index do |work_package, index| %>
<% box.with_work_package_item(work_package:) %>
<% list.with_work_package_item(work_package:) %>

<% if truncated? && index == TRUNCATE_MIDDLE - 1 %>
<% box.with_item(
<% list.with_item(
scheme: :neutral,
classes: "op-work-package-card-box--show-more-row",
classes: "op-work-package-card-list--show-more-row",
data: { draggable_id: last_omitted_id }
) do %>
<%= render(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,21 @@ See COPYRIGHT and LICENSE files for more details.

<%= component_wrapper(tag: :section) do %>
<%= render(
OpenProject::Common::WorkPackageCardBoxComponent.new(
OpenProject::Common::WorkPackageCardListComponent.new(
work_packages:,
project:,
container: sprint,
drag_and_drop: {
target_id: "sprint:#{sprint.id}",
allowed_drag_type: "story"
},
item_component_klass: Backlogs::WorkPackageCardBoxItemComponent,
item_component_klass: Backlogs::WorkPackageCardListItemComponent,
params: all_backlogs_params,
current_user:,
data: { test_selector: "sprint-#{sprint.id}" }
)
) do |box| %>
<% box.with_header(title: sprint.name, count: work_packages.size) do |header| %>
) do |list| %>
<% list.with_header(title: sprint.name, count: work_packages.size) do |header| %>
<% header.with_description do %>
<%= render(
Primer::Beta::Text.new(
Expand Down Expand Up @@ -133,7 +133,7 @@ See COPYRIGHT and LICENSE files for more details.
<% end %>
<% end %>

<% box.with_empty_state(
<% list.with_empty_state(
title: t(".blankslate_title", name: sprint.name),
description: t(".blankslate_description")
) %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#++

module Backlogs
class WorkPackageCardBoxItemComponent < OpenProject::Common::WorkPackageCardBoxComponent::Item
class WorkPackageCardListItemComponent < OpenProject::Common::WorkPackageCardListComponent::Item
def card
@card ||= WorkPackageCardComponent.new(work_package:, menu_src:)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ def render_component
expect(rendered_component).to have_css(
".Counter",
text: "1",
aria: { label: I18n.t("open_project.common.work_package_card_box_component.header.label_work_package_count", count: 1) }
aria: { label: I18n.t("open_project.common.work_package_card_list_component.header.label_work_package_count",
count: 1) }
)
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

require "rails_helper"

RSpec.describe Backlogs::WorkPackageCardBoxItemComponent, type: :component do
RSpec.describe Backlogs::WorkPackageCardListItemComponent, type: :component do
include Rails.application.routes.url_helpers

shared_let(:type_feature) { create(:type_feature) }
Expand Down
4 changes: 2 additions & 2 deletions modules/backlogs/spec/support/pages/backlog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ def expect_backlog_bucket_work_package_count(bucket, count)
expect(page).to have_css(
".Counter",
accessible_name: I18n.t(
"open_project.common.work_package_card_box_component.header.label_work_package_count",
"open_project.common.work_package_card_list_component.header.label_work_package_count",
count:
)
)
Expand Down Expand Up @@ -471,7 +471,7 @@ def expect_sprint_story_count(sprint, count)
expect(page).to have_css(
".Counter",
accessible_name: I18n.t(
"open_project.common.work_package_card_box_component.header.label_work_package_count",
"open_project.common.work_package_card_list_component.header.label_work_package_count",
count:
)
)
Expand Down
Loading
Loading