Skip to content

Commit 8b57c8c

Browse files
committed
Merge branch 'bump/primer-upstream-ref' into bump/primer-upstream
2 parents 6f02a78 + 45024b8 commit 8b57c8c

20 files changed

Lines changed: 300 additions & 26 deletions

.changeset/odd-planes-stop.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@openproject/primer-view-components': minor
3+
---
4+
5+
Create IncludeFragment component. Allow ConditionalWrapper to render components other than BaseComponent

.changeset/pink-items-stand.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@openproject/primer-view-components': patch
3+
---
4+
5+
Create IncludeFragment linter to migrate <include-fragment> uses

Gemfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ end
2828
# rubocop:enable Bundler/DuplicatedGem
2929

3030
# Use Puma as the app server
31-
gem "puma", "~> 6.4.2"
31+
gem "puma", "~> 6.6.0"
3232

3333
# Reduces boot times through caching; required in config/boot.rb
3434
gem "bootsnap", ">= 1.4.2", require: false
@@ -64,7 +64,7 @@ group :development do
6464
gem "rubocop-performance"
6565
gem "rubocop-rails"
6666
gem "rubocop-rails-accessibility", "~> 1.0"
67-
gem "selenium-webdriver", "~> 4.18"
67+
gem "selenium-webdriver", "~> 4.31"
6868
gem "simplecov", "~> 0.22.0"
6969
gem "simplecov-console", "~> 0.9.1"
7070
gem "sprockets"

Gemfile.lock

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ GEM
5757
parser (>= 2.4)
5858
smart_properties
5959
bigdecimal (3.1.9)
60-
bootsnap (1.18.3)
60+
bootsnap (1.18.4)
6161
msgpack (~> 1.2)
6262
builder (3.3.0)
6363
capybara (3.40.0)
@@ -77,7 +77,7 @@ GEM
7777
crass (1.0.6)
7878
css_parser (1.21.1)
7979
addressable
80-
cssbundling-rails (1.4.1)
80+
cssbundling-rails (1.4.3)
8181
railties (>= 6.0.0)
8282
cuprite (0.15)
8383
capybara (~> 3.0)
@@ -145,9 +145,9 @@ GEM
145145
minitest (5.25.5)
146146
mocha (2.3.0)
147147
ruby2_keywords (>= 0.0.5)
148-
msgpack (1.7.2)
148+
msgpack (1.8.0)
149149
mutex_m (0.3.0)
150-
nio4r (2.7.3)
150+
nio4r (2.7.4)
151151
nokogiri (1.18.7)
152152
mini_portile2 (~> 2.8.2)
153153
racc (~> 1.4)
@@ -165,10 +165,10 @@ GEM
165165
date
166166
stringio
167167
public_suffix (5.0.5)
168-
puma (6.4.2)
168+
puma (6.6.0)
169169
nio4r (~> 2.0)
170170
racc (1.8.1)
171-
rack (3.1.12)
171+
rack (3.1.13)
172172
rack-cors (2.0.2)
173173
rack (>= 2.0.0)
174174
rack-proxy (0.7.7)
@@ -206,7 +206,7 @@ GEM
206206
regexp_parser (2.9.2)
207207
reline (0.6.1)
208208
io-console (~> 0.5)
209-
rexml (3.3.7)
209+
rexml (3.4.1)
210210
rouge (4.5.1)
211211
rubocop (1.66.1)
212212
json (~> 2.3)
@@ -236,10 +236,11 @@ GEM
236236
rubocop (>= 1.0.0)
237237
ruby-progressbar (1.13.0)
238238
ruby2_keywords (0.0.5)
239-
rubyzip (2.3.2)
239+
rubyzip (2.4.1)
240240
securerandom (0.4.1)
241-
selenium-webdriver (4.20.1)
241+
selenium-webdriver (4.31.0)
242242
base64 (~> 0.2)
243+
logger (~> 1.4)
243244
rexml (~> 3.2, >= 3.2.5)
244245
rubyzip (>= 1.2.2, < 3.0)
245246
websocket (~> 1.0)
@@ -290,7 +291,7 @@ GEM
290291
crack (>= 0.3.2)
291292
hashdiff (>= 0.4.0, < 2.0.0)
292293
webrick (1.9.1)
293-
websocket (1.2.10)
294+
websocket (1.2.11)
294295
websocket-driver (0.7.6)
295296
websocket-extensions (>= 0.1.0)
296297
websocket-extensions (0.1.5)
@@ -323,7 +324,7 @@ DEPENDENCIES
323324
matrix (~> 0.4.2)
324325
mocha
325326
openproject-primer_view_components!
326-
puma (~> 6.4.2)
327+
puma (~> 6.6.0)
327328
rack-cors
328329
railties (= 8.0.2)
329330
rake (~> 13.2)
@@ -332,7 +333,7 @@ DEPENDENCIES
332333
rubocop-performance
333334
rubocop-rails
334335
rubocop-rails-accessibility (~> 1.0)
335-
selenium-webdriver (~> 4.18)
336+
selenium-webdriver (~> 4.31)
336337
simplecov (~> 0.22.0)
337338
simplecov-console (~> 0.9.1)
338339
sourcemap (~> 0.1)

