view_component 3.3.0 → 3.4.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of view_component might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/docs/CHANGELOG.md +10 -0
- data/lib/view_component/config.rb +8 -0
- data/lib/view_component/engine.rb +8 -1
- data/lib/view_component/instrumentation.rb +9 -1
- data/lib/view_component/preview.rb +1 -1
- data/lib/view_component/test_helpers.rb +8 -0
- data/lib/view_component/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fda2b08a3a0e713feb6e1fc6c1fef238f886cc4ab1ddd23e3d181bda02ad9c27
|
4
|
+
data.tar.gz: e405fabfc3f12543caf45207f7222fdb9efcf9963dad10d3d37e47c131427e8b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a8be926941021f58d66f8b8c29893e5bd682426483914f16f431783c2e230029755e137a434f535fd081f51d3d9a63c219174ce68af9202f8f5f42f0f7087bd
|
7
|
+
data.tar.gz: 4da3a061e16a87cc13440b4c1bf621da4d34a0b2443f28c34a132df0f4a85822b9f9ba12bea9b85c950e8b7991553c85a130eee75e1d7c84865feb30f66f17b5
|
data/docs/CHANGELOG.md
CHANGED
@@ -10,6 +10,16 @@ nav_order: 5
|
|
10
10
|
|
11
11
|
## main
|
12
12
|
|
13
|
+
## 3.4.0
|
14
|
+
|
15
|
+
* Avoid including Rails `url_helpers` into `Preview` class when they're not defined.
|
16
|
+
|
17
|
+
*Richard Macklin*
|
18
|
+
|
19
|
+
* Allow instrumentation to be automatically included in Server-Timing headers generated by Rails. To enable this set the config `config.use_deprecated_instrumentation_name = false`. The old key `!render.view_component` is deprecated: update ActiveSupport::Notification subscriptions to `render.view_component`.
|
20
|
+
|
21
|
+
*Travis Gaff*
|
22
|
+
|
13
23
|
## 3.3.0
|
14
24
|
|
15
25
|
* Include InlineTemplate by default in Base. **Note:** It's no longer necessary to include `ViewComponent::InlineTemplate` to use inline templates.
|
@@ -17,6 +17,7 @@ module ViewComponent
|
|
17
17
|
preview_route: "/rails/view_components",
|
18
18
|
show_previews_source: false,
|
19
19
|
instrumentation_enabled: false,
|
20
|
+
use_deprecated_instrumentation_name: true,
|
20
21
|
render_monkey_patch_enabled: true,
|
21
22
|
view_component_path: "app/components",
|
22
23
|
component_parent_class: nil,
|
@@ -99,6 +100,13 @@ module ViewComponent
|
|
99
100
|
# Whether ActiveSupport notifications are enabled.
|
100
101
|
# Defaults to `false`.
|
101
102
|
|
103
|
+
# @!attribute use_deprecated_instrumentation_name
|
104
|
+
# @return [Boolean]
|
105
|
+
# Whether ActiveSupport Notifications use the private name `"!render.view_component"`
|
106
|
+
# or are made more publicly available via `"render.view_component"`.
|
107
|
+
# Will default to `false` in next major version.
|
108
|
+
# Defaults to `true`.
|
109
|
+
|
102
110
|
# @!attribute render_monkey_patch_enabled
|
103
111
|
# @return [Boolean] Whether the #render method should be monkey patched.
|
104
112
|
# If this is disabled, use `#render_component` or
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require "rails"
|
4
4
|
require "view_component/config"
|
5
|
+
require "view_component/deprecation"
|
5
6
|
|
6
7
|
module ViewComponent
|
7
8
|
class Engine < Rails::Engine # :nodoc:
|
@@ -39,8 +40,14 @@ module ViewComponent
|
|
39
40
|
Base.config = app.config.view_component
|
40
41
|
|
41
42
|
if app.config.view_component.instrumentation_enabled.present?
|
42
|
-
# :nocov:
|
43
|
+
# :nocov: Re-executing the below in tests duplicates initializers and causes order-dependent failures.
|
43
44
|
ViewComponent::Base.prepend(ViewComponent::Instrumentation)
|
45
|
+
if app.config.view_component.use_deprecated_instrumentation_name
|
46
|
+
ViewComponent::Deprecation.deprecation_warning(
|
47
|
+
"!render.view_component",
|
48
|
+
"Use the new instrumentation key `render.view_component` instead. See https://viewcomponent.org/guide/instrumentation.html"
|
49
|
+
)
|
50
|
+
end
|
44
51
|
# :nocov:
|
45
52
|
end
|
46
53
|
end
|
@@ -10,7 +10,7 @@ module ViewComponent # :nodoc:
|
|
10
10
|
|
11
11
|
def render_in(view_context, &block)
|
12
12
|
ActiveSupport::Notifications.instrument(
|
13
|
-
|
13
|
+
notification_name,
|
14
14
|
{
|
15
15
|
name: self.class.name,
|
16
16
|
identifier: self.class.identifier
|
@@ -19,5 +19,13 @@ module ViewComponent # :nodoc:
|
|
19
19
|
super(view_context, &block)
|
20
20
|
end
|
21
21
|
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def notification_name
|
26
|
+
return "!render.view_component" if ViewComponent::Base.config.use_deprecated_instrumentation_name
|
27
|
+
|
28
|
+
"render.view_component"
|
29
|
+
end
|
22
30
|
end
|
23
31
|
end
|
@@ -4,7 +4,7 @@ require "active_support/descendants_tracker"
|
|
4
4
|
|
5
5
|
module ViewComponent # :nodoc:
|
6
6
|
class Preview
|
7
|
-
include Rails.application.routes.url_helpers
|
7
|
+
include Rails.application.routes.url_helpers if defined?(Rails.application.routes.url_helpers)
|
8
8
|
include ActionView::Helpers::TagHelper
|
9
9
|
include ActionView::Helpers::AssetTagHelper
|
10
10
|
extend ActiveSupport::DescendantsTracker
|
@@ -155,6 +155,14 @@ module ViewComponent
|
|
155
155
|
# end
|
156
156
|
# ```
|
157
157
|
#
|
158
|
+
# To use a specific host, pass the host param:
|
159
|
+
#
|
160
|
+
# ```ruby
|
161
|
+
# with_request_url("/users/42", host: "app.example.com") do
|
162
|
+
# render_inline(MyComponent.new)
|
163
|
+
# end
|
164
|
+
# ```
|
165
|
+
#
|
158
166
|
# @param path [String] The path to set for the current request.
|
159
167
|
# @param host [String] The host to set for the current request.
|
160
168
|
def with_request_url(path, host: nil)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: view_component
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ViewComponent Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-07-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|