Skip to content

Commit 973911a

Browse files
author
Ben Crouse
committed
Merge branch 'v3.5-stable'
2 parents 3e488ab + 11e340c commit 973911a

32 files changed

+458
-267
lines changed

CHANGELOG.md

+83
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,86 @@
1+
Workarea 3.5.25 (2020-12-23)
2+
--------------------------------------------------------------------------------
3+
4+
* Fix admin indexing for embedded model changes
5+
6+
When embedded models are changed, their root documents weren't being
7+
reindexed for admin search. This PR ensures admin indexing happens
8+
correctly.
9+
10+
Ben Crouse
11+
12+
* Index search customizations, handle missing search models for changeset releasables
13+
14+
WORKAREA-322
15+
16+
Matt Duffy
17+
18+
* Move release undo changeset building to sidekiq for large changesets
19+
20+
WORKAREA-316
21+
22+
Matt Duffy
23+
24+
* Fix undo releases not causing models to reindex
25+
26+
Because the changeset is the only getting saved when building an undo,
27+
admin reindexing for the affected models isn't happening. This change
28+
triggers callbacks to ensure any related side-effects happen.
29+
30+
Ben Crouse
31+
32+
* Use inline_svg fallback for missing releasable icons
33+
34+
WORKAREA-310
35+
36+
Matt Duffy
37+
38+
* Simplify undo releases, allow multiple undo releases from a single release
39+
40+
WORKAREA-316
41+
42+
Matt Duffy
43+
44+
* Update display of release changeset to handle large changesets
45+
46+
WORKAREA-310
47+
48+
Matt Duffy
49+
50+
* Allow admin config array fields to define a values type
51+
52+
WORKAREA-311
53+
54+
Matt Duffy
55+
56+
* Check if a releasable has a localized active field before redefining it
57+
58+
If Workarea.config.localized_active_field is set to false, the active
59+
field is redefined for each Releasable model to ensure the configuration
60+
is honored. With inherited models like discounts, this can cause the
61+
redefintion of active multiple times causing it to override custom active
62+
behaviors for segments. Only redefining the method if its currently in
63+
the models localized_fields list should ensure this does not happen.
64+
65+
WORKAREA-309
66+
67+
Matt Duffy
68+
69+
* Update releasable active test to work without localized active fields
70+
71+
WORKAREA-309
72+
73+
Matt Duffy
74+
75+
76+
77+
Workarea 3.5.24 (2020-12-22)
78+
--------------------------------------------------------------------------------
79+
80+
Due to a mistake releasing this gem, it has been yanked. See v3.5.25 instead.
81+
82+
83+
184
Workarea 3.5.23 (2020-11-25)
285
--------------------------------------------------------------------------------
386

admin/app/controllers/workarea/admin/create_release_undos_controller.rb

+19-5
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,20 @@ def create
1313
@undo_release.attributes = params[:release]
1414

1515
if @undo_release.save
16-
@release.changesets.each do |changeset|
17-
changeset.build_undo(release: @undo_release.model).save!
16+
@release.changesets.limit(Workarea.config.per_page).each do |changeset|
17+
if changeset.releasable.present?
18+
changeset.build_undo(release: @undo_release.model).save!
19+
changeset.releasable.run_callbacks(:save)
20+
end
1821
end
1922

23+
BuildReleaseUndoChangesets.perform_async(
24+
@undo_release.id,
25+
@release.id
26+
) if @release.changeset_count > Workarea.config.per_page
27+
2028
flash[:success] = t('workarea.admin.create_release_undos.flash_messages.saved')
21-
redirect_to review_release_undo_path(@release)
29+
redirect_to review_release_undo_path(@release, @undo_release)
2230
else
2331
render :new, status: :unprocessable_entity
2432
end
@@ -35,8 +43,14 @@ def find_release
3543
end
3644

3745
def find_undo_release
38-
model = @release.model.undo || @release.build_undo(params[:release])
39-
@undo_release = ReleaseViewModel.new(model, view_model_options)
46+
model =
47+
if params[:id].present?
48+
@release.model.undos.find(params[:id])
49+
else
50+
@release.build_undo
51+
end
52+
53+
@undo_release = ReleaseViewModel.wrap(model, view_model_options)
4054
end
4155
end
4256
end

