diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d754637f..a6c8cdec 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,7 +33,7 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v3 with: - node-version: '16.14.0' + node-version: '18.18.2' - name: Setup yarn run: npm install -g yarn - name: Install Node packages @@ -41,7 +41,7 @@ jobs: - name: Install Ruby and gems uses: ruby/setup-ruby@v1 with: - ruby-version: 3.1.3 + ruby-version: 3.1.4 bundler-cache: true - name: Precompile assets run: bundle exec rails assets:precompile @@ -60,7 +60,7 @@ jobs: - name: Install Ruby and gems uses: ruby/setup-ruby@v1 with: - ruby-version: 3.1.3 + ruby-version: 3.1.4 bundler-cache: true # Add or replace any other lints here - name: Security audit dependencies diff --git a/.gitignore b/.gitignore index 6090fbef..06cce314 100644 --- a/.gitignore +++ b/.gitignore @@ -41,3 +41,6 @@ bin/terrafile bin/konduit.sh bin/fetch_config.rb .byebug_history + +/app/assets/builds/* +!/app/assets/builds/.keep diff --git a/.ruby-version b/.ruby-version index ff365e06..0aec50e6 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -3.1.3 +3.1.4 diff --git a/.tool-versions b/.tool-versions index c197f06d..d77ce18a 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1,5 +1,5 @@ -nodejs 16.14.0 -ruby 3.1.3 +nodejs 18.18.2 +ruby 3.1.4 yarn 1.22.18 bundler 2.1.4 tilt 0.33.5 diff --git a/Dockerfile b/Dockerfile index f1e81bb8..3d1e8678 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM ruby:3.1.3-alpine3.15 +FROM ruby:3.1.4-alpine ENV APP_HOME /app RUN mkdir $APP_HOME @@ -17,9 +17,6 @@ RUN apk add --update --no-cache --virtual build-dependances \ rm -rf /usr/local/bundle/cache && \ apk del build-dependances -# Remove once base image ruby:3.1.3-alpine3.15 has been updated with latest libraries -RUN apk add --no-cache ncurses-libs=6.3_p20211120-r2 - COPY package.json yarn.lock ./ RUN yarn install --frozen-lockfile && \ yarn cache clean diff --git a/Gemfile b/Gemfile index a6104ab3..32e1a575 100644 --- a/Gemfile +++ b/Gemfile @@ -3,7 +3,7 @@ source "https://rubygems.org" git_source(:github) { |repo| "https://github.com/#{repo}.git" } -ruby "3.1.3" +ruby "3.1.4" gem "bootsnap", require: false gem "foreman" @@ -14,7 +14,6 @@ gem "puma", "~> 6.4" gem "rails", "~> 7.0.8" gem "sprockets-rails" gem "tzinfo-data", platforms: %i[mingw mswin x64_mingw jruby] -gem "webpacker" gem "pagy" gem "scenic" @@ -83,3 +82,7 @@ gem "sidekiq", "~> 6.5" gem "sidekiq-cron", "~> 1.10" gem "mail-notify", "~> 1.1" + +gem "dartsass-rails", "~> 0.5.0" + +gem "importmap-rails", "~> 1.2" diff --git a/Gemfile.lock b/Gemfile.lock index 0253b236..7ad12716 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -105,6 +105,9 @@ GEM dry-validation (~> 1.0, >= 1.0.0) connection_pool (2.4.1) crass (1.0.6) + dartsass-rails (0.5.0) + railties (>= 6.0.0) + sass-embedded (~> 1.63) date (3.3.3) debug (1.8.0) irb (>= 1.5.0) @@ -188,6 +191,7 @@ GEM raabro (~> 1.4) globalid (1.2.1) activesupport (>= 6.1) + google-protobuf (3.24.4) govuk-components (4.1.1) html-attributes-utils (~> 1.0.0, >= 1.0.0) pagy (~> 6.0) @@ -205,6 +209,9 @@ GEM multi_xml (>= 0.5.2) i18n (1.14.1) concurrent-ruby (~> 1.0) + importmap-rails (1.2.1) + actionpack (>= 6.0.0) + railties (>= 6.0.0) invisible_captcha (2.1.0) rails (>= 5.2) io-console (0.6.0) @@ -295,8 +302,6 @@ GEM rack (2.2.8) rack-protection (3.1.0) rack (~> 2.2, >= 2.2.4) - rack-proxy (0.7.6) - rack rack-test (2.1.0) rack (>= 1.3) rails (7.0.8) @@ -398,10 +403,12 @@ GEM sanitize (6.1.0) crass (~> 1.0.2) nokogiri (>= 1.12.0) + sass-embedded (1.69.3) + google-protobuf (~> 3.23) + rake (>= 13.0.0) scenic (1.7.0) activerecord (>= 4.0.0) railties (>= 4.0.0) - semantic_range (3.0.0) sentry-rails (5.12.0) railties (>= 5.0) sentry-ruby (~> 5.12.0) @@ -451,11 +458,6 @@ GEM activemodel (>= 6.0.0) bindex (>= 0.4.0) railties (>= 6.0.0) - webpacker (5.4.4) - activesupport (>= 5.2) - rack-proxy (>= 0.6.1) - railties (>= 5.2) - semantic_range (>= 2.3.0) websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) @@ -475,6 +477,7 @@ DEPENDENCIES bundler-audit capybara config (~> 4.2) + dartsass-rails (~> 0.5.0) debug devise (~> 4.9) dotenv-rails @@ -487,6 +490,7 @@ DEPENDENCIES govuk-components (= 4.1.1) govuk_design_system_formbuilder httparty (~> 0.21) + importmap-rails (~> 1.2) invisible_captcha jbuilder launchy @@ -516,10 +520,9 @@ DEPENDENCIES tzinfo-data uk_postcode web-console - webpacker RUBY VERSION - ruby 3.1.3p185 + ruby 3.1.4p223 BUNDLED WITH 2.1.4 diff --git a/Procfile.dev b/Procfile.dev index 57445a02..3243bac9 100644 --- a/Procfile.dev +++ b/Procfile.dev @@ -1,2 +1,2 @@ web: bin/rails server -p $PORT -webpack: bin/webpack-dev-server \ No newline at end of file +sass: bin/rails dartsass:watch diff --git a/app/assets/builds/.keep b/app/assets/builds/.keep new file mode 100644 index 00000000..e69de29b diff --git a/app/assets/config/manifest.js b/app/assets/config/manifest.js index 59181933..e3dbe384 100644 --- a/app/assets/config/manifest.js +++ b/app/assets/config/manifest.js @@ -1,2 +1,5 @@ //= link_tree ../images -//= link_directory ../stylesheets .css +//= link_tree ../builds +//= link_tree ../../javascript .js +//= link_tree ../../../vendor/javascript .js +//= link_tree ../../../node_modules diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss new file mode 100644 index 00000000..219c2c51 --- /dev/null +++ b/app/assets/stylesheets/application.scss @@ -0,0 +1,3 @@ +// Sassy +@import 'govuk-frontend/govuk/all'; +@import 'custom'; diff --git a/app/assets/stylesheets/custom.scss b/app/assets/stylesheets/custom.scss new file mode 100644 index 00000000..46279d85 --- /dev/null +++ b/app/assets/stylesheets/custom.scss @@ -0,0 +1,138 @@ +.dashboard { + display: grid; + grid-template-columns: 1fr 1fr 1fr; + grid-gap: 20px; /* Adjust this for your desired gap between columns */ +} + +.kpi-widget { + background-color: #1d70b8; + border-radius: 5px; + padding: 15px; + text-align: center; + + .title { + font-size: 28px; + font-weight: bold; + color: #fff; + margin: 0; + padding: 0; + } + + .subtitle { + font-size: 17px; + font-weight: bold; + color: #fff; + margin: 0; + padding: 0; + } + + .value { + font-size: 70px; + font-weight: bold; + color: #fff; + display: block; + padding: 0; + margin: 0; + } + + .value-small { + font-size: 24px; + font-weight: bold; + color: #fff; + display: block; + padding: 0; + margin: 0; + } + .value-smallest { + font-size: 20px; + font-weight: bold; + color: #fff; + display: block; + padding: 0; + margin: 0; + } + + .kpi-table { + margin-top: 20px; + margin-bottom: 20px; + width: 100%; + text-align: left; + color: #fff; + + th { + font-weight: bold; + padding: 5px; + } + + td { + padding: 5px; + font-size: 20px; + } + + a { + color: #fff; + text-decoration: none; + } + } +} + +.applicants-table { + font-size: 15px; + + .govuk-table__head { + position: sticky; + top: 0; + background-color: #fff; + box-shadow: 0 0.3px 0 #b1b4b6; + } + + th { + vertical-align: middle; + text-align: center; + } + + td:not(:nth-child(-n + 2)) { + width: 120px; + } + td { + vertical-align: middle; + } + tr.sla-breached { + background-color: #f8d7da; + } +} + +.flash { + padding: 15px; + margin-bottom: 20px; + border: 1px solid transparent; + border-radius: 4px; + width: 100%; + font-size: 1.2em; + + &.notice { + color: #155724; + background-color: #d4edda; + border-color: #c3e6cb; + } + + &.alert { + color: #721c24; + background-color: #f8d7da; + border-color: #f5c6cb; + } +} + +#search { + .row { + display: flex; + } + + .column { + flex: 1; + } + + .full-width { + width: 100%; + } +} diff --git a/app/javascript/application.js b/app/javascript/application.js new file mode 100644 index 00000000..38cfd337 --- /dev/null +++ b/app/javascript/application.js @@ -0,0 +1,4 @@ +// Configure your import map in config/importmap.rb. Read more: https://github.com/rails/importmap-rails +import { initAll } from "govuk-frontend" + +initAll(); diff --git a/app/views/layouts/admin.html.erb b/app/views/layouts/admin.html.erb index ddfa7c4d..55b7347c 100644 --- a/app/views/layouts/admin.html.erb +++ b/app/views/layouts/admin.html.erb @@ -13,16 +13,15 @@ - - - - - - - - <%= stylesheet_pack_tag 'govuk', 'data-turbolinks-track': 'reload' %> - - <%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %> + + + + + + + <%= stylesheet_link_tag 'application', 'data-turbolinks-track': 'reload' %> + + <%= javascript_importmap_tags %> @@ -56,8 +55,6 @@ "Help" => "#", "Cookies" => "#", "Contact" => "#", "Terms and Conditions" => "#" }) %> - - <%= javascript_pack_tag 'govuk', 'data-turbolinks-track': 'reload' %> diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index b342dd65..13a6d98e 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -13,18 +13,18 @@ - - - - - - + + + + + + - <%= stylesheet_pack_tag 'govuk', 'data-turbolinks-track': 'reload' %> + <%= stylesheet_link_tag 'application', 'data-turbolinks-track': 'reload' %> - <%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %> + <%= javascript_importmap_tags %> - + @@ -55,8 +55,6 @@ "Help" => "#", "Cookies" => "#", "Contact" => "#", "Terms and Conditions" => "#", "Privacy" => privacy_path }) %> - - <%= javascript_pack_tag 'govuk', 'data-turbolinks-track': 'reload' %> diff --git a/bin/dev b/bin/dev new file mode 100755 index 00000000..74ade166 --- /dev/null +++ b/bin/dev @@ -0,0 +1,8 @@ +#!/usr/bin/env sh + +if ! gem list foreman -i --silent; then + echo "Installing foreman..." + gem install foreman +fi + +exec foreman start -f Procfile.dev "$@" diff --git a/bin/importmap b/bin/importmap new file mode 100755 index 00000000..36502ab1 --- /dev/null +++ b/bin/importmap @@ -0,0 +1,4 @@ +#!/usr/bin/env ruby + +require_relative "../config/application" +require "importmap/commands" diff --git a/config/application.rb b/config/application.rb index 2948f757..8942567c 100644 --- a/config/application.rb +++ b/config/application.rb @@ -25,6 +25,8 @@ class Application < Rails::Application # Initialize configuration defaults for originally generated Rails version. config.load_defaults(7.0) + config.assets.paths << Rails.root.join("node_modules") + config.assets.paths << Rails.root.join("node_modules/govuk-frontend/govuk/assets") config.autoload_paths << Rails.root.join("app/services") # Configuration for the application, engines, and railties goes here. diff --git a/config/importmap.rb b/config/importmap.rb new file mode 100644 index 00000000..2cf75c08 --- /dev/null +++ b/config/importmap.rb @@ -0,0 +1,4 @@ +# Pin npm packages by running ./bin/importmap + +pin "application", preload: true +pin "govuk-frontend", to: "https://ga.jspm.io/npm:govuk-frontend@4.7.0/govuk-esm/all.mjs", preload: true diff --git a/db/schema.rb b/db/schema.rb index e7f52481..2e38062f 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,6 @@ # # It's strongly recommended that you check this file into your version control system. - ActiveRecord::Schema[7.0].define(version: 2023_10_03_024901) do # These are extensions that must be enabled in order to support this database enable_extension "citext" diff --git a/package.json b/package.json index 105710a5..91f6810c 100644 --- a/package.json +++ b/package.json @@ -1,31 +1,6 @@ { - "engines": { - "node": "16.x" - }, - "scripts": { - "js:lint": "standard --fix", - "test": "jest", - "test:ci": "jest --ci --runInBand --coverage" - }, "dependencies": { - "@ministryofjustice/frontend": "^1.8.0", - "@rails/webpacker": "5.4.4", - "core-js": "^3.33.0", - "govuk-frontend": "^4.7.0", - "rails-ujs": "^5.2.8", - "turbolinks": "^5.2.0", - "webpack": "^4.46.0", - "webpack-cli": "^4.10.0" - }, - "devDependencies": { - "jest": "^29.7.0", - "standard": "^17.1.0", - "webpack-dev-server": "^4" - }, - "standard": { - "env": [ - "jest" - ] - }, + "govuk-frontend": "^4.7.0" + }, "license": "MIT" } diff --git a/vendor/javascript/.keep b/vendor/javascript/.keep new file mode 100644 index 00000000..e69de29b