lesli_shield 1.1.7 → 1.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/stylesheets/lesli_shield/application.css +1036 -32
  3. data/app/assets/stylesheets/lesli_shield/confirmations.css +89 -557
  4. data/app/assets/stylesheets/lesli_shield/invitations.css +544 -0
  5. data/app/assets/stylesheets/lesli_shield/passwords.css +76 -542
  6. data/app/assets/stylesheets/lesli_shield/registrations.css +66 -539
  7. data/app/assets/stylesheets/lesli_shield/sessions.css +98 -564
  8. data/app/controllers/lesli_shield/invites_controller.rb +100 -49
  9. data/app/controllers/lesli_shield/profiles_controller.rb +9 -3
  10. data/app/controllers/lesli_shield/role/actions_controller.rb +134 -38
  11. data/app/controllers/lesli_shield/roles_controller.rb +114 -141
  12. data/app/controllers/lesli_shield/users_controller.rb +11 -4
  13. data/app/controllers/users/confirmations_controller.rb +2 -2
  14. data/app/controllers/users/invitations_controller.rb +101 -0
  15. data/app/controllers/users/passwords_controller.rb +1 -1
  16. data/app/controllers/users/registrations_controller.rb +2 -2
  17. data/app/controllers/users/sessions_controller.rb +3 -1
  18. data/app/jobs/lesli_shield/invitation_delivery_job.rb +123 -0
  19. data/app/mailers/lesli_shield/devise_mailer.rb +3 -3
  20. data/app/mailers/lesli_shield/invitation_mailer.rb +58 -0
  21. data/app/models/concerns/lesli_shield/role_management.rb +70 -0
  22. data/app/models/concerns/lesli_shield/user_security.rb +22 -19
  23. data/app/models/lesli_shield/invite.rb +183 -12
  24. data/app/services/lesli_shield/invitation_audit.rb +34 -0
  25. data/app/services/lesli_shield/invitation_email_policy.rb +64 -0
  26. data/app/services/lesli_shield/invitation_service.rb +405 -0
  27. data/app/services/lesli_shield/invite_service.rb +34 -5
  28. data/app/services/lesli_shield/profile_service.rb +1 -0
  29. data/app/services/lesli_shield/role_action_service.rb +37 -92
  30. data/app/services/lesli_shield/role_audit.rb +42 -0
  31. data/app/services/lesli_shield/role_permission_service.rb +347 -0
  32. data/app/services/lesli_shield/role_privilege_deployment_service.rb +79 -0
  33. data/app/services/lesli_shield/role_privilege_service.rb +69 -105
  34. data/app/services/lesli_shield/role_service.rb +431 -0
  35. data/app/services/lesli_shield/user_registration_service.rb +1 -1
  36. data/app/services/lesli_shield/user_validator_service.rb +9 -9
  37. data/app/views/devise/confirmations/new.html.erb +6 -6
  38. data/app/views/devise/confirmations/show.html.erb +6 -6
  39. data/app/views/devise/passwords/edit.html.erb +8 -8
  40. data/app/views/devise/passwords/new.html.erb +9 -9
  41. data/app/views/devise/registrations/new.html.erb +16 -16
  42. data/app/views/devise/sessions/new.html.erb +9 -9
  43. data/app/views/devise/shared/_application-devise-simple.erb +1 -1
  44. data/app/views/devise/shared/_application-devise.html.erb +4 -4
  45. data/app/views/devise/shared/_demo.html.erb +5 -5
  46. data/app/views/devise/shared/_error_messages.html.erb +5 -5
  47. data/app/views/devise/shared/_links.html.erb +12 -15
  48. data/app/views/lesli_shield/invites/_form.html.erb +64 -7
  49. data/app/views/lesli_shield/invites/_invite.html.erb +55 -2
  50. data/app/views/lesli_shield/invites/_invite_actions.html.erb +34 -0
  51. data/app/views/lesli_shield/invites/_status_badge.html.erb +13 -0
  52. data/app/views/lesli_shield/invites/index.html.erb +119 -63
  53. data/app/views/lesli_shield/invites/new.html.erb +11 -36
  54. data/app/views/lesli_shield/invites/show.html.erb +13 -52
  55. data/app/views/lesli_shield/profiles/_information-form.html.erb +11 -0
  56. data/app/views/lesli_shield/profiles/_password-form.html.erb +1 -1
  57. data/app/views/lesli_shield/profiles/show.html.erb +1 -4
  58. data/app/views/lesli_shield/role/actions/_custom_actions.html.erb +24 -0
  59. data/app/views/lesli_shield/role/actions/_deployment_status.html.erb +14 -0
  60. data/app/views/lesli_shield/role/actions/_matrix.html.erb +69 -0
  61. data/app/views/lesli_shield/role/actions/_permissions.html.erb +95 -0
  62. data/app/views/lesli_shield/role/actions/_toggle.html.erb +34 -0
  63. data/app/views/lesli_shield/role/actions/index.html.erb +13 -10
  64. data/app/views/lesli_shield/roles/_deployment_badge.html.erb +15 -0
  65. data/app/views/lesli_shield/roles/_empty_state.html.erb +20 -0
  66. data/app/views/lesli_shield/roles/_field_errors.html.erb +5 -0
  67. data/app/views/lesli_shield/roles/_filters.html.erb +66 -0
  68. data/app/views/lesli_shield/roles/_form.html.erb +149 -18
  69. data/app/views/lesli_shield/roles/_management_menu.html.erb +37 -0
  70. data/app/views/lesli_shield/roles/_pagination.html.erb +43 -0
  71. data/app/views/lesli_shield/roles/_role_list.html.erb +116 -0
  72. data/app/views/lesli_shield/roles/_status_badge.html.erb +11 -0
  73. data/app/views/lesli_shield/roles/_type_badge.html.erb +9 -0
  74. data/app/views/lesli_shield/roles/index.html.erb +15 -38
  75. data/app/views/lesli_shield/roles/new.html.erb +11 -0
  76. data/app/views/lesli_shield/roles/show.html.erb +79 -7
  77. data/app/views/lesli_shield/users/_information-card.html.erb +3 -3
  78. data/app/views/lesli_shield/users/_information-form.html.erb +6 -0
  79. data/app/views/lesli_shield/users/_management-privileges.html.erb +2 -2
  80. data/app/views/users/invitations/show.html.erb +142 -0
  81. data/app/views/users/invitations/unavailable.html.erb +19 -0
  82. data/config/locales/devise.en.yml +8 -0
  83. data/config/locales/devise.es.yml +8 -0
  84. data/config/locales/translations.en.yml +313 -78
  85. data/config/locales/translations.es.yml +313 -78
  86. data/config/routes.rb +10 -3
  87. data/db/migrate/v1/0801120110_create_lesli_shield_invites.rb +40 -6
  88. data/lib/lesli_shield/engine.rb +4 -0
  89. data/lib/lesli_shield/router.rb +10 -0
  90. data/lib/lesli_shield/version.rb +2 -2
  91. data/lib/tasks/lesli_shield_tasks.rake +1 -1
  92. data/readme.md +13 -1
  93. metadata +35 -11
  94. data/app/assets/stylesheets/lesli_shield/confirmations.tailwind.css +0 -918
  95. data/app/assets/stylesheets/lesli_shield/devise/oauth.css +0 -33
  96. data/app/assets/stylesheets/lesli_shield/passwords.tailwind.css +0 -873
  97. data/app/assets/stylesheets/lesli_shield/registrations.tailwind.css +0 -908
  98. data/app/assets/stylesheets/lesli_shield/sessions.tailwind.css +0 -984
  99. data/app/assets/stylesheets/lesli_shield/users.css +0 -31
  100. data/app/mailers/lesli_shield/invitation.html.erb +0 -23
  101. data/app/views/lesli_shield/invites/edit.html.erb +0 -12
  102. data/app/views/lesli_shield/role/actions/_form.html.erb +0 -75