admin/app/controllers/workarea/admin/releases_controller.rb

+1-4
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,6 @@ def update
4343
end
4444
end
4545

46-
def original
47-
end
48-
4946
def publish
5047
self.current_release = nil
5148
PublishRelease.perform_async(@release.id)
@@ -59,7 +56,7 @@ def destroy
5956
@release.destroy
6057

6158
flash[:success] = t('workarea.admin.releases.flash_messages.removed')
62-
redirect_to releases_path
59+
redirect_back_or releases_path
6360
end
6461

6562
def calendar_feed

admin/app/helpers/workarea/admin/changesets_helper.rb

+15-7
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,30 @@ module Workarea
22
module Admin::ChangesetsHelper
33
def changeset_icon(changeset, options = {})
44
type = changeset.root.model_name.element
5-
inline_svg_tag(releasable_icon_path(type), options)
5+
6+
inline_svg_tag(
7+
releasable_icon_path(type),
8+
options.reverse_merge(fallback: default_releasable_icon_path)
9+
)
610
end
711

812
def releaseable_icon(model, options = {})
913
type = model.model_name.element
10-
inline_svg(releasable_icon_path(type), options)
14+
inline_svg_tag(
15+
releasable_icon_path(type),
16+
options.reverse_merge(fallback: default_releasable_icon_path)
17+
)
1118
end
1219

1320
def releasable_icon_path(type)
14-
default = 'workarea/admin/icons/release.svg'
15-
return default unless type.present?
21+
return default_releasable_icon_path unless type.present?
1622

17-
path = Workarea.config.releasable_icons[type.to_sym] ||
18-
"workarea/admin/icons/#{type}.svg"
23+
Workarea.config.releasable_icons[type.to_sym] ||
24+
"workarea/admin/icons/#{type}.svg"
25+
end
1926

20-
Rails.application.assets.find_asset(path).present? ? path : default
27+
def default_releasable_icon_path
28+
'workarea/admin/icons/release.svg'
2129
end
2230
end
2331
end

admin/app/view_models/workarea/admin/changeset_summary_view_model.rb

+11-1
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,28 @@ def type
1212
end
1313

1414
def type_filter
15-
Search::Admin.for(model_class.new).type
15+
search_model&.type || model_name.param_key
1616
end
1717

1818
def label
1919
type_filter.titleize.pluralize(count)
2020
end
2121

22+
def searchable?
23+
search_model.present?
24+
end
25+
2226
private
2327

2428
def model_class
2529
@model_class ||= type.constantize
2630
end
31+
32+
def search_model
33+
return @search_model if defined?(@serch_model)
34+
35+
@search_model = Search::Admin.for(model_class.new)
36+
end
2737
end
2838
end
2939
end

admin/app/view_models/workarea/admin/release_view_model.rb

+6-3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ def changeset_count
1111
@changeset_count ||= model.changesets.count
1212
end
1313

14+
def additional_changesets_count
15+
[changeset_count - Workarea.config.per_page, 0].max
16+
end
17+
1418
def show_changeset_summary?
1519
changeset_count > Workarea.config.per_page
1620
end
@@ -39,9 +43,8 @@ def calendar_on
3943
calendar_at&.to_date
4044
end
4145

42-
def undo
43-
return unless undo?
44-
@undo ||= ReleaseViewModel.wrap(model.undo, options)
46+
def undos
47+
@undos ||= ReleaseViewModel.wrap(model.undos, options)
4548
end
4649

4750
def undoes

admin/app/views/workarea/admin/changesets/index.html.haml

+11-5
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,16 @@
3030
.grid.grid--center.grid--auto
3131
- @release.changeset_summary.each do |summary|
3232
.grid__cell
33-
.card.card--button
34-
= link_to search_path(type: [summary.type_filter], upcoming_changes: [@release.id]), class: 'card__header' do
35-
.card__header-text #{summary.count} #{summary.label}
36-
= releaseable_icon summary, { class: 'card__icon'}
33+
- if summary.searchable?
34+
.card.card--button
35+
= link_to search_path(type: [summary.type_filter], upcoming_changes: [@release.id]), class: 'card__header' do
36+
.card__header-text #{summary.count} #{summary.label}
37+
= releaseable_icon summary, { class: 'card__icon'}
38+
- else
39+
.card
40+
.card__header
41+
.card__header-text #{summary.count} #{summary.label}
42+
= releaseable_icon summary, { class: 'card__icon'}
3743

