Skip to content

Commit 35647f7

Browse files
committed
Gate commenting behind feature flag
Register a commenting feature flag so commenting can be enabled per account or entry. The loadCommenting seed flag is only set when the feature is active, preventing commenting components from loading otherwise. REDMINE-21261
1 parent a93a338 commit 35647f7

File tree

5 files changed

+23
-6
lines changed

5 files changed

+23
-6
lines changed

entry_types/scrolled/app/controllers/pageflow_scrolled/entries_controller.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,22 @@ def show
2323
locals: {
2424
entry:,
2525
entry_mode: mode,
26-
seed_options: seed_options(mode)
26+
seed_options: seed_options(entry, mode)
2727
}
2828
)
2929
end
3030

3131
private
3232

33-
def seed_options(mode)
33+
def seed_options(entry, mode)
3434
options = {
3535
embed: get_embed_from_env,
3636
origin_url: request.original_url
3737
}
3838

39-
options[:load_commenting] = true if mode == :preview
39+
if mode == :preview && entry.feature_state('commenting')
40+
options[:load_commenting] = true
41+
end
4042

4143
options
4244
end

entry_types/scrolled/config/locales/de.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
de:
22
pageflow:
3+
commenting:
4+
feature_name: Kommentare
35
datawrapper_chart_embed_opt_in:
46
feature_name: Opt-in für Datawrapper Embeds
57
image_srcset:

entry_types/scrolled/config/locales/en.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
en:
22
pageflow:
3+
commenting:
4+
feature_name: Comments
35
datawrapper_chart_embed_opt_in:
46
feature_name: Opt-in for Datawrapper embeds
57
image_srcset:

entry_types/scrolled/lib/pageflow_scrolled/plugin.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ def configure(config)
213213
c.features.register('custom_palette_colors')
214214
c.features.register('decoration_effects')
215215
c.features.register('backdrop_size')
216+
c.features.register('commenting')
216217
c.features.register('image_srcset')
217218
c.features.enable_by_default('image_srcset')
218219

entry_types/scrolled/spec/controllers/pageflow_scrolled/entries_controller_spec.rb

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,17 +189,27 @@ module PageflowScrolled
189189
expect(response.body).to include('"originUrl":"http://test.host/test/entry"')
190190
end
191191

192-
it 'includes loadCommenting flag in preview mode' do
193-
entry = create(:entry, :published, type_name: 'scrolled')
192+
it 'includes loadCommenting flag in preview mode when feature is enabled' do
193+
entry = create(:entry, :published, type_name: 'scrolled',
194+
with_feature: 'commenting')
194195

195196
get_with_entry_env(:show, entry:, mode: :preview)
196197

197198
expect(response.body).to include('"loadCommenting":true')
198199
end
199200

200-
it 'does not include loadCommenting flag in published mode' do
201+
it 'does not include loadCommenting flag in preview mode when feature is disabled' do
201202
entry = create(:entry, :published, type_name: 'scrolled')
202203

204+
get_with_entry_env(:show, entry:, mode: :preview)
205+
206+
expect(response.body).not_to include('"loadCommenting"')
207+
end
208+
209+
it 'does not include loadCommenting flag in published mode' do
210+
entry = create(:entry, :published, type_name: 'scrolled',
211+
with_feature: 'commenting')
212+
203213
get_with_entry_env(:show, entry:)
204214

205215
expect(response.body).not_to include('"loadCommenting"')

0 commit comments

Comments
 (0)