From cc1e5dc0369ade39daf539179cf36f089accc60d Mon Sep 17 00:00:00 2001 From: Trevor Vallender Date: Sun, 4 Feb 2024 14:16:19 +0000 Subject: [PATCH] Updates and feature flags --- Gemfile | 1 + Gemfile.lock | 188 ++++++++++-------- app/javascript/application.js | 1 + app/javascript/controllers/application.js | 9 + app/javascript/controllers/index.js | 11 + config/importmap.rb | 3 + .../20240126101316_create_feature_flags.rb | 10 + db/schema.rb | 10 +- 8 files changed, 144 insertions(+), 89 deletions(-) create mode 100644 app/javascript/controllers/application.js create mode 100644 app/javascript/controllers/index.js create mode 100644 db/migrate/20240126101316_create_feature_flags.rb diff --git a/Gemfile b/Gemfile index 943a923..5becb98 100644 --- a/Gemfile +++ b/Gemfile @@ -13,6 +13,7 @@ gem "stimulus-rails" gem "jbuilder" gem "bcrypt", "~> 3.1.7" gem "bootsnap", require: false +gem "flaggle_rock", git: "https://git.tsvallender.co.uk/tsv/flaggle_rock" gem "kaminari" # Pagination gem "solid_cache" diff --git a/Gemfile.lock b/Gemfile.lock index 7eca6d3..5ff20f7 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,70 +1,77 @@ +GIT + remote: https://git.tsvallender.co.uk/tsv/flaggle_rock + revision: 63d7337228f04a2cb9d743e3ca0115aaca9619fe + specs: + flaggle_rock (0.1.1) + GEM remote: https://rubygems.org/ specs: - actioncable (7.1.1) - actionpack (= 7.1.1) - activesupport (= 7.1.1) + actioncable (7.1.3) + actionpack (= 7.1.3) + activesupport (= 7.1.3) nio4r (~> 2.0) websocket-driver (>= 0.6.1) zeitwerk (~> 2.6) - actionmailbox (7.1.1) - actionpack (= 7.1.1) - activejob (= 7.1.1) - activerecord (= 7.1.1) - activestorage (= 7.1.1) - activesupport (= 7.1.1) + actionmailbox (7.1.3) + actionpack (= 7.1.3) + activejob (= 7.1.3) + activerecord (= 7.1.3) + activestorage (= 7.1.3) + activesupport (= 7.1.3) mail (>= 2.7.1) net-imap net-pop net-smtp - actionmailer (7.1.1) - actionpack (= 7.1.1) - actionview (= 7.1.1) - activejob (= 7.1.1) - activesupport (= 7.1.1) + actionmailer (7.1.3) + actionpack (= 7.1.3) + actionview (= 7.1.3) + activejob (= 7.1.3) + activesupport (= 7.1.3) mail (~> 2.5, >= 2.5.4) net-imap net-pop net-smtp rails-dom-testing (~> 2.2) - actionpack (7.1.1) - actionview (= 7.1.1) - activesupport (= 7.1.1) + actionpack (7.1.3) + actionview (= 7.1.3) + activesupport (= 7.1.3) nokogiri (>= 1.8.5) + racc rack (>= 2.2.4) rack-session (>= 1.0.1) rack-test (>= 0.6.3) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) - actiontext (7.1.1) - actionpack (= 7.1.1) - activerecord (= 7.1.1) - activestorage (= 7.1.1) - activesupport (= 7.1.1) + actiontext (7.1.3) + actionpack (= 7.1.3) + activerecord (= 7.1.3) + activestorage (= 7.1.3) + activesupport (= 7.1.3) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.1.1) - activesupport (= 7.1.1) + actionview (7.1.3) + activesupport (= 7.1.3) builder (~> 3.1) erubi (~> 1.11) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) - activejob (7.1.1) - activesupport (= 7.1.1) + activejob (7.1.3) + activesupport (= 7.1.3) globalid (>= 0.3.6) - activemodel (7.1.1) - activesupport (= 7.1.1) - activerecord (7.1.1) - activemodel (= 7.1.1) - activesupport (= 7.1.1) + activemodel (7.1.3) + activesupport (= 7.1.3) + activerecord (7.1.3) + activemodel (= 7.1.3) + activesupport (= 7.1.3) timeout (>= 0.4.0) - activestorage (7.1.1) - actionpack (= 7.1.1) - activejob (= 7.1.1) - activerecord (= 7.1.1) - activesupport (= 7.1.1) + activestorage (7.1.3) + actionpack (= 7.1.3) + activejob (= 7.1.3) + activerecord (= 7.1.3) + activesupport (= 7.1.3) marcel (~> 1.0) - activesupport (7.1.1) + activesupport (7.1.3) base64 bigdecimal concurrent-ruby (~> 1.0, >= 1.0.2) @@ -74,13 +81,13 @@ GEM minitest (>= 5.1) mutex_m tzinfo (~> 2.0) - addressable (2.8.5) + addressable (2.8.6) public_suffix (>= 2.0.2, < 6.0) base64 (0.2.0) - bcrypt (3.1.19) - bigdecimal (3.1.4) + bcrypt (3.1.20) + bigdecimal (3.1.6) bindex (0.8.1) - bootsnap (1.16.0) + bootsnap (1.17.1) msgpack (~> 1.2) builder (3.2.4) capybara (3.39.2) @@ -92,13 +99,13 @@ GEM rack-test (>= 0.6.3) regexp_parser (>= 1.5, < 3.0) xpath (~> 3.2) - concurrent-ruby (1.2.2) + concurrent-ruby (1.2.3) connection_pool (2.4.1) crass (1.0.6) - date (3.3.3) - debug (1.8.0) - irb (>= 1.5.0) - reline (>= 0.3.1) + date (3.3.4) + debug (1.9.1) + irb (~> 1.10) + reline (>= 0.3.8) drb (2.2.0) ruby2_keywords erubi (1.12.0) @@ -106,13 +113,14 @@ GEM activesupport (>= 6.1) i18n (1.14.1) concurrent-ruby (~> 1.0) - importmap-rails (1.2.1) + importmap-rails (2.0.1) actionpack (>= 6.0.0) + activesupport (>= 6.0.0) railties (>= 6.0.0) - io-console (0.6.0) - irb (1.8.2) + io-console (0.7.2) + irb (1.11.1) rdoc - reline (>= 0.3.8) + reline (>= 0.4.2) jbuilder (2.11.5) actionview (>= 5.0.0) activesupport (>= 5.0.0) @@ -128,7 +136,7 @@ GEM activerecord kaminari-core (= 1.2.2) kaminari-core (1.2.2) - loofah (2.21.4) + loofah (2.22.0) crass (~> 1.0.2) nokogiri (>= 1.12.0) mail (2.8.1) @@ -139,30 +147,30 @@ GEM marcel (1.0.2) matrix (0.4.2) mini_mime (1.1.5) - minitest (5.20.0) + minitest (5.21.2) msgpack (1.7.2) mutex_m (0.2.0) - net-imap (0.4.1) + net-imap (0.4.9.1) date net-protocol net-pop (0.1.2) net-protocol - net-protocol (0.2.1) + net-protocol (0.2.2) timeout - net-smtp (0.4.0) + net-smtp (0.4.0.1) net-protocol - nio4r (2.5.9) - nokogiri (1.15.4-aarch64-linux) + nio4r (2.7.0) + nokogiri (1.16.0-aarch64-linux) racc (~> 1.4) - nokogiri (1.15.4-x86_64-linux) + nokogiri (1.16.0-x86_64-linux) racc (~> 1.4) pg (1.5.4) - psych (5.1.1) + psych (5.1.2) stringio - public_suffix (5.0.3) - puma (6.4.0) + public_suffix (5.0.4) + puma (6.4.2) nio4r (~> 2.0) - racc (1.7.1) + racc (1.7.3) rack (3.0.8) rack-session (2.0.0) rack (>= 3.0.0) @@ -171,20 +179,20 @@ GEM rackup (2.1.0) rack (>= 3) webrick (~> 1.8) - rails (7.1.1) - actioncable (= 7.1.1) - actionmailbox (= 7.1.1) - actionmailer (= 7.1.1) - actionpack (= 7.1.1) - actiontext (= 7.1.1) - actionview (= 7.1.1) - activejob (= 7.1.1) - activemodel (= 7.1.1) - activerecord (= 7.1.1) - activestorage (= 7.1.1) - activesupport (= 7.1.1) + rails (7.1.3) + actioncable (= 7.1.3) + actionmailbox (= 7.1.3) + actionmailer (= 7.1.3) + actionpack (= 7.1.3) + actiontext (= 7.1.3) + actionview (= 7.1.3) + activejob (= 7.1.3) + activemodel (= 7.1.3) + activerecord (= 7.1.3) + activestorage (= 7.1.3) + activesupport (= 7.1.3) bundler (>= 1.15.0) - railties (= 7.1.1) + railties (= 7.1.3) rails-dom-testing (2.2.0) activesupport (>= 5.0.0) minitest @@ -192,29 +200,32 @@ GEM rails-html-sanitizer (1.6.0) loofah (~> 2.21) nokogiri (~> 1.14) - railties (7.1.1) - actionpack (= 7.1.1) - activesupport (= 7.1.1) + railties (7.1.3) + actionpack (= 7.1.3) + activesupport (= 7.1.3) irb rackup (>= 1.0.0) rake (>= 12.2) thor (~> 1.0, >= 1.2.2) zeitwerk (~> 2.6) - rake (13.0.6) - rdoc (6.5.0) + rake (13.1.0) + rdoc (6.6.2) psych (>= 4.0.0) - regexp_parser (2.8.2) - reline (0.3.9) + regexp_parser (2.9.0) + reline (0.4.2) io-console (~> 0.5) rexml (3.2.6) ruby2_keywords (0.0.5) rubyzip (2.3.2) - selenium-webdriver (4.14.0) + selenium-webdriver (4.17.0) + base64 (~> 0.2) rexml (~> 3.2, >= 3.2.5) rubyzip (>= 1.2.2, < 3.0) websocket (~> 1.0) - solid_cache (0.1.0) - rails (>= 7) + solid_cache (0.4.1) + activejob (>= 7) + activerecord (>= 7) + railties (>= 7) sprockets (4.2.1) concurrent-ruby (~> 1.0) rack (>= 2.2.4, < 4) @@ -222,11 +233,11 @@ GEM actionpack (>= 5.2) activesupport (>= 5.2) sprockets (>= 3.0.0) - stimulus-rails (1.3.0) + stimulus-rails (1.3.3) railties (>= 6.0.0) - stringio (3.0.8) + stringio (3.1.0) thor (1.3.0) - timeout (0.4.0) + timeout (0.4.1) turbo-rails (1.5.0) actionpack (>= 6.0.0) activejob (>= 6.0.0) @@ -256,6 +267,7 @@ DEPENDENCIES bootsnap capybara debug + flaggle_rock! importmap-rails jbuilder kaminari diff --git a/app/javascript/application.js b/app/javascript/application.js index bcfb47b..9e7854c 100644 --- a/app/javascript/application.js +++ b/app/javascript/application.js @@ -2,3 +2,4 @@ import "@hotwired/turbo-rails" import "trix" import "@rails/actiontext" +import "controllers" diff --git a/app/javascript/controllers/application.js b/app/javascript/controllers/application.js new file mode 100644 index 0000000..1213e85 --- /dev/null +++ b/app/javascript/controllers/application.js @@ -0,0 +1,9 @@ +import { Application } from "@hotwired/stimulus" + +const application = Application.start() + +// Configure Stimulus development experience +application.debug = false +window.Stimulus = application + +export { application } diff --git a/app/javascript/controllers/index.js b/app/javascript/controllers/index.js new file mode 100644 index 0000000..54ad4ca --- /dev/null +++ b/app/javascript/controllers/index.js @@ -0,0 +1,11 @@ +// Import and register all your controllers from the importmap under controllers/* + +import { application } from "controllers/application" + +// Eager load all controllers defined in the import map under controllers/**/*_controller +import { eagerLoadControllersFrom } from "@hotwired/stimulus-loading" +eagerLoadControllersFrom("controllers", application) + +// Lazy load controllers as they appear in the DOM (remember not to preload controllers in import map!) +// import { lazyLoadControllersFrom } from "@hotwired/stimulus-loading" +// lazyLoadControllersFrom("controllers", application) diff --git a/config/importmap.rb b/config/importmap.rb index fff93ec..53f59f6 100644 --- a/config/importmap.rb +++ b/config/importmap.rb @@ -4,3 +4,6 @@ pin "application", preload: true pin "@hotwired/turbo-rails", to: "turbo.min.js", preload: true pin "trix" pin "@rails/actiontext", to: "actiontext.js" +pin "@hotwired/stimulus", to: "stimulus.min.js" +pin "@hotwired/stimulus-loading", to: "stimulus-loading.js" +pin_all_from "app/javascript/controllers", under: "controllers" diff --git a/db/migrate/20240126101316_create_feature_flags.rb b/db/migrate/20240126101316_create_feature_flags.rb new file mode 100644 index 0000000..8407880 --- /dev/null +++ b/db/migrate/20240126101316_create_feature_flags.rb @@ -0,0 +1,10 @@ +class CreateFeatureFlags < ActiveRecord::Migration[7.0] + def change + create_table :feature_flags do |t| + t.string :name, null: false, index: { unique: true } + t.boolean :enabled, null: false, default: false + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 3af3095..8afa141 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.1].define(version: 2024_01_07_131738) do +ActiveRecord::Schema[7.1].define(version: 2024_01_26_101316) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -97,6 +97,14 @@ ActiveRecord::Schema[7.1].define(version: 2024_01_07_131738) do t.index ["exercise_type_id"], name: "index_exercises_on_exercise_type_id" end + create_table "feature_flags", force: :cascade do |t| + t.string "name", null: false + t.boolean "enabled", default: false, null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["name"], name: "index_feature_flags_on_name", unique: true + end + create_table "learning_goals", force: :cascade do |t| t.string "title", null: false t.date "starts_on"