3844
.grid__cell.grid__cell--80-at-medium
3945
%h2.align-center= t('workarea.admin.changesets.recent')
@@ -64,4 +70,4 @@
6470

6571
- if @release.show_changeset_summary?
6672
%li.text.text--large.align-center
67-
= link_to t('workarea.admin.cards.more', amount: @release.changeset_count - Workarea.config.per_page ), search_path(upcoming_changes: [@release.id])
73+
= link_to t('workarea.admin.cards.more', amount: @release.additional_changesets_count ), search_path(upcoming_changes: [@release.id])

admin/app/views/workarea/admin/create_release_undos/new.html.haml

+6-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
- @undo_release.errors.full_messages.each do |message|
1010
= render_message 'error', message
1111

12-
= form_tag release_undo_path(@release), method: 'post' do
12+
= form_tag release_undos_path(@release), method: 'post' do
1313
.section
1414
.property.property--required
1515
= label_tag 'release_name', t('workarea.admin.fields.name'), class: 'property__name'
@@ -26,12 +26,15 @@
2626
.grid__cell.grid__cell--50-at-medium
2727
.property
2828
= label_tag 'release_publish_at', t('workarea.admin.fields.undo_at'), class: 'property__name'
29-
.box.box--rounded= hidden_field_tag 'release[publish_at]', @undo_release.publish_at, data: { datetimepicker_field: { inline: true } }
29+
.box.box--rounded= hidden_field_tag 'release[publish_at]', @undo_release.publish_at, data: { datetimepicker_field: { inline: true, uiOptions: { minDate: (@release.publish_at.present? ? @release.publish_at.to_s(:date_only) : 0) } } }
3030

3131
.workflow-bar
3232
.grid.grid--middle
3333
.grid__cell.grid__cell--20
34-
= link_to t('workarea.admin.form.cancel'), undo_release_path(@release), class: 'workflow-bar__button workflow-bar__button--delete'
34+
- if @undo_release.persisted?
35+
= link_to t('workarea.admin.form.cancel'), release_path(@undo_release, return_to: release_path(@release)), class: 'workflow-bar__button workflow-bar__button--delete', data: { method: 'delete', confirm: t('workarea.admin.create_release_undos.workflow.delete_confirmation') }
36+
- else
37+
= link_to t('workarea.admin.form.cancel'), release_path(@release), class: 'workflow-bar__button workflow-bar__button--delete'
3538

3639
.grid__cell.grid__cell--60
3740
%ol.workflow-bar__steps

admin/app/views/workarea/admin/create_release_undos/review.html.haml

+8-2
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,21 @@
3434
- changeset.changed_fields.each do |field|
3535
= render_changeset_field(changeset, field)
3636

37+
- if @release.show_changeset_summary?
38+
%li.text.text--large.align-center
39+
= t('workarea.admin.cards.more', amount: @release.additional_changesets_count )
40+
41+
%p= t('workarea.admin.create_release_undos.review.change_count_message')
42+
3743
.workflow-bar
3844
.grid.grid--middle
3945
.grid__cell.grid__cell--20
40-
= link_to t('workarea.admin.form.cancel'), release_path(@undo_release), class: 'workflow-bar__button workflow-bar__button--delete', data: { method: 'delete', confirm: t('workarea.admin.create_release_undos.workflow.delete_confirmation') }
46+
= link_to t('workarea.admin.form.cancel'), release_path(@undo_release, return_to: release_path(@release)), class: 'workflow-bar__button workflow-bar__button--delete', data: { method: 'delete', confirm: t('workarea.admin.create_release_undos.workflow.delete_confirmation') }
4147

