maquina 0.5.2 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. checksums.yaml +4 -4
  2. data/.ruby-version +1 -1
  3. data/Gemfile +2 -0
  4. data/Gemfile.lock +3 -35
  5. data/app/assets/javascripts/controllers/alert_controller.js +22 -0
  6. data/app/assets/stylesheets/maquina/application.tailwind.css +4 -101
  7. data/app/assets/stylesheets/maquina.css +114 -0
  8. data/app/controllers/concerns/maquina/authenticate.rb +29 -1
  9. data/app/controllers/concerns/maquina/index.rb +81 -2
  10. data/app/controllers/concerns/maquina/resourceful.rb +95 -9
  11. data/app/controllers/maquina/application_controller.rb +1 -1
  12. data/app/controllers/maquina/dashboard_controller.rb +10 -5
  13. data/app/controllers/maquina/invitations_controller.rb +0 -2
  14. data/app/controllers/maquina/plans_controller.rb +13 -23
  15. data/app/controllers/maquina/sessions_controller.rb +1 -1
  16. data/app/controllers/maquina/users_controller.rb +0 -2
  17. data/app/helpers/maquina/application_helper.rb +0 -8
  18. data/app/helpers/maquina/navbar_menu_helper.rb +1 -1
  19. data/app/models/concerns/maquina/blockeable.rb +64 -0
  20. data/app/models/concerns/maquina/organization_scoped.rb +26 -0
  21. data/app/models/concerns/maquina/retain_passwords.rb +44 -0
  22. data/app/models/concerns/maquina/sqlite_search.rb +92 -0
  23. data/app/models/concerns/maquina/user_scoped.rb +26 -0
  24. data/app/models/maquina/active_session.rb +40 -0
  25. data/app/models/maquina/current.rb +39 -2
  26. data/app/models/maquina/invitation.rb +28 -0
  27. data/app/models/maquina/membership.rb +23 -1
  28. data/app/models/maquina/organization.rb +19 -2
  29. data/app/models/maquina/plan.rb +26 -6
  30. data/app/models/maquina/used_password.rb +30 -0
  31. data/app/models/maquina/user.rb +50 -8
  32. data/app/policies/maquina/application_policy.rb +1 -1
  33. data/app/policies/maquina/dashboard_policy.rb +7 -0
  34. data/app/views/layouts/maquina/application.html.erb +2 -2
  35. data/app/views/layouts/maquina/sessions.html.erb +1 -1
  36. data/app/views/maquina/application/_navbar.html.erb +8 -3
  37. data/app/views/maquina/application/components/checkbox_component.rb +3 -3
  38. data/app/views/maquina/application/components/component_base.rb +3 -2
  39. data/app/views/maquina/application/edit.html.erb +10 -7
  40. data/app/views/maquina/application/filters.rb +118 -0
  41. data/app/views/maquina/application/index.html.erb +6 -3
  42. data/app/views/maquina/application/index_header.rb +5 -2
  43. data/app/views/maquina/application/index_table.rb +71 -6
  44. data/app/views/maquina/application/index_tools.rb +17 -0
  45. data/app/views/maquina/application/new.html.erb +10 -7
  46. data/app/views/maquina/application/search.rb +42 -0
  47. data/app/views/maquina/application/sessions_header.rb +3 -9
  48. data/app/views/maquina/dashboard/index.html.erb +4 -0
  49. data/app/views/maquina/dashboard/stats.rb +35 -0
  50. data/app/views/maquina/dashboard/tasks.rb +124 -0
  51. data/app/views/maquina/first_runs/form.rb +0 -2
  52. data/app/views/maquina/first_runs/show.html.erb +4 -1
  53. data/app/views/maquina/navbar/title.rb +4 -2
  54. data/config/importmap.rb +1 -13
  55. data/config/locales/flash.en.yml +6 -0
  56. data/config/locales/flash.es.yml +6 -0
  57. data/config/locales/forms.en.yml +33 -4
  58. data/config/locales/forms.es.yml +22 -11
  59. data/config/locales/models.en.yml +10 -0
  60. data/config/locales/models.es.yml +10 -0
  61. data/config/locales/views.en.yml +33 -5
  62. data/config/locales/views.es.yml +28 -10
  63. data/config/routes.rb +1 -0
  64. data/db/migrate/20221109010726_create_maquina_plans.rb +1 -1
  65. data/db/migrate/20221113000409_create_maquina_users.rb +1 -1
  66. data/db/migrate/20221113020108_create_maquina_used_passwords.rb +1 -1
  67. data/db/migrate/20221115223414_create_maquina_active_sessions.rb +1 -3
  68. data/db/migrate/20230201203922_create_maquina_invitations.rb +1 -1
  69. data/db/migrate/20230829183530_create_maquina_organizations.rb +1 -1
  70. data/db/migrate/20230829192656_create_maquina_memberships.rb +2 -4
  71. data/db/migrate/20241109191405_add_counter_cache_to_plans.rb +5 -0
  72. data/lib/generators/maquina/install_generator.rb +67 -1
  73. data/lib/generators/maquina/tailwind_config/templates/lib/generators/tailwind_config/templates/config/tailwind.config.js.tt +9 -5
  74. data/lib/generators/maquina/tailwind_config/templates/lib/tasks/tailwind.rake.tt +2 -0
  75. data/lib/generators/maquina/templates/config/initializers/maquina.rb.tt +2 -1
  76. data/lib/maquina/engine.rb +6 -3
  77. data/lib/maquina/version.rb +1 -1
  78. data/lib/maquina.rb +2 -9
  79. metadata +20 -76
  80. data/app/assets/javascripts/maquina/application.js +0 -4
  81. data/app/assets/javascripts/maquina/controllers/alert_controller.js +0 -29
  82. data/app/assets/javascripts/maquina/controllers/application.js +0 -9
  83. data/app/assets/javascripts/maquina/controllers/index.js +0 -11
  84. data/app/models/concerns/maquina/authenticate_by.rb +0 -33
  85. data/app/views/maquina/navbar/search.rb +0 -40
  86. data/lib/generators/maquina/install_templates/install_templates_generator.rb +0 -31
  87. /data/app/assets/javascripts/{maquina/controllers → controllers}/backdrop_controller.js +0 -0
  88. /data/app/assets/javascripts/{maquina/controllers → controllers}/file_controller.js +0 -0
  89. /data/app/assets/javascripts/{maquina/controllers → controllers}/mobile_menu_controller.js +0 -0
  90. /data/app/assets/javascripts/{maquina/controllers → controllers}/modal_controller.js +0 -0
  91. /data/app/assets/javascripts/{maquina/controllers → controllers}/modal_open_controller.js +0 -0
  92. /data/app/assets/javascripts/{maquina/controllers → controllers}/popup_menu_controller.js +0 -0
  93. /data/app/assets/javascripts/{maquina/controllers → controllers}/submit_form_controller.js +0 -0