app/components/primer/alpha/action_menu.html.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<%= render(@overlay) do |overlay| %>
44
<% overlay.with_body(padding: :none) do %>
55
<% if @src.present? %>
6-
<include-fragment src="<%= @src %>" loading="<%= preload? ? "eager" : "lazy" %>" data-target="action-menu.includeFragment">
6+
<%= render(Primer::Alpha::IncludeFragment.new(src: @src, loading: preload? ? :eager : :lazy, "data-target": "action-menu.includeFragment")) do %>
77
<%= render(Primer::Alpha::ActionMenu::List.new(id: "#{@menu_id}-list", menu_id: @menu_id)) do |list| %>
88
<% list.with_item(
99
aria: { disabled: true },
@@ -18,7 +18,7 @@
1818
<%= render Primer::Beta::Spinner.new(aria: { label: "Loading content..." }) %>
1919
<% end %>
2020
<% end %>
21-
</include-fragment>
21+
<% end %>
2222
<% else %>
2323
<%= render(@list) %>
2424
<% end %>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# frozen_string_literal: true
2+
3+
module Primer
4+
module Alpha
5+
# Use `IncludeFragment` to load HTML elements from the server.
6+
# Add additional usage considerations or best practices that may aid the user to use the component correctly.
7+
# @accessibility Add any accessibility considerations
8+
class IncludeFragment < Primer::Component
9+
status :alpha
10+
11+
# @param src [String] The URL from which to retrieve an HTML element fragment.
12+
# @param loading [Symbol] <%= one_of([:lazy, :eager]) %>
13+
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
14+
def initialize(src: nil, loading: :eager, **system_arguments)
15+
@system_arguments = system_arguments
16+
@system_arguments[:tag] = "include-fragment"
17+
@system_arguments[:loading] = loading
18+
@system_arguments[:src] = src
19+
end
20+
21+
def call
22+
render(Primer::BaseComponent.new(**@system_arguments)) { content }
23+
end
24+
end
25+
end
26+
end

app/components/primer/alpha/select_panel.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
)) do %>
6363
<div id="<%= @body_id %>">
6464
<% if @src.present? %>
65-
<%= render(Primer::ConditionalWrapper.new(condition: @fetch_strategy == :eventually_local, tag: "include-fragment", data: { target: "select-panel.includeFragment" }, src: @src, loading: preload? ? "eager" : "lazy", accept: "text/fragment+html")) do %>
65+
<%= render(Primer::ConditionalWrapper.new(condition: @fetch_strategy == :eventually_local, component: Primer::Alpha::IncludeFragment, data: { target: "select-panel.includeFragment" }, src: @src, loading: preload? ? "eager" : "lazy", accept: "text/fragment+html")) do %>
6666
<%= render(Primer::BaseComponent.new(
6767
tag: :div,
6868
id: "#{@panel_id}-list",
Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
# frozen_string_literal: true
22

33
module Primer
4-
# Conditionally renders a `Primer::BaseComponent` around the given content. If the given condition
5-
# is true, a `Primer::BaseComponent` will render around the content. If the condition is false, only
4+
# Conditionally renders a component around the given content. If the given condition
5+
# is true, the component will render around the content. If the condition is false, only
66
# the content is rendered.
77
class ConditionalWrapper < Primer::Component
8-
# @param condition [Boolean] Whether or not to wrap the content in a `Primer::BaseComponent`.
9-
# @param base_component_arguments [Hash] The arguments to pass to `Primer::BaseComponent`.
10-
def initialize(condition:, **base_component_arguments)
8+
# @param condition [Boolean] Whether or not to wrap the content in a component.
9+
# @param component [Class] The component class to use as a wrapper, defaults to `Primer::BaseComponent`
10+
# @param base_component_arguments [Hash] The arguments to pass to the component.
11+
def initialize(condition:, component: Primer::BaseComponent, **base_component_arguments)
1112
@condition = condition
13+
@component = component
1214
@base_component_arguments = base_component_arguments
1315
@trim = !!@base_component_arguments.delete(:trim)
1416
end
@@ -18,7 +20,7 @@ def call
1820
return @trim ? trimmed_content : content
1921
end
2022

21-
BaseComponent.new(trim: @trim, **@base_component_arguments).render_in(self) { content }
23+
@component.new(trim: @trim, **@base_component_arguments).render_in(self) { content }
2224
end
2325
end
2426
end
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# frozen_string_literal: true
2+
3+
# :nodoc:
4+
class IncludeFragmentController < ApplicationController
5+
layout false
6+
7+
def landing; end
8+
9+
def deferred
10+
render "include_fragment/deferred"
11+
end
12+
end
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<div>
2+
Hello world!
3+
</div>

0 commit comments

Comments
 (0)