4248
.grid__cell.grid__cell--60
4349
%ol.workflow-bar__steps
4450
%li.workflow-bar__step
45-
1) #{link_to t('workarea.admin.create_release_undos.workflow.setup'), new_release_undo_path(@release)}
51+
1) #{link_to t('workarea.admin.create_release_undos.workflow.setup'), new_release_undo_path(@release, id: @undo_release.id)}
4652
%li.workflow-bar__step
4753
%strong 2) #{t('workarea.admin.create_release_undos.workflow.review')}
4854

admin/app/views/workarea/admin/releases/_cards.html.haml

-50
Original file line numberDiff line numberDiff line change
@@ -78,55 +78,5 @@
7878
= link_to release_changesets_path(model), class: 'card__button' do
7979
%span.button.button--small= t('workarea.admin.releases.cards.planned_changes.button')
8080

81-
.grid__cell
82-
- if model.undoes?
83-
.card{ class: card_classes(:original, local_assigns[:active]) }
84-
= link_to original_release_path(model), class: 'card__header' do
85-
%span.card__header-text= t('workarea.admin.releases.cards.original.title')
86-
= inline_svg_tag 'workarea/admin/icons/planned_changes.svg', class: 'card__icon'
87-
88-
- if local_assigns[:active].blank?
89-
.card__body
90-
.card__empty-note
91-
%p= t('workarea.admin.releases.cards.original.undoes_html', link: link_to(model.undoes.name, release_path(model.undoes)))
92-
93-
- if model.undoes.publish_at.present? && model.undoes.publish_at.future?
94-
%p= t('workarea.admin.releases.cards.undo.set_to_publish_html', link: link_to(model.undoes.name, release_path(model.undoes)), at: local_time_ago(model.undoes.publish_at))
95-
- elsif model.undoes.published_at.present?
96-
%p= t('workarea.admin.releases.cards.undo.published_html', link: link_to(model.undoes.name, release_path(model.undoes)), at: local_time_ago(model.undoes.published_at))
97-
- else
98-
%p= t('workarea.admin.releases.cards.undo.unscheduled_html', link: link_to(model.undoes.name, release_path(model.undoes)))
99-
100-
= link_to original_release_path(model), class: 'card__button' do
101-
%span.button.button--small= t('workarea.admin.releases.cards.original.learn_more')
102-
103-
- else
104-
.card{ class: card_classes(:undo, local_assigns[:active]) }
105-
= link_to undo_release_path(model), class: 'card__header' do
106-
%span.card__header-text= t('workarea.admin.releases.cards.undo.title')
107-
= inline_svg_tag 'workarea/admin/icons/planned_changes.svg', class: 'card__icon'
108-
109-
- if local_assigns[:active].blank?
110-
.card__body
111-
.card__empty-note
112-
- if model.undo.blank?
113-
%p= t('workarea.admin.releases.cards.undo.not_setup')
114-
115-
= link_to undo_release_path(model), class: 'card__button' do
116-
%span.button.button--small= t('workarea.admin.releases.cards.undo.build_an_undo')
117-
118-
- else
119-
%p= t('workarea.admin.releases.cards.undo.undo_html', link: link_to(model.undo.name, release_path(model.undo)), at: local_time_ago(model.undo.created_at))
120-
121-
- if model.undo.publish_at.present? && model.undo.publish_at.future?
122-
%p= t('workarea.admin.releases.cards.undo.set_to_publish_html', link: link_to(model.undo.name, release_path(model.undo)), at: local_time_ago(model.undo.publish_at))
123-
- elsif model.undo.published_at.present?
124-
%p= t('workarea.admin.releases.cards.undo.published_html', link: link_to(model.undo.name, release_path(model.undo)), at: local_time_ago(model.undo.published_at))
125-
- else
126-
%p= t('workarea.admin.releases.cards.undo.unscheduled_html', link: link_to(model.undo.name, release_path(model.undo)))
127-
128-
= link_to undo_release_path(model), class: 'card__button' do
129-
%span.button.button--small= t('workarea.admin.releases.cards.undo.learn_more')
130-
13181
.grid__cell
13282
= render 'workarea/admin/comments/card', commentable: model, active: local_assigns[:active]

0 commit comments

Comments
 (0)