-
Notifications
You must be signed in to change notification settings - Fork 3.2k
[#74684] Extract BorderBoxListComponent
#23074
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
myabc
wants to merge
11
commits into
dev
Choose a base branch
from
implementation/74684-extract-border-box-list-component
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
39b5174
[#74684] Extract BorderBoxListComponent
myabc 96eb722
Move nested classes to OpenProject::Common
myabc 3b38e11
Add EmptyState and WorkPackageItem
myabc 99ac56e
Rewrite BorderBoxListComponent with Primer composition
myabc f36b509
Add styles for BorderBoxListComponent
myabc 2479f7a
Move WorkPackageCardListComponent to Backlogs
myabc 8c18800
Update Backlogs callers for new APIs
myabc e15dcdd
Rewrite BorderBoxListComponent specs for v2 API
myabc de4ffe3
Add WorkPackageCardListComponent specs
myabc 4102a28
Add BorderBoxListComponent Lookbook preview
myabc 78c15af
Remove old OpPrimer and WorkPackageCardList files
myabc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
119 changes: 119 additions & 0 deletions
119
app/components/open_project/common/border_box_list_component.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,119 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| #-- copyright | ||
| # OpenProject is an open source project management software. | ||
| # Copyright (C) the OpenProject GmbH | ||
| # | ||
| # This program is free software; you can redistribute it and/or | ||
| # modify it under the terms of the GNU General Public License version 3. | ||
| # | ||
| # OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: | ||
| # Copyright (C) 2006-2013 Jean-Philippe Lang | ||
| # Copyright (C) 2010-2013 the ChiliProject Team | ||
| # | ||
| # This program is free software; you can redistribute it and/or | ||
| # modify it under the terms of the GNU General Public License | ||
| # as published by the Free Software Foundation; either version 2 | ||
| # of the License, or (at your option) any later version. | ||
| # | ||
| # This program is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # GNU General Public License for more details. | ||
| # | ||
| # You should have received a copy of the GNU General Public License | ||
| # along with this program; if not, write to the Free Software | ||
| # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
| # | ||
| # See COPYRIGHT and LICENSE files for more details. | ||
| #++ | ||
|
|
||
| module OpenProject | ||
| module Common | ||
| class BorderBoxListComponent < ApplicationComponent | ||
| include OpPrimer::ComponentHelpers | ||
|
|
||
| renders_one :header, ->(**system_arguments) { | ||
| system_arguments[:list_id] ||= list_id | ||
|
|
||
| Header.new(**system_arguments) | ||
| } | ||
|
|
||
| renders_many :items, types: { | ||
| item: { | ||
| renders: ->(**system_arguments) { | ||
| Item.new(**system_arguments) | ||
| }, | ||
| as: :item | ||
| }, | ||
| work_package_item: { | ||
| renders: ->(work_package:, project: nil, params: {}, component_klass: WorkPackageItem, **item_arguments) { | ||
| project ||= work_package.project | ||
| item_arguments[:container] = container unless item_arguments.key?(:container) | ||
| item_arguments[:current_user] = current_user unless item_arguments.key?(:current_user) | ||
|
|
||
| component_klass.new( | ||
| work_package:, | ||
| project:, | ||
| params:, | ||
| **item_arguments | ||
| ) | ||
| }, | ||
| as: :work_package_item | ||
| } | ||
| } | ||
|
|
||
| renders_one :empty_state, ->(title:, description: nil, icon: nil, **system_arguments) { | ||
| EmptyState.new(title:, description:, icon:, **system_arguments) | ||
| } | ||
|
|
||
| renders_one :footer, ->(**system_arguments) { | ||
| system_arguments[:id] ||= dom_target(list_id, :footer) if list_id | ||
|
|
||
| Footer.new(**system_arguments) | ||
| } | ||
|
|
||
| attr_reader :container, :current_user | ||
|
|
||
| def initialize(container:, current_user: User.current, **system_arguments) | ||
| super() | ||
|
|
||
| @container = container | ||
| @current_user = current_user | ||
| @system_arguments = system_arguments | ||
|
|
||
| apply_container_defaults! | ||
| end | ||
|
|
||
| def before_render | ||
| content | ||
| apply_header_defaults! | ||
| end | ||
|
|
||
| def render? | ||
| header? || items.any? || empty_state? || footer? | ||
| end | ||
|
|
||
| private | ||
|
|
||
| def apply_container_defaults! | ||
| @system_arguments[:id] ||= dom_target(*Array(container)) | ||
| @system_arguments[:list_id] ||= dom_target(*Array(container), :list) | ||
| end | ||
|
|
||
| def apply_header_defaults! | ||
| return unless header? | ||
|
|
||
| header.collapsible_id = [list_id, footer_id].compact.join(" ") | ||
| end | ||
|
|
||
| def list_id | ||
| @system_arguments[:list_id] | ||
| end | ||
|
|
||
| def footer_id | ||
| footer&.id | ||
| end | ||
| end | ||
| end | ||
| end | ||
22 changes: 22 additions & 0 deletions
22
app/components/open_project/common/border_box_list_component.sass
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| //-- copyright | ||
| // OpenProject is an open source project management software. | ||
| // Copyright (C) the OpenProject GmbH | ||
| // | ||
| // This program is free software; you can redistribute it and/or | ||
| // modify it under the terms of the GNU General Public License version 3. | ||
| // | ||
| // See COPYRIGHT and LICENSE files for more details. | ||
| //++ | ||
|
|
||
| .op-border-box-list-header | ||
| display: grid | ||
| grid-template-columns: 1fr minmax(5rem, max-content) auto | ||
| grid-template-areas: "collapsible actions menu" | ||
| align-items: center | ||
|
|
||
| &--actions, | ||
| &--menu | ||
| margin-left: var(--stack-gap-normal) | ||
| align-self: flex-start | ||
| // Unfortunately, the invisible button style bites us here again. | ||
| margin-top: -6px |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.