@@ -1,67 +1,123 @@
1
- <%#
2
-
3
- Lesli
4
-
5
- Copyright (c) 2026, Lesli Technologies, S. A.
6
-
7
- This program is free software: you can redistribute it and/or modify
8
- it under the terms of the GNU General Public License as published by
9
- the Free Software Foundation, either version 3 of the License, or
10
- (at your option) any later version.
11
-
12
- This program is distributed in the hope that it will be useful,
13
- but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
- GNU General Public License for more details.
16
-
17
- You should have received a copy of the GNU General Public License
18
- along with this program. If not, see http://www.gnu.org/licenses/.
19
-
20
- Lesli · Ruby on Rails SaaS Development Framework.
21
-
22
- Made with ♥ by LesliTech
23
- Building a better future, one line of code at a time.
1
+ <%
2
+ records = @invites.fetch(:records)
3
+ status_filters = [
4
+ [nil, I18n.t("lesli_shield.invites.filter_all")],
5
+ *LesliShield::InviteService::STATUS_FILTERS.map do |status|
6
+ [status, I18n.t("lesli_shield.invites.statuses_#{status}")]
7
+ end
8
+ ]
9
+ %>
24
10
 
25
- @contact hello@lesli.tech
26
- @website https://www.lesli.tech
27
- @license GPLv3 http://www.gnu.org/licenses/gpl-3.0.en.html
11
+ <%= render LesliView::Layout::Container.new("shield-invites") do %>
12
+ <%= render LesliView::Components::Header.new(
13
+ I18n.t("lesli_shield.invites.title"),
14
+ I18n.t("lesli_shield.invites.subtitle")
15
+ ) do %>
16
+ <%= link_to new_invite_path,
17
+ class: "inline-flex h-10 items-center justify-center gap-2 rounded-xl bg-primary px-4 text-sm font-semibold text-white shadow-sm transition hover:bg-primary-strong focus:outline-none focus:ring-4 focus:ring-primary/20" do %>
18
+ <span class="material-symbols" aria-hidden="true">person_add</span>
19
+ <span><%= I18n.t("lesli_shield.invites.action_create") %></span>
20
+ <% end %>
21
+ <% end %>
28
22
 
