Workarea 3.0.7

Fixes Scheduled Jobs for Removed/Renamed Workers

#2536

Workarea 3.0.7 modifies the workarea-core/config/initializers/05_scheduled_jobs.rb initializer to remove Sidekiq cron jobs that reference workers that were previously removed or renamed.

The change removes cron jobs for the Workarea::UpdateDashboards and Workarea::Admin::StatusReporter workers and adds a job for the Workarea::StatusReporter worker.

After upgrading, the removed jobs may still exist within Sidekiq as retried or scheduled jobs and will raise exceptions when Sidekiq tries to run them. You must manually clear these jobs from Sidekiq within each environment.

Fixes Styling of Validation Messages in Storefront

#2566, #2572, e03d11b2e0f

validation message in Storefront

Prior to 3.0.7, client-side validation messages in the Storefront are unstyled because the class value expected by the stylesheet, value__error, isn't present in the DOM. The class value is missing in these versions because the value component was dropped from the Admin in Workarea 3.0, and the Admin and Storefront share client-side validation behavior, which was updated to match the Admin for Workarea 3.0.

To fix this issue, Workarea 3.0.7 removes the shared validation behavior from Core and adds validation behavior to the Admin and Storefront engines directly. The changes are summarized below.

If your application is overriding any of the above assets, update your copies as needed to fix validation styling in the Storefront.

Improves UI for Backordered Until Field

#2567

Workarea 3.0.7 modifies the workarea/admin/inventory_skus/new.html.haml and workarea/admin/bulk_action_product_edits/edit.html.haml Admin views, adding a data-datepicker-field attribute to the backordered_until field (named Backorder Ship Date in the English translation of the Admin). This change provides a calendar UI for this field when focused.

calendar for backordered until field

This change also modifies the workarea/admin/inventory_skus/_cards.html.haml Admin partial to output a backordered_until value for an inventory SKU when present.

backordered until output on inventory sku card

If your application is overriding any of these views, apply the changes manually to benefit from these improvements.

Fixes Display of Admin Filters when Wrapping

#2568

Workarea 3.0.7 modifies the workarea/admin/components/_browsing_controls.scss Admin stylesheet to fix the display of Admin filters when they wrap to a second line.

filters wrapping to second line in Admin

If your application is overriding this stylesheet, you'll need to apply this patch manually to your copy.

Fixes Duplicate ID Values in Admin Content Editing HTML

#2544

Workarea 3.0.7 modifies the following Admin partials to fix duplicate ID values in the HTML rendered for the content editing page.

If your application is overriding either of these partials, you should apply this patch manually to your copies of the files.

Adds Append Points

#2533, #2534

Workarea 3.0.7 adds the following append point to the Admin.

admin.user_properties within workarea/admin/users/edit.html.haml

And adds the following append point to the Storefront.

storefront.style_guide_components.property within workarea/storefront/style_guides/components/_property.html.haml

If your application is overriding either of the above views/partials, you may want to add these append points to your copies so that plugins can take advantage of these extension points.

Stores Relative Paths for Product Images in Elasticsearch

#2561

Prior to 3.0.7, Workarea stores absolute URLs for product images in Elasticsearch. Workarea 3.0.7 uses relative paths instead, which avoids the need to re-index when moving data between environments.

The PR changes the Core query Workarea::ProductPrimaryImageUrl. It modifies the implementation of Workarea::ProductPrimaryImageUrl#url and adds Workarea::ProductPrimaryImageUrl#image (extracted from #url) and Workarea::ProductPrimaryImageUrl#path.

The change also modifies the Core helper Workarea::ApplicationHelper. It edits the implementation of Workarea::ApplicationHelper#product_image_url and adds Workarea::ApplicationHelper#product_image_path (extracted from #product_image_url).

Furthermore, the change modifies the search model method Workarea::Search::Storefront::Product#primary_image.

In the Storefront, the PR changes the view model Workarea::Storefront::SearchSuggestionViewModel. It modifies the implementation of Workarea::Storefront::SearchSuggestionViewModel#image, adds Workarea::Storefront::SearchSuggestionViewModel#asset_host, and also makes the following methods public.

Finally, the change adds a new view model test case, Workarea::Storefront::SearchSuggestionViewModelTest.

If your application is extending any of the methods affected by this change, you should review the PR and update your application code accordingly to benefit from this change.

Changes Uniqueness Strategy for Workers

7064a5eed91

Workarea 3.0.7 modifies the following workers to use the until_executing uniqueness strategy for unique jobs. In earlier versions, these workers use the until_and_while_executing strategy, which can reportedly lead to race conditions that cause workers to not be enqueued.

If your application is extending the worker options on any of the above workers, you may want to apply this change to your application code to avoid workers not being enqueued.

Improves Performance of Indexing Category Changes

175f5260b8f

Workarea 3.0.7 modifies the Workarea::IndexCategoryChanges worker to improve performance. The change adds an ignore_if option to the worker, and modifies the implementation of Workarea::IndexCategoryChanges#perform.

If your application is extending this worker, you may want to update your application code to ensure you are benefiting from this performance improvement.

Adds Caching for Default Category of a Product

e4b85c1fa4a

Workarea 3.0.7 modifies Workarea::Categorization query, adding a cache within Workarea::Categorization#default_model to resolve performance issues reported by systems integrators.

# workarea-core/app/queries/workarea/categorization.rb

module Workarea
  class Categorization
    # ...

    def default_model
      key = "#{@product.cache_key}/default_category"

      @default_model ||= Rails.cache.fetch(key, expires_in: 1.day) do
        to_models.sort_by(&:created_at).first
      end
    end

    # ...
  end
end

If your application is extending this method, ensure your implementation does not conflict with these changes.

Fixes Tax Price Adjustment Amount

#2553

Workarea::Pricing::TaxApplier#assign_item_tax is responsible for writing a price adjustment that adjusts tax to a shipping. Prior to 3.0.7, the amount of that adjustment is incorrect under certain conditions (order affected by multiple tax codes and a discount). Workarea 3.0.7 applies the following changes to fix the issue.

If your application is extending the tax applier, update your implementation accordingly to fix this issue.

Adds Argument for Wait for XHR Timeout Threshold

#2552

Workarea 3.0.7 modifies Workarea::SystemTest#wait_for_xhr, allowing the maximum wait time to be passed as an argument.

# workarea-testing/lib/workarea/system_test.rb
# ...

module Workarea
  class SystemTest < IntegrationTest
    # ...

    def wait_for_xhr(time=Capybara.default_max_wait_time)
      Timeout.timeout(time) do
        loop until finished_all_xhr_requests?
      end
    end

    # ...
  end
end

Use this argument to call the method with an arbitrary timeout threshold that differs from the configured default.