Skip to content

Commit

Permalink
Removed Beta Banner from PDC Discovery (#749)
Browse files Browse the repository at this point in the history
* commented out and removed data from yml file

* readded all environments in banner.yml except production

* left blank production values in banner.yml

* Added a test. Tweaked the logic in the helper a little bit.

Co-authored-by: Claudia Lee <claudiawulee@users.noreply.github.com>

* Update Circle CI browser-tools

* Shot in the dark

* Shot in the dark part 2

* Shot in the dark part 3

* Shot in the dark part 4

* Shot in the dark part 5 - using version posted today, fingers crossed

---------

Co-authored-by: Hector Correa <hector_correa@princeton.edu>
Co-authored-by: Claudia Lee <claudiawulee@users.noreply.github.com>
  • Loading branch information
3 people authored Feb 4, 2025
1 parent 591b9d6 commit 71a361b
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
version: 2.1

orbs:
browser-tools: circleci/browser-tools@1.4.4
browser-tools: circleci/browser-tools@1.5.1
coveralls: coveralls/coveralls@2.2.1

executors:
Expand Down
11 changes: 8 additions & 3 deletions app/helpers/banner_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,14 @@ module BannerHelper
# rubocop:disable Rails/ContentTag
def banner_content
@yaml_data = YAML.load_file('config/banner.yml')
return false if @yaml_data[Rails.env].nil?
@banner_title = "<h1>#{@yaml_data[Rails.env]['title']}</h1>"
@banner_body = "<p>#{@yaml_data[Rails.env]['body']}</p>"
return false if @yaml_data.nil? || @yaml_data[Rails.env].nil?

title = @yaml_data[Rails.env]['title']
body = @yaml_data[Rails.env]['body']
return false if title.nil? && body.nil?

@banner_title = "<h1>#{title}</h1>"
@banner_body = "<p>#{body}</p>"
end
# rubocop:enable Rails/ContentTag
end
4 changes: 2 additions & 2 deletions config/banner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ staging:
title: Welcome to Princeton Data Commons Discovery! (Staging)
body: Have a look around our new website for the discovery and sharing of research data and <a href="mailto:prds@princeton.edu"> let us know what you think</a>. See our <a href="https://researchdata.princeton.edu/research-lifecycle-guide/getting-started-princeton-data-commons-describe-contributor" target="_blank"> Getting Started as a Princeton Data Commons Contributor</a> guide for instructions on how to publish your research data and code.
production:
title: Welcome to Princeton Data Commons Discovery!
body: Have a look around our new website for the discovery and sharing of research data and <a href="mailto:prds@princeton.edu"> let us know what you think</a>. See <a href="https://datacommons.princeton.edu/describe/" target="_blank">How to Submit</a> for instructions on how to publish your research data and code.
title:
body:
7 changes: 7 additions & 0 deletions spec/system/banner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,11 @@
expect(page.find("div#banner p b").text).to eq "test"
expect(page).to have_link "message", href: "mailto:fake@princeton.edu"
end

it "does not render a banner when there are no values in the configuration for the environment" do
Rails.env = "not-an-environment"
visit '/'
expect(page).not_to have_css '#banner'
Rails.env = "test"
end
end

0 comments on commit 71a361b

Please sign in to comment.