29
- // · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~
30
- // ·
31
- %>
23
+ <nav
24
+ class="mb-6 flex flex-wrap gap-2"
25
+ aria-label="<%= I18n.t("lesli_shield.invites.filters_label") %>">
26
+ <% status_filters.each do |status, label| %>
27
+ <%
28
+ active = @status_filter == status
29
+ filter_classes = class_names(
30
+ "inline-flex items-center rounded-full border px-3 py-1.5 text-sm font-medium transition focus:outline-none focus:ring-4 focus:ring-primary/10",
31
+ active ?
32
+ "border-primary bg-primary text-white" :
33
+ "border-neutral-200 bg-white text-neutral-600 hover:border-neutral-300 hover:text-neutral-900"
34
+ )
35
+ %>
36
+ <%= link_to label,
37
+ invites_path(status: status),
38
+ class: filter_classes,
39
+ aria: { current: active ? "page" : nil } %>
40
+ <% end %>
41
+ </nav>
32
42
 
33
- <%
34
- columns = [{
35
- field: "id",
36
- label: "ID",
37
- sort: true
38
- }, {
39
- field: "full_name",
40
- label: "Name",
41
- sort: true
42
- }, {
43
- field: "email",
44
- label: "Email",
45
- sort: true
46
- }, {
47
- field: "telephone",
48
- label: "Telephone",
49
- sort: true
50
- }, {
51
- field: "status",
52
- label: "status",
53
- sort: true
54
- }]
55
- %>
56
- <%= render LesliView::Layout::Container.new('shield-invites') do %>
57
- <%= render LesliView::Components::Header.new('Invites') do %>
58
- <%= render(LesliView::Elements::Button.new('Create invitation', url: new_invite_path, icon: "add", solid:true)) %>
59
- <%= render(LesliView::Elements::Button.new(icon: 'refresh')) %>
43
+ <% if records.any? %>
44
+ <div class="overflow-hidden rounded-2xl border border-neutral-200 bg-white shadow-sm">
45
+ <div class="overflow-x-auto">
46
+ <table class="min-w-full divide-y divide-neutral-200">
47
+ <thead class="bg-neutral-50">
48
+ <tr>
49
+ <% %w[recipient role status sent_at expires_at actions].each do |column| %>
50
+ <th scope="col" class="px-5 py-3 text-left text-xs font-semibold uppercase tracking-wide text-neutral-500">
51
+ <%= I18n.t("lesli_shield.invites.column_#{column}") %>
52
+ </th>
53
+ <% end %>
54
+ </tr>
55
+ </thead>
56
+ <tbody class="divide-y divide-neutral-100 bg-white">
57
+ <% records.each do |invite| %>
58
+ <tr class="transition hover:bg-neutral-50/80">
59
+ <td class="whitespace-nowrap px-5 py-4">
60
+ <%= link_to invite_path(invite), class: "block focus:outline-none" do %>
61
+ <span class="block text-sm font-semibold text-neutral-900">
62
+ <%= invite.full_name.presence || invite.email %>
63
+ </span>
64
+ <% if invite.full_name.present? %>
65
+ <span class="mt-0.5 block text-sm text-neutral-500"><%= invite.email %></span>
66
+ <% end %>
67
+ <% end %>
68
+ </td>
69
+ <td class="whitespace-nowrap px-5 py-4 text-sm text-neutral-600">
70
+ <%= invite.role&.name || I18n.t("lesli_shield.invites.value_not_available") %>
71
+ </td>
72
+ <td class="whitespace-nowrap px-5 py-4">
73
+ <%= render "status_badge", invite: invite %>
74
+ </td>
75
+ <td class="whitespace-nowrap px-5 py-4 text-sm text-neutral-600">
76
+ <%= invite.sent_at.present? ? I18n.l(invite.sent_at, format: :short) : "—" %>
77
+ </td>
78
+ <td class="whitespace-nowrap px-5 py-4 text-sm text-neutral-600">
79
+ <%= invite.expires_at.present? ? I18n.l(invite.expires_at, format: :short) : "—" %>
80
+ </td>
81
+ <td class="whitespace-nowrap px-5 py-4">
82
+ <%= render "invite_actions", invite: invite, show_view: true %>
83
+ </td>
84
+ </tr>
85
+ <% end %>
86
+ </tbody>
87
+ </table>
88
+ </div>
89
+ </div>
90
+ <% else %>
91
+ <%
92
+ if @status_filter.present?
93
+ empty_title = I18n.t("lesli_shield.invites.empty_filtered_title")
94
+ empty_description = I18n.t(
95
+ "lesli_shield.invites.empty_filtered_description"
96
+ )
97
+ empty_action = I18n.t(
98
+ "lesli_shield.invites.empty_filtered_action"
99
+ )
100
+ empty_action_path = invites_path
101
+ else
102
+ empty_title = I18n.t("lesli_shield.invites.empty_title")
103
+ empty_description = I18n.t(
104
+ "lesli_shield.invites.empty_description"
105
+ )
106
+ empty_action = I18n.t("lesli_shield.invites.empty_action")
107
+ empty_action_path = new_invite_path
108
+ end
109
+ %>
110
+ <section class="rounded-2xl border border-dashed border-neutral-300 bg-white px-6 py-16 text-center shadow-sm">
111
+ <span class="material-symbols mx-auto mb-4 block text-5xl text-neutral-300" aria-hidden="true">person_add</span>
112
+ <h2 class="text-lg font-semibold text-neutral-900">
113
+ <%= empty_title %>
114
+ </h2>
115
+ <p class="mx-auto mt-2 max-w-md text-sm leading-6 text-neutral-500">
116
+ <%= empty_description %>
117
+ </p>
118
+ <%= link_to empty_action,
119
+ empty_action_path,
120
+ class: "mt-6 inline-flex h-10 items-center justify-center rounded-xl bg-primary px-4 text-sm font-semibold text-white shadow-sm transition hover:bg-primary-strong focus:outline-none focus:ring-4 focus:ring-primary/20" %>
121
+ </section>
60
122
  <% end %>
