Skip to content

Commit

Permalink
DM-5363: Update defaults to 6.0 (#1142)
Browse files Browse the repository at this point in the history
* Add back 6.0 defaults for testing

* Update image attachment validation

* update breadcrumbs logic and partial to utilize inst var for image url in banner element

* remove 6.0 config defaults initializer file

* update dafault config setting from 6.0 to 6.1

* revert changes to banner img attribute interpolation

* revert config.load_defaults to 6.0 from 6.1, going to upgrade in separate branch

* add custom error message for page image content type validation

---------

Co-authored-by: Camille Villa <[email protected]>
Co-authored-by: PhilipDeFraties <[email protected]>
  • Loading branch information
3 people authored Dec 16, 2024
1 parent 032c9e0 commit 6113de9
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 15 deletions.
6 changes: 0 additions & 6 deletions app/helpers/navigation_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ def setup_breadcrumb_navigation
session[:breadcrumbs] = session[:breadcrumbs] || []
session[:heading] = nil
session[:description] = nil
session[:page_image] = nil
session[:page_image_alt_text] = nil
action = params[:action]
controller = params[:controller]

Expand Down Expand Up @@ -246,10 +244,6 @@ def add_landing_page_breadcrumb(path)
if @page.is_visible?
session[:heading] = @page.title
session[:description] = @page.description
if @page.image.present?
session[:page_image] = @page.image_s3_presigned_url(:thumb)
session[:page_image_alt_text] = @page.image_alt_text
end
end
end
end
Expand Down
8 changes: 3 additions & 5 deletions app/models/page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@ class Page < ApplicationRecord
case_sensitive: false

validates :slug, format: { with: Regexp.new('\A' + SLUG_FORMAT.source + '\z'), message: "invalid characters in URL" }
validates_attachment :image,
content_type: {
content_type: %w[image/jpg image/jpeg image/png],
message: "must be one of the following types: jpg, jpeg, or png"
}
validates_attachment_content_type :image,
content_type: ["image/jpg", "image/jpeg", "image/png"],
message: "must be one of the following types: jpg, jpeg, or png"
validates :image_alt_text,
presence: { message: "can't be blank if Page image is present" },
if: Proc.new { |page| page.image.present? }
Expand Down
4 changes: 2 additions & 2 deletions app/views/shared/_breadcrumbs.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
breadcrumbs.pop
end

page_image = session[:page_image]
alt_text = session[:page_image_alt_text]
page_image = @page.present? && @page.image.present? ? @page.image_s3_presigned_url(:thumb) : nil
alt_text = @page.present? && @page.image_alt_text.present? ? @page.image_alt_text : nil
%>

<% if @page_group&.is_community? && @page.is_subnav_page # only shown on mobile width %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/shared/_page_heading_banner.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<% if page_image.present? %>
<div class="page-image-column desktop:grid-col-5 margin-top-4 desktop:margin-y-0">
<div class="page-image-container">
<img src="<%= page_image %>" alt="<%= alt_text %>" class=""/>
<img src="<%= page_image %>" alt="<%= alt_text %>" class="page-image"/>
</div>
</div>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
module DiffusionMarketplace
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 5.2
config.load_defaults 6.0

# Settings in config/environments/* take precedence over those specified here.
# Application configuration can go into files in config/initializers
Expand Down

0 comments on commit 6113de9

Please sign in to comment.