Skip to content

Commit

Permalink
Add update service page for both claims and placements
Browse files Browse the repository at this point in the history
  • Loading branch information
gms-gs committed Dec 20, 2023
1 parent 0c33b6b commit b2f15ee
Show file tree
Hide file tree
Showing 17 changed files with 277 additions and 37 deletions.
38 changes: 19 additions & 19 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: 20.9.0
cache: 'npm'
cache: "npm"
- name: Install dependencies
run: |
sudo apt-get update && sudo apt-get -yqq install libpq-dev
bundle install --jobs 4 --retry 3
bundle exec rails assets:precompile
env:
DATABASE_URL: postgres://postgres:password@localhost:5432
GOVUK_NOTIFY_API_KEY: fake_key
SIGN_IN_METHOD: persona
DATABASE_URL: postgres://postgres:password@localhost:5432
GOVUK_NOTIFY_API_KEY: fake_key
SIGN_IN_METHOD: persona
- name: ${{ matrix.tests }}
run: ${{ env.COMMAND }}
env:
Expand All @@ -52,16 +52,16 @@ jobs:
name: Test
runs-on: ubuntu-latest
services:
postgres:
image: postgres:16
env:
POSTGRES_PASSWORD: password
ports: ['5432:5432']
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
postgres:
image: postgres:16
env:
POSTGRES_PASSWORD: password
ports: ["5432:5432"]
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
strategy:
fail-fast: false
steps:
Expand All @@ -77,16 +77,16 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: 20.9.0
cache: 'npm'
cache: "npm"
- name: Install dependencies
run: |
sudo apt-get update && sudo apt-get -yqq install libpq-dev
bundle install --jobs 4 --retry 3
bundle exec rails assets:precompile
env:
DATABASE_URL: postgres://postgres:password@localhost:5432
GOVUK_NOTIFY_API_KEY: fake_key
SIGN_IN_METHOD: persona
DATABASE_URL: postgres://postgres:password@localhost:5432
GOVUK_NOTIFY_API_KEY: fake_key
SIGN_IN_METHOD: persona
- name: Run Tests
env:
RAILS_ENV: test
Expand All @@ -98,4 +98,4 @@ jobs:
run: |
bundle exec rake db:create
bundle exec rails db:schema:load
bundle exec rspec --format progress
bundle exec rspec --format progress
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ gem "bootsnap", require: false
# gem 'image_processing', '~> 1.2'

gem "flipflop"
gem "redcarpet", "~> 3.6"

gem "govuk-components"
gem "govuk_design_system_formbuilder", "~> 5.0.0"
Expand Down
31 changes: 17 additions & 14 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ GEM
minitest (>= 5.1)
mutex_m
tzinfo (~> 2.0)
addressable (2.8.5)
addressable (2.8.6)
public_suffix (>= 2.0.2, < 6.0)
aes_key_wrap (1.1.0)
annotate (3.2.0)
Expand Down Expand Up @@ -165,16 +165,16 @@ GEM
terminal-table (>= 1.8)
globalid (1.2.1)
activesupport (>= 6.1)
govuk-components (4.1.2)
govuk-components (5.0.0)
html-attributes-utils (~> 1.0.0, >= 1.0.0)
pagy (~> 6.0)
view_component (>= 3.3, < 3.7)
view_component (>= 3.3, < 3.8)
govuk_design_system_formbuilder (5.0.0)
actionview (>= 6.1)
activemodel (>= 6.1)
activesupport (>= 6.1)
html-attributes-utils (~> 1)
haml (6.2.3)
haml (6.3.0)
temple (>= 0.8.2)
thor
tilt
Expand All @@ -183,7 +183,7 @@ GEM
activesupport (>= 6.1.4.4)
i18n (1.14.1)
concurrent-ruby (~> 1.0)
io-console (0.7.0)
io-console (0.6.0)
irb (1.10.1)
rdoc
reline (>= 0.3.8)
Expand Down Expand Up @@ -225,7 +225,7 @@ GEM
minitest (5.20.0)
msgpack (1.7.2)
mutex_m (0.2.0)
net-imap (0.4.7)
net-imap (0.4.8)
date
net-protocol
net-pop (0.1.2)
Expand All @@ -235,7 +235,7 @@ GEM
net-smtp (0.4.0)
net-protocol
nio4r (2.7.0)
nokogiri (1.15.5-arm64-darwin)
nokogiri (1.15.5-x86_64-darwin)
racc (~> 1.4)
nokogiri (1.15.5-x86_64-linux)
racc (~> 1.4)
Expand Down Expand Up @@ -290,7 +290,7 @@ GEM
puma (6.4.0)
nio4r (~> 2.0)
racc (1.7.3)
rack (2.2.8)
rack (3.0.8)
rack-oauth2 (2.2.0)
activesupport
attr_required
Expand All @@ -300,13 +300,13 @@ GEM
rack (>= 2.1.0)
rack-protection (3.0.6)
rack
rack-session (1.0.2)
rack (< 3)
rack-session (2.0.0)
rack (>= 3.0.0)
rack-test (2.1.0)
rack (>= 1.3)
rackup (1.0.0)
rack (< 3)
webrick
rackup (2.1.0)
rack (>= 3)
webrick (~> 1.8)
rails (7.1.2)
actioncable (= 7.1.2)
actionmailbox (= 7.1.2)
Expand Down Expand Up @@ -350,6 +350,7 @@ GEM
rbs (2.8.4)
rdoc (6.6.1)
psych (>= 4.0.0)
redcarpet (3.6.0)
regexp_parser (2.8.3)
reline (0.4.1)
io-console (~> 0.5)
Expand Down Expand Up @@ -475,7 +476,7 @@ GEM
validate_url (1.0.15)
activemodel (>= 3.0.0)
public_suffix
view_component (3.6.0)
view_component (3.7.0)
activesupport (>= 5.2.0, < 8.0)
concurrent-ruby (~> 1.0)
method_source (~> 1.0)
Expand All @@ -501,6 +502,7 @@ GEM
PLATFORMS
arm64-darwin-22
arm64-darwin-23
x86_64-darwin-22
x86_64-linux