61
- <%= render LesliView::Components::Toolbar.new() %>
62
- <%= render(LesliView::Elements::Table.new(
63
- columns: columns,
64
- records: @invites[:records],
65
- link: lambda {|invite| invite_path(invite.id) }
66
- )) %>
67
- <% end %>
123
+ <% end %>
@@ -1,36 +1,11 @@
1
- <%#
2
-
3
- Lesli
4
-
5
- Copyright (c) 2023, Lesli Technologies, S. A.
6
-
7
- This program is free software: you can redistribute it and/or modify
8
- it under the terms of the GNU General Public License as published by
9
- the Free Software Foundation, either version 3 of the License, or
10
- (at your option) any later version.
11
-
12
- This program is distributed in the hope that it will be useful,
13
- but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
- GNU General Public License for more details.
16
-
17
- You should have received a copy of the GNU General Public License
18
- along with this program. If not, see http://www.gnu.org/licenses/.
19
-
20
- Lesli · Ruby on Rails SaaS Development Framework.
21
-
22
- Made with ♥ by https://www.lesli.tech
23
- Building a better future, one line of code at a time.
24
-
25
- @contact hello@lesli.tech
26
- @website https://www.lesli.tech
27
- @license GPLv3 http://www.gnu.org/licenses/gpl-3.0.en.html
28
-
29
- // · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~
30
- // ·
31
- %>
32
-
33
- <%= render LesliView::Layout::Container.new('shield-invites') do %>
34
- <%= render LesliView::Components::Header.new('Invites')%>
35
- <%= render "form" %>
36
- <% end %>
1
+ <%= render LesliView::Layout::Container.new("shield-invites") do %>
2
+ <%= render LesliView::Components::Header.new(
3
+ I18n.t("lesli_shield.invites.new_title"),
4
+ I18n.t("lesli_shield.invites.new_description"),
5
+ back: invites_path
6
+ ) %>
7
+
8
+ <div class="max-w-2xl">
9
+ <%= render "form" %>
10
+ </div>
11
+ <% end %>
@@ -1,54 +1,15 @@
1
- <%#
2
-
3
- Lesli
4
-
5
- Copyright (c) 2023, Lesli Technologies, S. A.
6
-
7
- This program is free software: you can redistribute it and/or modify
8
- it under the terms of the GNU General Public License as published by
9
- the Free Software Foundation, either version 3 of the License, or
10
- (at your option) any later version.
11
-
12
- This program is distributed in the hope that it will be useful,
13
- but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
- GNU General Public License for more details.
16
-
17
- You should have received a copy of the GNU General Public License
18
- along with this program. If not, see http://www.gnu.org/licenses/.
19
-
20
- Lesli · Ruby on Rails SaaS Development Framework.
21
-
22
- Made with ♥ by https://www.lesli.tech
23
- Building a better future, one line of code at a time.
24
-
25
- @contact hello@lesli.tech
26
- @website https://www.lesli.tech
27
- @license GPLv3 http://www.gnu.org/licenses/gpl-3.0.en.html
28
-
29
- // · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~
30
- // ·
1
+ <%
2
+ recipient = @invite.full_name.presence || @invite.email
31
3
  %>