@@ -1,29 +0,0 @@
1
- import { Controller } from "@hotwired/stimulus"
2
- import { useTransition } from "stimulus-use"
3
-
4
- /**
5
- * Alert Controller
6
- *
7
- * Cuando hay información en el objeto Flash de Rails se muestra con una animación
8
- * el mensaje y desaparece solo después de 10 segundos o cerrándolo con la X.
9
- */
10
-
11
- export default class extends Controller {
12
- static targets = ["alert"];
13
-
14
- connect() {
15
- let element = this.element;
16
- if (this.hasAlertTarget) {
17
- element = this.alertTarget
18
- }
19
- useTransition(this, { element: element })
20
-
21
- this.enter()
22
-
23
- setTimeout(this.close.bind(this), 10000)
24
- }
25
-
26
- close() {
27
- this.leave()
28
- }
29
- }
@@ -1,9 +0,0 @@
1
- import { Application } from "@hotwired/stimulus"
2
-
3
- const application = Application.start()
4
-
5
- // Configure Stimulus development experience
6
- application.debug = false
7
- window.Stimulus = application
8
-
9
- export { application }
@@ -1,11 +0,0 @@
1
- // Import and register all your controllers from the importmap under controllers/*
2
-
3
- import { application } from "controllers/application"
4
-
5
- // Eager load all controllers defined in the import map under controllers/**/*_controller
6
- import { eagerLoadControllersFrom } from "@hotwired/stimulus-loading"
7
- eagerLoadControllersFrom("controllers", application)
8
-
9
- // Lazy load controllers as they appear in the DOM (remember not to preload controllers in import map!)
10
- // import { lazyLoadControllersFrom } from "@hotwired/stimulus-loading"
11
- // lazyLoadControllersFrom("controllers", application)
@@ -1,33 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Maquina
4
- module AuthenticateBy
5
- extend ActiveSupport::Concern
6
- included do
7
- add_authenticate_by
8
- end
9
-
10
- class_methods do
11
- def add_authenticate_by
12
- version = Gem::Version.new(Rails::VERSION::STRING)
13
- return if version.to_s.to_f >= 7.1
14
-
15
- Rails.logger.warn "[#{self}] Adding class method authenticate_by"
16
- self.class.define_method(:authenticate_by) do |attributes|
17
- passwords, identifiers = attributes.to_h.partition do |name, value|
18
- !has_attribute?(name) && has_attribute?("#{name}_digest")
19
- end.map(&:to_h)
20
-
21
- raise ArgumentError, "One or more password arguments are required" if passwords.empty?
22
- raise ArgumentError, "One or more finder arguments are required" if identifiers.empty?
23
- if (record = find_by(identifiers))
24
- record if passwords.count { |name, value| record.public_send(:"authenticate_#{name}", value) } == passwords.size
25
- else
26
- new(passwords)
27
- nil
28
- end
29
- end
30
- end
31
- end
32
- end
33
- end
@@ -1,40 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Maquina
4
- module Navbar
5
- class Search < Phlex::HTML
6
- include ApplicationView
7
- include Phlex::Rails::Helpers::FormWith
8
-
9
- delegate :t, to: :helpers
10
-
11
- def initialize(url: nil, query: "")
12
- @url = url
13
- @query = query
14
- end
15
-
16
- def view_template
17
- div class: "flex-1 flex items-center justify-center px-2 lg:ml-6 lg:justify-end" do
18
- div class: "max-w-lg w-full lg:max-w-xs" do
19
- form_with(url: @url, method: :get, data: {controller: "submit-form"}) do |form|
20
- form.label :search, t("search.search"), class: "sr-only"
21
-
22
- div class: "relative" do
23
- div class: "absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none" do
24
- svg_icon(:fill, view_box: "0 0 20 20", css_class: "h-5 w-5 text-skin-dimmed", icon: search_icon)
25
- end
26
- form.text_field :q, value: @query, placeholder: t("search.search"), class: "block w-full font-sans", maxlength: 15, type: :search, data: {action: "input->submit-form#clear"}
27
- end
28
- end
29
- end
30
- end
31
- end
32
-
33
- private
34
-
35
- def search_icon
36
- "M8 4a4 4 0 100 8 4 4 0 000-8zM2 8a6 6 0 1110.89 3.476l4.817 4.817a1 1 0 01-1.414 1.414l-4.816-4.816A6 6 0 012 8z"
37
- end
38
- end
39
- end
40
- end
@@ -1,31 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Maquina
4
- module Generators
5
- class InstallTemplatesGenerator < Rails::Generators::Base
6
- source_root File.expand_path("../../../../app/views", __FILE__)
7
-
8
- def copy_layout
9
- empty_directory "app/views/layouts/maquina"
10
- directory File.join(engine_views_path, "layouts", "maquina"),
11
- File.join(app_views_path, "layouts", "maquina")
12
- end
13
-
14
- def copy_views
15
- empty_directory "app/views/maquina"
16
- directory File.join(engine_views_path, "maquina"),
17
- File.join(app_views_path, "maquina")
18
- end
19
-
20
- private
21
-
22
- def engine_views_path
23
- @engine_views_path ||= File.join(Maquina::Engine.root, "app", "views")
24
- end
25
-
26
- def app_views_path
27
- @app_views_path ||= File.join(Rails.root, "app", "views")
28
- end
29
- end
30
- end
31
- end