DEPENDENCIES
Expand Down Expand Up @@ -533,6 +535,7 @@ DEPENDENCIES
rails (~> 7.1.2)
rails-controller-testing
rails-erd
redcarpet (~> 3.6)
rladr
rspec
rspec-rails
Expand Down
5 changes: 5 additions & 0 deletions app/assets/components/service_update/view.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<section id="<%= service_update.id %>">
<%= title_element %>
<p class="govuk-body govuk-!-margin-bottom-2"><%= date_pretty %></p>
<div class="govuk-body"><%= content_html %></div>
</section>
26 changes: 26 additions & 0 deletions app/assets/components/service_update/view.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
class ServiceUpdate::View < GovukComponent::Base
attr_reader :service_update

delegate :title, :content, :date, to: :service_update

TITLE_CLASS = "govuk-heading-m govuk-!-margin-bottom-2"

def initialize(service_update:)
@service_update = service_update
end

def title_element
tag.h2(title, class: TITLE_CLASS)
end

def date_pretty
date.to_date.strftime("%e %B %Y")
end

def content_html
custom_render =
Redcarpet::Render::HTML.new(link_attributes: { class: "govuk-link" })
markdown = Redcarpet::Markdown.new(custom_render)
markdown.render(content).html_safe
end
end
10 changes: 10 additions & 0 deletions app/controllers/service_updates_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# frozen_string_literal: true

class ServiceUpdatesController < ApplicationController
include ApplicationHelper

def index
@service_name ||= current_service
@service_updates = ServiceUpdate.where(service: @service_name)
end
end
30 changes: 30 additions & 0 deletions app/models/service_update.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
class ServiceUpdate
CLAIMS_SERVICE_UPDATES_YAML_FILE =
Rails.root.join("db/claims_service_updates.yml").freeze
PLACEMENTS_SERVICE_UPDATES_YAML_FILE =
Rails.root.join("db/placements_service_updates.yml").freeze

include ActiveModel::Model

attr_accessor :date, :title, :content

def id
title.parameterize
end

def self.where(service:)
path = file_path(service:)
updates = YAML.load_file(path) || []

updates.map { |service_update| new(service_update) }
end

def self.file_path(service:)
case service
when :claims
CLAIMS_SERVICE_UPDATES_YAML_FILE
when :placements
PLACEMENTS_SERVICE_UPDATES_YAML_FILE
end
end
end
17 changes: 17 additions & 0 deletions app/views/service_updates/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds-from-desktop">
<h1 class="govuk-heading-xl"><%= t("service_updates.#{@service_name}.heading") %></h1>

<h2 class="govuk-heading-m"><%= t("service_updates.contents") %></h2>
<ul class="govuk-list app-list--dash govuk-!-margin-bottom-8 govuk-!-margin-left-3">
<% @service_updates.each do |service_update| %>
<li><a class="govuk-link" href="#<%= service_update.id %>"><%= service_update.title %></a></li>
<% end %>
</ul>

<% @service_updates.each do |service_update| %>
<hr class="govuk-section-break govuk-section-break--l govuk-section-break--visible">
<%= render ServiceUpdate::View.new(service_update:) %>
<% end %>
</div>
</div>
1 change: 1 addition & 0 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class Application < Rails::Application
"node_modules/govuk-frontend/govuk/assets"
)

config.autoload_paths += %W[#{config.root}/app/assets/components]
config.exceptions_app = routes
end
end
6 changes: 6 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,9 @@ en:
roles_include: "%{persona_name}’s role includes:"
sign_in_as: "Sign In as %{persona_name}"
title: Test users
service_updates:
claims:
heading: Claims news and updates
placements:
heading: Placements news and updates
contents: Contents
2 changes: 2 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
get("/auth/developer/sign-out", to: "sessions#signout")
post("/auth/developer/callback", to: "sessions#callback")

resources :service_updates, only: %i[index]

draw :placements
draw :claims
end
6 changes: 5 additions & 1 deletion config/routes/placements.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
scope module: :placements, as: :placements, constraints: { host: ENV["PLACEMENTS_HOST"] } do
scope module: :placements,
as: :placements,
constraints: {
host: ENV["PLACEMENTS_HOST"]
} do
root to: "pages#index"
end
11 changes: 11 additions & 0 deletions db/claims_service_updates.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Example structure for adding service updates

# - date:
# type: String
# format: YYYY-MM-DD
# title:
# type: String
# format: Short text
# content:
# type: String
# format: Multi-line text
11 changes: 11 additions & 0 deletions db/placements_service_updates.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Example structure for adding service updates

# - date:
# type: String
# format: YYYY-MM-DD
# title:
# type: String
# format: Plain text
# content:
# type: String
# format: Multi-line text
Loading

0 comments on commit b2f15ee

Please sign in to comment.