32
- <%= render LesliView::Layout::Container.new('shield-invites') do %>
33
- <%= render LesliView::Components::Header.new("Invite for #{ @invite.full_name.presence || @invite.email }") do %>
34
- <%= render(LesliView::Elements::Button.new(
35
- 'Send invitation',
36
- success:true,
37
- solid:true,
38
- icon:'send',
39
- url: invite_path(@invite),
40
- method: :put,
41
- params: { invite: { status: :sent } }
42
- )) %>
43
- <%= render(LesliView::Elements::Button.new(
44
- 'Cancel invitation',
45
- danger:true,
46
- solid:true,
47
- icon:'cancel',
48
- url: invite_path(@invite),
49
- method: :put,
50
- params: { invite: { status: :cancelled } }
51
- )) %>
4
+
5
+ <%= render LesliView::Layout::Container.new("shield-invites") do %>
6
+ <%= render LesliView::Components::Header.new(
7
+ I18n.t("lesli_shield.invites.detail_title", recipient: recipient),
8
+ nil,
9
+ back: invites_path
10
+ ) do %>
11
+ <%= render "invite_actions", invite: @invite, show_view: false %>
52
12
  <% end %>
53
- <%= render "form" %>
54
- <% end %>
13
+
14
+ <%= render "invite", invite: @invite %>
15
+ <% end %>
@@ -0,0 +1,11 @@
1
+ <div id="shield-profile-information-form">
2
+ <% if @user.errors.any? %>
3
+ <div role="alert">
4
+ <% @user.errors.full_messages.each do |message| %>
5
+ <p><%= message %></p>
6
+ <% end %>
7
+ </div>
8
+ <% end %>
9
+
10
+ <%= render "lesli_shield/users/information-form", form_url: profile_path %>
11
+ </div>
@@ -1,5 +1,5 @@
1
1
  <div id="shield-profile-password-form" class="max-w-2xl">
2
- <p class="mb-6 text-sm leading-6 text-slate-600">
2
+ <p class="mb-6 text-sm leading-6 text-neutral-600">
3
3
  <%= I18n.t("lesli_shield.profiles.password_description") %>
4
4
  </p>
5
5
 
@@ -9,10 +9,7 @@
9
9
  title: I18n.t("lesli_shield.profiles.information"),
10
10
  icon: "info"
11
11
  ) do %>
12
- <%= render(
13
- "lesli_shield/users/information-form",
14
- form_url: profile_path
15
- ) %>
12
+ <%= render "lesli_shield/profiles/information-form" %>
16
13
  <% end %>
17
14
 
