diff --git a/Gemfile b/Gemfile index 670a476caf..adcf0a5438 100644 --- a/Gemfile +++ b/Gemfile @@ -129,7 +129,6 @@ gem 'flipper-active_record' gem 'flipper-ui' gem "view_component" -gem 'view_component_reflex', '3.1.14.pre9' # mini_portile2 is needed when installing with Vargant # https://openfoodnetwork.slack.com/archives/CEBMTRCNS/p1668439152992899 @@ -162,7 +161,6 @@ group :test, :development do gem 'rspec-sql' gem 'rswag' gem 'shoulda-matchers' - gem 'stimulus_reflex_testing', github: "podia/stimulus_reflex_testing", branch: :main gem 'timecop' end diff --git a/Gemfile.lock b/Gemfile.lock index 69389e95a7..9c32ce1874 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -17,14 +17,6 @@ GIT sass-rails thor (>= 0.14) -GIT - remote: https://github.com/podia/stimulus_reflex_testing.git - revision: abac2ee34de347c589795b4d1a8e83e0baafb201 - branch: main - specs: - stimulus_reflex_testing (0.3.1) - stimulus_reflex (>= 3.3.0) - PATH remote: engines/catalog specs: @@ -191,13 +183,6 @@ GEM bullet (7.1.6) activesupport (>= 3.0.0) uniform_notifier (~> 1.11) - cable_ready (5.0.5) - actionpack (>= 5.2) - actionview (>= 5.2) - activesupport (>= 5.2) - observer (~> 0.1) - railties (>= 5.2) - thread-local (>= 1.1.0) cancancan (1.15.0) capybara (3.40.0) addressable @@ -452,15 +437,12 @@ GEM nokogiri (1.16.5) mini_portile2 (~> 2.8.2) racc (~> 1.4) - nokogiri-html5-inference (0.3.0) - nokogiri (~> 1.14) oauth2 (1.4.11) faraday (>= 0.17.3, < 3.0) jwt (>= 1.0, < 3.0) multi_json (~> 1.3) multi_xml (~> 0.5) rack (>= 1.2, < 4) - observer (0.1.2) omniauth (2.1.2) hashie (>= 3.4.6) rack (>= 2.2.3) @@ -755,17 +737,6 @@ GEM state_machines-activerecord (0.9.0) activerecord (>= 6.0) state_machines-activemodel (>= 0.9.0) - stimulus_reflex (3.5.1) - actioncable (>= 5.2, < 8) - actionpack (>= 5.2, < 8) - actionview (>= 5.2, < 8) - activesupport (>= 5.2, < 8) - cable_ready (~> 5.0) - nokogiri (~> 1.0) - nokogiri-html5-inference (~> 0.3) - rack (>= 2, < 4) - railties (>= 5.2, < 8) - redis (>= 4.0, < 6.0) stringex (2.8.6) stringio (3.1.0) stripe (11.1.0) @@ -777,7 +748,6 @@ GEM faraday-follow_redirects temple (0.8.2) thor (1.3.1) - thread-local (1.1.0) tilt (2.3.0) timecop (0.9.8) timeout (0.4.1) @@ -806,10 +776,6 @@ GEM activesupport (>= 5.2.0, < 8.0) concurrent-ruby (~> 1.0) method_source (~> 1.0) - view_component_reflex (3.1.14.pre9) - rails (>= 5.2, < 8.0) - stimulus_reflex (>= 3.5.0.pre2) - view_component (>= 2.28.0) virtual_assembly-semantizer (1.1.1) json-ld (~> 3.2, >= 3.2.3) warden (1.2.9) @@ -969,7 +935,6 @@ DEPENDENCIES spring-commands-rspec spring-commands-rubocop state_machines-activerecord - stimulus_reflex_testing! stringex (~> 2.8.5) stripe timecop @@ -979,7 +944,6 @@ DEPENDENCIES validates_lengths_from_database vcr view_component - view_component_reflex (= 3.1.14.pre9) web! web-console webmock diff --git a/app/webpacker/controllers/application_controller.js b/app/webpacker/controllers/application_controller.js deleted file mode 100644 index 50f5e57269..0000000000 --- a/app/webpacker/controllers/application_controller.js +++ /dev/null @@ -1,69 +0,0 @@ -import { Controller } from "@hotwired/stimulus"; -import StimulusReflex from "stimulus_reflex"; - -/* This is your ApplicationController. - * All StimulusReflex controllers should inherit from this class. - * - * Example: - * - * import ApplicationController from './application_controller' - * - * export default class extends ApplicationController { ... } - * - * Learn more at: https://docs.stimulusreflex.com - */ -export default class extends Controller { - connect() { - StimulusReflex.register(this); - } - - /* Application-wide lifecycle methods - * - * Use these methods to handle lifecycle concerns for the entire application. - * Using the lifecycle is optional, so feel free to delete these stubs if you don't need them. - * - * Arguments: - * - * element - the element that triggered the reflex - * may be different than the Stimulus controller's this.element - * - * reflex - the name of the reflex e.g. "Example#demo" - * - * error/noop - the error message (for reflexError), otherwise null - * - * reflexId - a UUID4 or developer-provided unique identifier for each Reflex - */ - - beforeReflex(element, reflex, noop, reflexId) { - // document.body.classList.add('wait') - } - - reflexSuccess(element, reflex, noop, reflexId) { - // show success message - } - - reflexError(element, reflex, error, reflexId) { - // Log to console (it normally only gets logged in dev mode) - console.error(reflex + ":\n " + error); - - // show error message - alert(I18n.t("errors.general_error.message")); - } - - reflexForbidden(element, reflex, noop, reflexId) { - // Reflex action did not have permission to run - // window.location = '/' - } - - reflexHalted(element, reflex, noop, reflexId) { - // handle aborted Reflex action - } - - afterReflex(element, reflex, noop, reflexId) { - // document.body.classList.remove('wait') - } - - finalizeReflex(element, reflex, noop, reflexId) { - // all operations have completed, animation etc is now safe - } -} diff --git a/app/webpacker/controllers/example_controller.js b/app/webpacker/controllers/example_controller.js deleted file mode 100644 index 3a1ab11fab..0000000000 --- a/app/webpacker/controllers/example_controller.js +++ /dev/null @@ -1,73 +0,0 @@ -import ApplicationController from "./application_controller"; - -/* This is the custom StimulusReflex controller for the Example Reflex. - * Learn more at: https://docs.stimulusreflex.com - */ -export default class extends ApplicationController { - /* - * Regular Stimulus lifecycle methods - * Learn more at: https://stimulusjs.org/reference/lifecycle-callbacks - * - * If you intend to use this controller as a regular stimulus controller as well, - * make sure any Stimulus lifecycle methods overridden in ApplicationController call super. - * - * Important: - * By default, StimulusReflex overrides the -connect- method so make sure you - * call super if you intend to do anything else when this controller connects. - */ - - connect() { - super.connect(); - // add your code here, if applicable - } - - /* Reflex specific lifecycle methods. - * - * For every method defined in your Reflex class, a matching set of lifecycle methods become available - * in this javascript controller. These are optional, so feel free to delete these stubs if you don't - * need them. - * - * Important: - * Make sure to add data-controller="example" to your markup alongside - * data-reflex="Example#dance" for the lifecycle methods to fire properly. - * - * Example: - * - * Dance! - * - * Arguments: - * - * element - the element that triggered the reflex - * may be different than the Stimulus controller's this.element - * - * reflex - the name of the reflex e.g. "Example#dance" - * - * error/noop - the error message (for reflexError), otherwise null - * - * reflexId - a UUID4 or developer-provided unique identifier for each Reflex - */ - - // Assuming you create a "Example#dance" action in your Reflex class - // you'll be able to use the following lifecycle methods: - - // beforeDance(element, reflex, noop, reflexId) { - // element.innerText = 'Putting dance shoes on...' - // } - - // danceSuccess(element, reflex, noop, reflexId) { - // element.innerText = '\nDanced like no one was watching! Was someone watching?' - // } - - // danceError(element, reflex, error, reflexId) { - // console.error('danceError', error); - // element.innerText = "\nCouldn\'t dance!" - // } - - // afterDance(element, reflex, noop, reflexId) { - // element.innerText = '\nWhatever that was, it\'s over now.' - // } - - // finalizeDance(element, reflex, noop, reflexId) { - // element.innerText = '\nNow, the cleanup can begin!' - // } -} diff --git a/app/webpacker/controllers/index.js b/app/webpacker/controllers/index.js index 147ceac172..1ae080412c 100644 --- a/app/webpacker/controllers/index.js +++ b/app/webpacker/controllers/index.js @@ -2,9 +2,7 @@ // Controller files must be named *_controller.js. import { Application } from "stimulus"; import { definitionsFromContext } from "stimulus/webpack-helpers"; -import StimulusReflex from "stimulus_reflex"; import consumer from "../channels/consumer"; -import controller from "../controllers/application_controller"; import RailsNestedForm from '@stimulus-components/rails-nested-form/dist/stimulus-rails-nested-form.umd.js' // the default module entry point is broken const application = Application.start(); @@ -15,6 +13,4 @@ application.load(definitionsFromContext(context).concat(definitionsFromContext(c application.register('nested-form', RailsNestedForm); application.consumer = consumer; -StimulusReflex.initialize(application, { controller, isolate: true }); -StimulusReflex.debug = process.env.RAILS_ENV === "development"; -CableReady.initialize({ consumer }); + diff --git a/app/webpacker/controllers/loading_controller.js b/app/webpacker/controllers/loading_controller.js index 4d93c2bd6c..f4b89e88cf 100644 --- a/app/webpacker/controllers/loading_controller.js +++ b/app/webpacker/controllers/loading_controller.js @@ -1,10 +1,6 @@ -import ApplicationController from "./application_controller"; - -export default class extends ApplicationController { - connect() { - super.connect(); - } +import { Controller } from "stimulus"; +export default class extends Controller { hideLoading = () => { this.element.classList.add("hidden"); }; diff --git a/app/webpacker/controllers/products_controller.js b/app/webpacker/controllers/products_controller.js index b50dd714c6..3af4c1ff0d 100644 --- a/app/webpacker/controllers/products_controller.js +++ b/app/webpacker/controllers/products_controller.js @@ -1,22 +1,9 @@ -import ApplicationController from "./application_controller"; +import { Controller } from "stimulus"; -export default class extends ApplicationController { +export default class extends Controller { static targets = ["loading"]; static values = { currentId: Number }; - connect() { - super.connect(); - } - - beforeReflex() { - this.showLoading(); - this.scrollToElement(); - } - - afterReflex() { - this.hideLoading(); - } - delete_product() { this.#deleteByRecordType('product'); } diff --git a/app/webpacker/controllers/search-input_controller.js b/app/webpacker/controllers/search-input_controller.js index 47aee17134..58bb399477 100644 --- a/app/webpacker/controllers/search-input_controller.js +++ b/app/webpacker/controllers/search-input_controller.js @@ -1,15 +1,13 @@ -import ApplicationController from "./application_controller"; +import { Controller } from "stimulus"; -export default class extends ApplicationController { +export default class extends Controller { connect() { - super.connect(); this.element .querySelector("input") .addEventListener("keydown", this.searchOnEnter); } disconnect() { - super.disconnect(); this.element .querySelector("input") .removeEventListener("keydown", this.searchOnEnter); diff --git a/app/webpacker/controllers/selector_controller.js b/app/webpacker/controllers/selector_controller.js index cce4241643..eea13e9f81 100644 --- a/app/webpacker/controllers/selector_controller.js +++ b/app/webpacker/controllers/selector_controller.js @@ -1,14 +1,12 @@ -import ApplicationController from "./application_controller"; +import { Controller } from "stimulus"; -export default class extends ApplicationController { +export default class extends Controller { connect() { - super.connect(); window.addEventListener("click", this.closeOnClickOutside); this.computeItemsHeight(); } disconnect() { - super.disconnect(); window.removeEventListener("click", this.closeOnClickOutside); } @@ -16,10 +14,6 @@ export default class extends ApplicationController { this.close(); } - afterReflex() { - this.computeItemsHeight(); - } - toggle = (event) => { event.preventDefault(); this.element.querySelector(".selector").classList.toggle("selector-close"); diff --git a/app/webpacker/controllers/terms_and_conditions_controller.js b/app/webpacker/controllers/terms_and_conditions_controller.js index efaea8303d..74d641750a 100644 --- a/app/webpacker/controllers/terms_and_conditions_controller.js +++ b/app/webpacker/controllers/terms_and_conditions_controller.js @@ -1,13 +1,12 @@ -import ApplicationController from "./application_controller"; +import { Controller } from "stimulus"; -export default class extends ApplicationController { +export default class extends Controller { static targets = ["filename", "fileinput"]; static values = { message: String, }; connect() { - super.connect(); this.fileinputTarget.addEventListener("change", (event) => { this.filenameTarget.innerText = event.target.files[0].name; }); diff --git a/config/initializers/cable_ready.rb b/config/initializers/cable_ready.rb deleted file mode 100644 index 0375cba039..0000000000 --- a/config/initializers/cable_ready.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -CableReady.configure do |config| - # Enable/disable exiting / warning when the sanity checks fail options: - # `:exit` or `:warn` or `:ignore` - - # config.on_failed_sanity_checks = :exit - - # Enable/disable exiting / warning when there's a new CableReady release - # `:exit` or `:warn` or `:ignore` - - # config.on_new_version_available = :ignore - - # Define your own custom operations - # https://cableready.stimulusreflex.com/customization#custom-operations - - # config.add_operation_name :jazz_hands -end diff --git a/package.json b/package.json index 7a22c42681..e49d5641e9 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "@floating-ui/dom": "^1.6.11", "@hotwired/stimulus": "^3.2", "@hotwired/turbo": "^8.0.12", + "@rails/actioncable": "^7.2.102", "@rails/ujs": "^7.1.3-4", "@rails/webpacker": "5.4.4", "@stimulus-components/rails-nested-form": "^5.0.0", diff --git a/spec/reflex_helper.rb b/spec/reflex_helper.rb deleted file mode 100644 index 4f36f3b6f8..0000000000 --- a/spec/reflex_helper.rb +++ /dev/null @@ -1,4 +0,0 @@ -# frozen_string_literal: true - -require "base_spec_helper" -require "stimulus_reflex_testing/rspec" diff --git a/yarn.lock b/yarn.lock index e28e50d156..54879bdcc0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1124,7 +1124,7 @@ resolved "https://registry.yarnpkg.com/@hotwired/stimulus-webpack-helpers/-/stimulus-webpack-helpers-1.0.1.tgz#4cd74487adeca576c9865ac2b9fe5cb20cef16dd" integrity sha512-wa/zupVG0eWxRYJjC1IiPBdt3Lruv0RqGN+/DTMmUWUyMAEB27KXmVY6a8YpUVTM7QwVuaLNGW4EqDgrS2upXQ== -"@hotwired/stimulus@^3", "@hotwired/stimulus@^3.2", "@hotwired/stimulus@^3.2.2": +"@hotwired/stimulus@^3.2", "@hotwired/stimulus@^3.2.2": version "3.2.2" resolved "https://registry.yarnpkg.com/@hotwired/stimulus/-/stimulus-3.2.2.tgz#071aab59c600fed95b97939e605ff261a4251608" integrity sha512-eGeIqNOQpXoPAIP7tC1+1Yc1yl1xnwYqg+3mzqxyrbE5pg5YFBZcA6YoTiByJB6DKAEsiWtl6tjTJS4IYtbB7A== @@ -1389,10 +1389,10 @@ resolved "https://registry.yarnpkg.com/@orchidjs/unicode-variants/-/unicode-variants-1.0.4.tgz#6d2f812e3b19545bba2d81caffff1204de9a6a58" integrity sha512-NvVBRnZNE+dugiXERFsET1JlKZfM5lJDEpSMilKW4bToYJ7pxf0Zne78xyXB2ny2c2aHfJ6WLnz1AaTNHAmQeQ== -"@rails/actioncable@^6 || ^7": - version "7.0.4" - resolved "https://registry.yarnpkg.com/@rails/actioncable/-/actioncable-7.0.4.tgz#70a3ca56809f7aaabb80af2f9c01ae51e1a8ed41" - integrity sha512-tz4oM+Zn9CYsvtyicsa/AwzKZKL+ITHWkhiu7x+xF77clh2b4Rm+s6xnOgY/sGDWoFWZmtKsE95hxBPkgQQNnQ== +"@rails/actioncable@^7.2.102": + version "7.2.102" + resolved "https://registry.yarnpkg.com/@rails/actioncable/-/actioncable-7.2.102.tgz#0ad6214681f2fdadf5baeee2dbba4ad229612a41" + integrity sha512-cqgfFwU8bFye53jkzJRVErbIFUnbWSJSccbY3EZvyOxatpcUEuuYGvLv/It6gT1/HNgweiARllmVbnegcAN3Lg== "@rails/ujs@^7.1.3-4": version "7.1.3-4" @@ -2438,13 +2438,6 @@ bytes@3.1.2: resolved "https://registry.yarnpkg.com/bytes/-/bytes-3.1.2.tgz#8b0beeb98605adf1b128fa4386403c009e0221a5" integrity sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg== -cable_ready@^5.0.5: - version "5.0.5" - resolved "https://registry.yarnpkg.com/cable_ready/-/cable_ready-5.0.5.tgz#45dd12ae5b3c5c53a1b42c10785e79ff87a5be22" - integrity sha512-qPC6zaI8h59BzMH3MxtpuMC+H33VJTA2eVddL6fZSWz01jJ2Y3okld01oYWQoKwE2yle/tvHbyuhoKxD4mhEuw== - dependencies: - morphdom "2.6.1" - cacache@^12.0.2: version "12.0.4" resolved "https://registry.yarnpkg.com/cacache/-/cacache-12.0.4.tgz#668bcbd105aeb5f1d92fe25570ec9525c8faa40c" @@ -6198,11 +6191,6 @@ moment@^2.30.1: resolved "https://registry.yarnpkg.com/moment/-/moment-2.30.1.tgz#f8c91c07b7a786e30c59926df530b4eac96974ae" integrity sha512-uEmtNhbDOrWPFS+hdjFCBfy9f2YoyzRpwcl+DqpC6taX21FzsTLQVbMV/W7PzNSX6x/bhC1zA3c2UQ5NzH6how== -morphdom@2.6.1: - version "2.6.1" - resolved "https://registry.yarnpkg.com/morphdom/-/morphdom-2.6.1.tgz#e868e24f989fa3183004b159aed643e628b4306e" - integrity sha512-Y8YRbAEP3eKykroIBWrjcfMw7mmwJfjhqdpSvoqinu8Y702nAwikpXcNFDiIkyvfCLxLM9Wu95RZqo4a9jFBaA== - move-concurrently@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/move-concurrently/-/move-concurrently-1.0.1.tgz#be2c005fda32e0b29af1f05d7c4b33214c701f92" @@ -8460,15 +8448,6 @@ stimulus@^3.2.2: "@hotwired/stimulus" "^3.2.2" "@hotwired/stimulus-webpack-helpers" "^1.0.0" -stimulus_reflex@3.5.1: - version "3.5.1" - resolved "https://registry.yarnpkg.com/stimulus_reflex/-/stimulus_reflex-3.5.1.tgz#fb9c548667e01b8dc7141187c73abfe1aa25472a" - integrity sha512-Bwsuerfh8ca6kp7MKlUgzYAmeflqoBzSpb25M4i+h3FsmAfPl4rUNN6T8v1d6JPqAPAVQRUL/wtDHumLtpETFw== - dependencies: - "@hotwired/stimulus" "^3" - "@rails/actioncable" "^6 || ^7" - cable_ready "^5.0.5" - stream-browserify@^2.0.1: version "2.0.2" resolved "https://registry.yarnpkg.com/stream-browserify/-/stream-browserify-2.0.2.tgz#87521d38a44aa7ee91ce1cd2a47df0cb49dd660b"