18
15
  <% tabs.with_tab(
@@ -0,0 +1,24 @@
1
+ <div class="divide-y divide-neutral-200 border-t border-neutral-200" data-custom-actions>
2
+ <h3 class="px-4 py-3 text-sm font-semibold text-neutral-900 sm:px-5">
3
+ <%= t("lesli_shield.roles.permissions_custom_actions") %>
4
+ </h3>
5
+ <% resources.each do |resource| %>
6
+ <fieldset class="px-4 py-5 sm:px-5">
7
+ <legend class="w-full">
8
+ <span class="block text-sm font-semibold text-neutral-900"><%= resource[:label] %></span>
9
+ <span class="mt-0.5 block break-all font-mono text-xs text-neutral-500"><%= resource[:route] %></span>
10
+ </legend>
11
+ <div class="mt-4 grid gap-3 sm:grid-cols-2 xl:grid-cols-3">
12
+ <% resource[:actions].reject { |action| action[:standard] }.each do |action| %>
13
+ <div class="flex min-h-14 items-start gap-3 rounded-xl border border-neutral-200 bg-white p-3">
14
+ <%= render "toggle", action: action %>
15
+ <span class="min-w-0 flex-1">
16
+ <span class="block text-sm font-semibold text-neutral-900"><%= action[:display_label] %></span>
17
+ <span class="mt-0.5 block break-all font-mono text-xs text-neutral-500"><%= action[:action] %></span>
18
+ </span>
19
+ </div>
20
+ <% end %>
21
+ </div>
22
+ </fieldset>
23
+ <% end %>
24
+ </div>
@@ -0,0 +1,14 @@
1
+ <div
2
+ id="role-permission-deployment-status"
3
+ class="flex min-h-10 items-center gap-2 rounded-xl border border-neutral-200 bg-white px-3 shadow-sm"
4
+ >
5
+ <%= render "lesli_shield/roles/deployment_badge", role: @role %>
6
+ <% if @role.deployed_at.present? %>
7
+ <time
8
+ datetime="<%= @role.deployed_at.iso8601 %>"
9
+ class="hidden text-xs text-neutral-500 sm:inline"
10
+ >
11
+ <%= l(@role.deployed_at, format: :short) %>
12
+ </time>
13
+ <% end %>
14
+ </div>
@@ -0,0 +1,69 @@
1
+ <%
2
+ standard_action_names = LesliShield::RolePermissionService::STANDARD_ACTION_ORDER
3
+ %>
4
+
5
+ <% @permission_matrix.each do |engine| %>
6
+ <%
7
+ engine_actions = engine[:resources].flat_map { |resource| resource[:actions] }
8
+ standard_resources = engine[:resources].select { |resource| resource[:actions].any? { |action| action[:standard] } }
9
+ custom_resources = engine[:resources].select { |resource| resource[:actions].any? { |action| !action[:standard] } }
10
+ %>
11
+ <section
12
+ id="permission-engine-<%= engine[:engine].parameterize %>"
13
+ class="scroll-mt-4 overflow-hidden rounded-xl border border-neutral-200 bg-white shadow-sm"
14
+ >
15
+ <header class="flex items-center justify-between gap-4 border-b border-neutral-200 bg-neutral-50 px-4 py-4 sm:px-5">
16
+ <h2 class="font-semibold text-neutral-900"><%= engine[:label] %></h2>
17
+ <p class="text-right text-xs text-neutral-600">
18
+ <%= t(
19
+ "lesli_shield.roles.permissions_module_summary",
20
+ selected: engine_actions.count { |action| action[:assigned] },
21
+ total: engine_actions.size
22
+ ) %>
23
+ </p>
24
+ </header>
25
+
26
+ <% if standard_resources.any? %>
27
+ <table class="block w-full xl:table">
28
+ <thead class="hidden bg-neutral-50 xl:table-header-group">
29
+ <tr>
30
+ <th scope="col" class="px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-neutral-500 sm:px-5">
31
+ <%= t("lesli_shield.roles.permissions_resource") %>
32
+ </th>
33
+ <% standard_action_names.each do |action_name| %>
34
+ <th scope="col" class="px-2 py-3 text-center text-xs font-semibold uppercase tracking-wide text-neutral-500">
35
+ <%= t("lesli_shield.roles.permissions_standard_actions_#{action_name}") %>
36
+ </th>
37
+ <% end %>
38
+ </tr>
39
+ </thead>
40
+ <tbody class="block divide-y divide-neutral-200 xl:table-row-group">
41
+ <% standard_resources.each do |resource| %>
42
+ <tr class="block p-4 xl:table-row xl:p-0">
43
+ <th scope="row" class="block pb-3 text-left xl:table-cell xl:px-5 xl:py-4 xl:align-middle">
44
+ <span class="block text-sm font-semibold text-neutral-900"><%= resource[:label] %></span>
45
+ <span class="mt-0.5 block break-all font-mono text-xs font-normal text-neutral-500"><%= resource[:route] %></span>
46
+ </th>
47
+ <% standard_action_names.each do |action_name| %>
48
+ <% action = resource[:actions].find { |candidate| candidate[:action] == action_name } %>
49
+ <td class="block py-1 xl:table-cell xl:px-2 xl:py-4 xl:text-center xl:align-middle">
50
+ <% if action %>
51
+ <div class="flex min-h-11 items-center justify-between gap-3 rounded-lg px-2 py-2 transition hover:bg-primary-soft xl:flex-col xl:justify-center">
52
+ <span class="text-sm font-medium text-neutral-700 xl:sr-only"><%= action[:display_label] %></span>
53
+ <%= render "toggle", action: action %>
54
+ </div>
55
+ <% else %>
56
+ <span class="hidden text-neutral-300 xl:inline" aria-label="<%= t("lesli_shield.roles.permissions_not_available") %>">—</span>
57
+ <% end %>
58
+ </td>
59
+ <% end %>
60
+ </tr>
61
+ <% end %>
62
+ </tbody>
63
+ </table>
64
+ <% end %>
65
+ <% if custom_resources.any? %>
66
+ <%= render "custom_actions", resources: custom_resources %>
67
+ <% end %>
68
+ </section>
69
+ <% end %>
@@ -0,0 +1,95 @@
1
+ <%
2
+ index_path = if @engine_slug
3
+ engine_role_actions_path(@role, engine_slug: @engine_slug)
4
+ else
5
+ role_actions_path(@role)
6
+ end
7
+
8
+ navigation_items = [{
9
+ label: t("lesli_shield.roles.detail_summary_title"),
10
+ path: role_path(@role),
11
+ selected: false
12
+ }]
13
+ engines = [
14
+ {
15
+ slug: nil,
16
+ label: t("lesli_shield.roles.permissions_all_engines"),
17
+ count: @permission_engines.sum { |engine| engine[:count] }
18
+ },
19
+ *@permission_engines
20
+ ]
21
+ engines.each do |engine|
22
+ path = if engine[:slug]
23
+ engine_role_actions_path(@role, engine_slug: engine[:slug], search: @search.presence)
24
+ else
25
+ role_actions_path(@role, search: @search.presence)
26
+ end
27
+ navigation_items << {
28
+ label: engine[:label],
29
+ count: engine[:count],
30
+ path: path,
31
+ selected: @engine_slug == engine[:slug]
32
+ }
33
+ end
34
+ %>
35
+
36
+ <div id="shield-role-permissions" class="flex min-w-0 flex-col gap-6 lg:flex-row lg:items-start">
37
+ <%= render LesliView::Layout::NavigationSidebar.new(
38
+ items: navigation_items,
39
+ label: t("lesli_shield.roles.permissions_engine_navigation")
40
+ ) %>
41
+ <div class="min-w-0 flex-1 space-y-6">
42
+ <section class="rounded-xl border border-neutral-200 bg-white p-4 shadow-sm sm:p-5" aria-labelledby="permission-tools-title">
43
+ <h2 id="permission-tools-title" class="sr-only">
44
+ <%= t("lesli_shield.roles.permissions_tools") %>
45
+ </h2>
46
+
47
+ <%= form_with(
48
+ url: index_path,
49
+ method: :get,
50
+ data: { turbo_frame: "_top" },
51
+ class: "flex flex-col gap-3 sm:flex-row sm:items-end"
52
+ ) do |form| %>
53
+ <div class="min-w-0 flex-1">
54
+ <%= form.label :search,
55
+ t("lesli_shield.roles.permissions_search_label"),
56
+ class: "block text-sm font-medium text-neutral-700" %>
57
+ <div class="relative mt-1.5">
58
+ <span class="pointer-events-none absolute inset-y-0 left-3 flex items-center text-neutral-400" aria-hidden="true">
59
+ <span class="material-symbols">search</span>
60
+ </span>
61
+ <%= form.search_field :search,
62
+ value: @search,
63
+ autocomplete: "off",
64
+ class: "block min-h-11 w-full rounded-xl border border-neutral-300 bg-white py-2.5 pl-10 pr-3 text-sm text-neutral-900 shadow-sm outline-none transition placeholder:text-neutral-400 focus:border-primary focus:ring-4 focus:ring-primary/10",
65
+ placeholder: t("lesli_shield.roles.permissions_search_placeholder") %>
66
+ </div>
67
+ </div>
68
+ <div class="flex gap-2">
69
+ <%= render LesliView::Elements::Button.new(t("lesli_shield.roles.permissions_search"), type: :submit, icon: "search") %>
70
+ <% if @search.present? %>
71
+ <%= link_to t("lesli_shield.roles.permissions_clear_search"),
72
+ index_path,
73
+ data: { turbo_frame: "_top" },
74
+ class: "inline-flex min-h-11 items-center justify-center rounded-xl border border-neutral-300 bg-white px-4 py-2 text-sm font-semibold text-neutral-700 transition hover:bg-neutral-50 focus-visible:outline-none focus-visible:ring-4 focus-visible:ring-primary/20" %>
75
+ <% end %>
76
+ </div>
77
+ <% end %>
78
+ </section>
79
+
80
+ <div class="min-w-0 space-y-4">
81
+ <% if @permission_matrix.any? %>
82
+ <%= render "matrix" %>
83
+ <% else %>
84
+ <div class="rounded-xl border border-dashed border-neutral-300 bg-neutral-50 px-6 py-10 text-center">
85
+ <% if @search.present? %>
86
+ <p class="text-sm font-semibold text-neutral-800"><%= t("lesli_shield.roles.permissions_no_matches") %></p>
87
+ <p class="mt-1 text-sm text-neutral-500"><%= t("lesli_shield.roles.permissions_no_matches_hint") %></p>
88
+ <% else %>
89
+ <p class="text-sm font-medium text-neutral-700"><%= t("lesli_shield.roles.permissions_empty") %></p>
90
+ <% end %>
91
+ </div>
92
+ <% end %>
93
+ </div>
94
+ </div>
95
+ </div>
@@ -0,0 +1,34 @@
1
+ <%
2
+ enabled = action[:assigned]
3
+ route_options = { search: @search.presence }
4
+ route_options[:engine_slug] = @engine_slug if @engine_slug
5
+ path = if enabled
6
+ role_action_path(@role, action[:id], **route_options)
7
+ else
8
+ role_actions_path(@role, **route_options)
9
+ end
10
+ method = enabled ? :delete : :post
11
+ request_params = enabled ? {} : { action_id: action[:id] }
12
+ label = t(
13
+ "lesli_shield.roles.permissions_toggle",
14
+ action: action[:display_label],
15
+ state: t("lesli_shield.roles.permissions_states_#{enabled ? 'enabled' : 'disabled'}")
16
+ )
17
+ %>
18
+
19
+ <%= button_to(
20
+ path,
21
+ method: method,
22
+ params: request_params,
23
+ form: { class: "shrink-0" },
24
+ class: class_names(
25
+ "inline-flex size-6 items-center justify-center rounded-md border transition focus-visible:outline-none focus-visible:ring-4 focus-visible:ring-primary/20",
26
+ "border-primary bg-primary text-white hover:bg-primary-strong" => enabled,
27
+ "border-neutral-300 bg-white text-transparent hover:border-primary" => !enabled
28
+ ),
29
+ role: "switch",
30
+ aria: { checked: enabled, label: label },
31
+ data: { turbo_submits_with: "…" }
32
+ ) do %>
33
+ <span class="material-symbols text-lg" aria-hidden="true">check</span>
34
+ <% end %>
@@ -1,14 +1,17 @@
1
1
  <%= render LesliView::Layout::Container.new("shield-role-actions") do %>
2
- <%= render LesliView::Components::Header.new("#{@role.name} privileges", :back => role_path(@role)) do %>
3
- <%= render(LesliView::Elements::Button.new('Deploy privileges',
4
- solid:true,
5
- danger:true,
6
- icon: 'shield',
7
- css_class: 'is-light is-hovered',
8
- url: deploy_role_path(@role.id),
2
+ <%= render LesliView::Components::Header.new(
3
+ t("lesli_shield.roles.permissions_title", role: @role.name),
4
+ back: role_path(@role)
5
+ ) do %>
6
+ <%= render "deployment_status" %>
7
+ <%= render(LesliView::Elements::Button.new(
8
+ t("lesli_shield.roles.permissions_deploy"),
9
+ solid: true,
10
+ icon: "shield",
11
+ url: deploy_role_path(@role, engine_slug: @engine_slug, search: @search.presence),
9
12
  method: :post
10
-
11
13
  )) %>
12
14
  <% end %>
13
- <%= render "form" %>
14
- <% end %>
15
+
16
+ <%= render "permissions" %>
17
+ <% end %>
@@ -0,0 +1,15 @@
1
+ <%
2
+ status = role.permissions_deployment_status
3
+ styles = {
4
+ pending: "bg-warning-100 text-warning-800 ring-warning-200",
5
+ deployed: "bg-success-100 text-success-700 ring-success-200",
6
+ never_deployed: "bg-neutral-100 text-neutral-600 ring-neutral-200"
7
+ }
8
+ %>
9
+
10
+ <span
11
+ class="inline-flex items-center rounded-full px-2.5 py-1 text-xs font-semibold ring-1 ring-inset <%= styles.fetch(status) %>"
12
+ data-role-deployment-status="<%= status %>"
13
+ >
14
+ <%= t("lesli_shield.roles.deployment_statuses_#{status}") %>
15
+ </span>
@@ -0,0 +1,20 @@
1
+ <%
2
+ filtered = filters.values.any?(&:present?)
3
+ title_key = filtered ? "empty_filtered_title" : "empty_title"
4
+ description_key = filtered ? "empty_filtered_description" : "empty_description"
5
+ action_key = filtered ? "empty_filtered_action" : "action_create"
6
+ action_path = filtered ? roles_path : new_role_path
7
+ %>
8
+
9
+ <section class="rounded-2xl border border-dashed border-neutral-300 bg-white px-6 py-16 text-center shadow-sm">
10
+ <span class="material-symbols mx-auto block text-5xl text-neutral-300" aria-hidden="true">admin_panel_settings</span>
11
+ <h2 class="mt-4 text-lg font-semibold text-neutral-900">
12
+ <%= t("lesli_shield.roles.#{title_key}") %>
13
+ </h2>
14
+ <p class="mx-auto mt-2 max-w-md text-sm leading-6 text-neutral-500">
15
+ <%= t("lesli_shield.roles.#{description_key}") %>
16
+ </p>
17
+ <%= render LesliView::Elements::Button.new(t("lesli_shield.roles.#{action_key}"),
18
+ url: action_path,
19
+ solid: false, data: { turbo_frame: "_top" }) %>
20
+ </section>