lesli_shield 1.1.6 → 1.1.8
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.
- checksums.yaml +4 -4
- data/Rakefile +3 -0
- data/app/assets/stylesheets/lesli_shield/application.css +1222 -1
- data/app/assets/stylesheets/lesli_shield/confirmations.css +917 -18
- data/app/assets/stylesheets/lesli_shield/confirmations.tailwind.css +918 -0
- data/app/assets/stylesheets/lesli_shield/invitations.css +1008 -0
- data/app/assets/stylesheets/lesli_shield/passwords.css +872 -18
- data/app/assets/stylesheets/lesli_shield/passwords.tailwind.css +873 -0
- data/app/assets/stylesheets/lesli_shield/registrations.css +904 -832
- data/app/assets/stylesheets/lesli_shield/registrations.tailwind.css +908 -0
- data/app/assets/stylesheets/lesli_shield/sessions.css +984 -32
- data/app/assets/stylesheets/lesli_shield/sessions.tailwind.css +983 -1
- data/app/controllers/lesli_shield/invites_controller.rb +100 -49
- data/app/controllers/lesli_shield/profile/passwords_controller.rb +119 -0
- data/app/controllers/lesli_shield/profiles_controller.rb +69 -0
- data/app/controllers/lesli_shield/role/actions_controller.rb +134 -38
- data/app/controllers/lesli_shield/roles_controller.rb +114 -141
- data/app/controllers/lesli_shield/sessions_controller.rb +1 -2
- data/app/controllers/lesli_shield/users_controller.rb +11 -4
- data/app/controllers/users/confirmations_controller.rb +162 -49
- data/app/controllers/users/invitations_controller.rb +101 -0
- data/app/controllers/users/passwords_controller.rb +211 -28
- data/app/controllers/users/registrations_controller.rb +108 -83
- data/app/controllers/users/sessions_controller.rb +124 -84
- data/app/interfaces/lesli_shield/authorization_interface.rb +2 -2
- data/app/jobs/lesli_shield/invitation_delivery_job.rb +123 -0
- data/app/mailers/lesli_shield/devise_mailer.rb +73 -17
- data/app/mailers/lesli_shield/invitation_mailer.rb +58 -0
- data/app/models/concerns/lesli_shield/role_management.rb +70 -0
- data/app/models/concerns/lesli_shield/user_authentication.rb +54 -0
- data/app/models/concerns/lesli_shield/user_security.rb +22 -19
- data/app/models/lesli_shield/account.rb +4 -1
- data/app/models/lesli_shield/invite.rb +183 -12
- data/app/models/lesli_shield/user/role.rb +1 -1
- data/app/models/lesli_shield/user.rb +5 -2
- data/app/services/lesli_shield/invitation_audit.rb +34 -0
- data/app/services/lesli_shield/invitation_email_policy.rb +64 -0
- data/app/services/lesli_shield/invitation_service.rb +405 -0
- data/app/services/lesli_shield/invite_service.rb +34 -5
- data/app/services/lesli_shield/profile/password_service.rb +47 -0
- data/app/services/lesli_shield/profile_service.rb +25 -0
- data/app/services/lesli_shield/role_action_service.rb +37 -92
- data/app/services/lesli_shield/role_audit.rb +42 -0
- data/app/services/lesli_shield/role_permission_service.rb +347 -0
- data/app/services/lesli_shield/role_privilege_deployment_service.rb +79 -0
- data/app/services/lesli_shield/role_privilege_service.rb +69 -105
- data/app/services/lesli_shield/role_service.rb +431 -0
- data/app/services/lesli_shield/user_registration_service.rb +41 -74
- data/app/services/lesli_shield/user_session_service.rb +1 -1
- data/app/services/lesli_shield/user_validator_service.rb +37 -39
- data/app/views/devise/confirmations/new.html.erb +58 -12
- data/app/views/devise/confirmations/show.html.erb +27 -60
- data/app/views/devise/passwords/edit.html.erb +59 -25
- data/app/views/devise/passwords/new.html.erb +61 -26
- data/app/views/devise/registrations/new.html.erb +83 -56
- data/app/views/devise/sessions/new.html.erb +58 -41
- data/app/views/devise/shared/_application-devise-simple.erb +18 -19
- data/app/views/devise/shared/_demo.html.erb +8 -6
- data/app/views/devise/shared/_error_messages.html.erb +45 -10
- data/app/views/devise/shared/_links.html.erb +10 -20
- data/app/views/lesli_shield/invites/_form.html.erb +64 -7
- data/app/views/lesli_shield/invites/_invite.html.erb +55 -2
- data/app/views/lesli_shield/invites/_invite_actions.html.erb +34 -0
- data/app/views/lesli_shield/invites/_status_badge.html.erb +13 -0
- data/app/views/lesli_shield/invites/index.html.erb +119 -62
- data/app/views/lesli_shield/invites/new.html.erb +11 -36
- data/app/views/lesli_shield/invites/show.html.erb +13 -52
- data/app/views/lesli_shield/profiles/_information-form.html.erb +11 -0
- data/app/views/lesli_shield/profiles/_password-form.html.erb +68 -0
- data/app/views/lesli_shield/profiles/show.html.erb +26 -0
- data/app/views/lesli_shield/role/actions/_custom_actions.html.erb +24 -0
- data/app/views/lesli_shield/role/actions/_deployment_status.html.erb +14 -0
- data/app/views/lesli_shield/role/actions/_matrix.html.erb +69 -0
- data/app/views/lesli_shield/role/actions/_permissions.html.erb +95 -0
- data/app/views/lesli_shield/role/actions/_toggle.html.erb +34 -0
- data/app/views/lesli_shield/role/actions/index.html.erb +14 -10
- data/app/views/lesli_shield/roles/_deployment_badge.html.erb +15 -0
- data/app/views/lesli_shield/roles/_empty_state.html.erb +20 -0
- data/app/views/lesli_shield/roles/_field_errors.html.erb +5 -0
- data/app/views/lesli_shield/roles/_filters.html.erb +66 -0
- data/app/views/lesli_shield/roles/_form.html.erb +149 -18
- data/app/views/lesli_shield/roles/_management_menu.html.erb +37 -0
- data/app/views/lesli_shield/roles/_pagination.html.erb +43 -0
- data/app/views/lesli_shield/roles/_role_list.html.erb +116 -0
- data/app/views/lesli_shield/roles/_status_badge.html.erb +11 -0
- data/app/views/lesli_shield/roles/_type_badge.html.erb +9 -0
- data/app/views/lesli_shield/roles/index.html.erb +15 -38
- data/app/views/lesli_shield/roles/new.html.erb +11 -0
- data/app/views/lesli_shield/roles/show.html.erb +79 -7
- data/app/views/lesli_shield/users/_information-form.html.erb +15 -1
- data/app/views/users/invitations/show.html.erb +142 -0
- data/app/views/users/invitations/unavailable.html.erb +19 -0
- data/config/initializers/devise.rb +52 -328
- data/config/locales/devise.en.yml +8 -0
- data/config/locales/devise.es.yml +8 -0
- data/config/locales/translations.en.yml +314 -16
- data/config/locales/translations.es.yml +314 -16
- data/config/routes.rb +14 -3
- data/db/migrate/v1/0801120110_create_lesli_shield_invites.rb +40 -6
- data/lib/lesli_shield/engine.rb +42 -4
- data/lib/lesli_shield/router.rb +62 -18
- data/lib/lesli_shield/version.rb +2 -2
- data/lib/tasks/lesli_shield_tasks.rake +1 -1
- data/readme.md +17 -3
- metadata +63 -8
- data/app/assets/config/lesli_shield_manifest.js +0 -48
- data/app/assets/stylesheets/lesli_shield/application.tailwind.css +0 -2
- data/app/mailers/lesli_shield/invitation.html.erb +0 -23
- data/app/views/lesli_shield/invites/edit.html.erb +0 -12
- data/app/views/lesli_shield/role/actions/_form.html.erb +0 -75
|
@@ -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-slate-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-slate-700" %>
|
|
57
|
+
<div class="relative mt-1.5">
|
|
58
|
+
<span class="pointer-events-none absolute inset-y-0 left-3 flex items-center text-slate-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-slate-300 bg-white py-2.5 pl-10 pr-3 text-sm text-slate-900 shadow-sm outline-none transition placeholder:text-slate-400 focus:border-sky-500 focus:ring-4 focus:ring-sky-500/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-slate-300 bg-white px-4 py-2 text-sm font-semibold text-slate-700 transition hover:bg-slate-50 focus-visible:outline-none focus-visible:ring-4 focus-visible:ring-sky-500/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-slate-300 bg-slate-50 px-6 py-10 text-center">
|
|
85
|
+
<% if @search.present? %>
|
|
86
|
+
<p class="text-sm font-semibold text-slate-800"><%= t("lesli_shield.roles.permissions_no_matches") %></p>
|
|
87
|
+
<p class="mt-1 text-sm text-slate-500"><%= t("lesli_shield.roles.permissions_no_matches_hint") %></p>
|
|
88
|
+
<% else %>
|
|
89
|
+
<p class="text-sm font-medium text-slate-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-sky-500/20",
|
|
26
|
+
"border-sky-600 bg-sky-600 text-white hover:bg-sky-700" => enabled,
|
|
27
|
+
"border-slate-300 bg-white text-transparent hover:border-sky-500" => !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,18 @@
|
|
|
1
1
|
<%= render LesliView::Layout::Container.new("shield-role-actions") do %>
|
|
2
|
-
<%= render LesliView::Components::Header.new(
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
+
danger: true,
|
|
11
|
+
icon: "shield",
|
|
12
|
+
url: deploy_role_path(@role, engine_slug: @engine_slug, search: @search.presence),
|
|
9
13
|
method: :post
|
|
10
|
-
|
|
11
14
|
)) %>
|
|
12
15
|
<% end %>
|
|
13
|
-
|
|
14
|
-
|
|
16
|
+
|
|
17
|
+
<%= render "permissions" %>
|
|
18
|
+
<% end %>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<%
|
|
2
|
+
status = role.permissions_deployment_status
|
|
3
|
+
styles = {
|
|
4
|
+
pending: "bg-amber-100 text-amber-800 ring-amber-200",
|
|
5
|
+
deployed: "bg-emerald-100 text-emerald-700 ring-emerald-200",
|
|
6
|
+
never_deployed: "bg-slate-100 text-slate-600 ring-slate-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-slate-300 bg-white px-6 py-16 text-center shadow-sm">
|
|
10
|
+
<span class="material-symbols mx-auto block text-5xl text-slate-300" aria-hidden="true">admin_panel_settings</span>
|
|
11
|
+
<h2 class="mt-4 text-lg font-semibold text-slate-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-slate-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>
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
<%= form_with url: roles_path,
|
|
2
|
+
method: :get,
|
|
3
|
+
local: true,
|
|
4
|
+
class: "mb-6 rounded-2xl border border-slate-200 bg-white p-4 shadow-sm",
|
|
5
|
+
role: "search",
|
|
6
|
+
data: { turbo_frame: "_top" } do %>
|
|
7
|
+
|
|
8
|
+
<% %w[perPage orderBy order].each do |parameter| %>
|
|
9
|
+
<%= hidden_field_tag parameter, params[parameter] if params[parameter].present? %>
|
|
10
|
+
<% end %>
|
|
11
|
+
|
|
12
|
+
<div class="grid gap-3 lg:grid-cols-[minmax(16rem,1fr)_13rem_13rem_auto] lg:items-end">
|
|
13
|
+
<div>
|
|
14
|
+
<%= label_tag :search,
|
|
15
|
+
t("lesli_shield.roles.filters_search_label"),
|
|
16
|
+
class: "mb-1.5 block text-sm font-medium text-slate-700" %>
|
|
17
|
+
<div class="relative">
|
|
18
|
+
<span class="material-symbols pointer-events-none absolute left-3 top-1/2 -translate-y-1/2 text-xl text-slate-400" aria-hidden="true">search</span>
|
|
19
|
+
<%= search_field_tag :search,
|
|
20
|
+
filters[:search],
|
|
21
|
+
placeholder: t("lesli_shield.roles.filters_search_placeholder"),
|
|
22
|
+
autocomplete: "off",
|
|
23
|
+
class: "h-11 w-full rounded-xl border border-slate-300 bg-white py-2 pl-10 pr-10 text-sm text-slate-900 outline-none transition placeholder:text-slate-400 hover:border-slate-400 focus:border-sky-500 focus:ring-4 focus:ring-sky-500/10" %>
|
|
24
|
+
<% if filters[:search].present? %>
|
|
25
|
+
<%= link_to roles_path(request.query_parameters.except("search", "page")),
|
|
26
|
+
class: "absolute right-2 top-1/2 inline-flex h-7 w-7 -translate-y-1/2 items-center justify-center rounded-lg text-slate-400 transition hover:bg-slate-100 hover:text-slate-700",
|
|
27
|
+
data: { turbo_frame: "_top" },
|
|
28
|
+
aria: { label: t("lesli_shield.roles.filters_clear_search") } do %>
|
|
29
|
+
<span class="material-symbols text-lg" aria-hidden="true">close</span>
|
|
30
|
+
<% end %>
|
|
31
|
+
<% end %>
|
|
32
|
+
</div>
|
|
33
|
+
</div>
|
|
34
|
+
|
|
35
|
+
<div>
|
|
36
|
+
<%= label_tag :status,
|
|
37
|
+
t("lesli_shield.roles.filters_status_label"),
|
|
38
|
+
class: "mb-1.5 block text-sm font-medium text-slate-700" %>
|
|
39
|
+
<%= select_tag :status,
|
|
40
|
+
options_for_select([
|
|
41
|
+
[t("lesli_shield.roles.filters_status_all"), ""],
|
|
42
|
+
[t("lesli_shield.roles.statuses_active"), "active"],
|
|
43
|
+
[t("lesli_shield.roles.statuses_inactive"), "inactive"]
|
|
44
|
+
], filters[:status]),
|
|
45
|
+
class: "h-11 w-full rounded-xl border border-slate-300 bg-white px-3 text-sm text-slate-700 outline-none transition hover:border-slate-400 focus:border-sky-500 focus:ring-4 focus:ring-sky-500/10" %>
|
|
46
|
+
</div>
|
|
47
|
+
|
|
48
|
+
<div>
|
|
49
|
+
<%= label_tag :type,
|
|
50
|
+
t("lesli_shield.roles.filters_type_label"),
|
|
51
|
+
class: "mb-1.5 block text-sm font-medium text-slate-700" %>
|
|
52
|
+
<%= select_tag :type,
|
|
53
|
+
options_for_select([
|
|
54
|
+
[t("lesli_shield.roles.filters_type_all"), ""],
|
|
55
|
+
[t("lesli_shield.roles.types_system"), "system"],
|
|
56
|
+
[t("lesli_shield.roles.types_custom"), "custom"]
|
|
57
|
+
], filters[:type]),
|
|
58
|
+
class: "h-11 w-full rounded-xl border border-slate-300 bg-white px-3 text-sm text-slate-700 outline-none transition hover:border-slate-400 focus:border-sky-500 focus:ring-4 focus:ring-sky-500/10" %>
|
|
59
|
+
</div>
|
|
60
|
+
|
|
61
|
+
<%= render LesliView::Elements::Button.new(
|
|
62
|
+
t("lesli_shield.roles.filters_submit"), type: :submit, icon: "filter_alt",
|
|
63
|
+
data: { turbo_submits_with: t("lesli_shield.roles.filters_loading") }
|
|
64
|
+
) %>
|
|
65
|
+
</div>
|
|
66
|
+
<% end %>
|
|
@@ -1,21 +1,152 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
<%
|
|
2
|
+
editable = @role.new_record? || @role_editable
|
|
3
|
+
input_classes = "mt-1.5 block w-full rounded-xl border border-slate-300 bg-white px-3 py-2.5 text-sm text-slate-900 shadow-sm outline-none transition placeholder:text-slate-400 hover:border-slate-400 focus:border-sky-500 focus:ring-4 focus:ring-sky-500/10 disabled:cursor-not-allowed disabled:bg-slate-50 disabled:text-slate-500"
|
|
4
|
+
error_input_classes = "border-red-400 focus:border-red-500 focus:ring-red-500/10"
|
|
5
|
+
members_count = @role_summary&.fetch(:members, 0).to_i
|
|
6
|
+
members_plural = members_count == 1 ? "one" : "other"
|
|
7
|
+
%>
|
|
8
|
+
|
|
9
|
+
<div id="role-form">
|
|
10
|
+
<%= form_with model: @role,
|
|
11
|
+
id: "role-form-fields",
|
|
12
|
+
class: "space-y-6",
|
|
13
|
+
data: { turbo: true, turbo_frame: "_top" } do |form| %>
|
|
14
|
+
<% if @role.errors.any? %>
|
|
15
|
+
<div class="rounded-xl border border-red-200 bg-red-50 p-4" role="alert">
|
|
16
|
+
<div class="flex gap-3">
|
|
17
|
+
<span class="material-symbols text-red-500" aria-hidden="true">error</span>
|
|
18
|
+
<div>
|
|
19
|
+
<h2 class="text-sm font-semibold text-red-800">
|
|
20
|
+
<%= t("lesli_shield.roles.form_errors_title") %>
|
|
21
|
+
</h2>
|
|
22
|
+
<ul class="mt-2 list-disc space-y-1 pl-5 text-sm text-red-700">
|
|
23
|
+
<% @role.errors.full_messages.each do |message| %>
|
|
24
|
+
<li><%= message %></li>
|
|
25
|
+
<% end %>
|
|
26
|
+
</ul>
|
|
27
|
+
</div>
|
|
28
|
+
</div>
|
|
7
29
|
</div>
|
|
8
|
-
|
|
9
|
-
|
|
30
|
+
<% end %>
|
|
31
|
+
|
|
32
|
+
<div class="space-y-5">
|
|
33
|
+
<div>
|
|
34
|
+
<%= form.label :name, t("lesli_shield.roles.fields_name"), class: "block text-sm font-medium text-slate-700" %>
|
|
35
|
+
<%= form.text_field :name,
|
|
36
|
+
autofocus: @role.new_record?,
|
|
37
|
+
disabled: !editable,
|
|
38
|
+
autocomplete: "off",
|
|
39
|
+
class: class_names(input_classes, error_input_classes => @role.errors[:name].any?) %>
|
|
40
|
+
<%= render "field_errors", record: @role, attribute: :name %>
|
|
41
|
+
</div>
|
|
42
|
+
|
|
43
|
+
<div>
|
|
44
|
+
<%= form.label :description, t("lesli_shield.roles.fields_description"), class: "block text-sm font-medium text-slate-700" %>
|
|
45
|
+
<%= form.text_area :description,
|
|
46
|
+
rows: 4,
|
|
47
|
+
disabled: !editable,
|
|
48
|
+
class: class_names(input_classes, "resize-y", error_input_classes => @role.errors[:description].any?) %>
|
|
49
|
+
<p class="mt-1.5 text-xs leading-5 text-slate-500">
|
|
50
|
+
<%= t("lesli_shield.roles.form_description_hint") %>
|
|
51
|
+
</p>
|
|
52
|
+
<%= render "field_errors", record: @role, attribute: :description %>
|
|
53
|
+
</div>
|
|
54
|
+
</div>
|
|
55
|
+
|
|
56
|
+
<% if @role.new_record? %>
|
|
57
|
+
<fieldset class="border-t border-slate-200 pt-6">
|
|
58
|
+
<legend class="text-sm font-medium text-slate-700">
|
|
59
|
+
<%= t("lesli_shield.roles.fields_status") %>
|
|
60
|
+
</legend>
|
|
61
|
+
|
|
62
|
+
<div class="mt-3 grid gap-3 sm:grid-cols-2">
|
|
63
|
+
<% [true, false].each do |active| %>
|
|
64
|
+
<label class="relative flex cursor-pointer gap-3 rounded-xl border border-slate-200 bg-white p-4 transition hover:border-sky-300 hover:bg-sky-50/40 has-[:checked]:border-sky-500 has-[:checked]:ring-4 has-[:checked]:ring-sky-500/10">
|
|
65
|
+
<%= form.radio_button :active,
|
|
66
|
+
active,
|
|
67
|
+
class: "mt-0.5 h-4 w-4 border-slate-300 text-sky-600 focus:ring-sky-500" %>
|
|
68
|
+
<span>
|
|
69
|
+
<span class="block text-sm font-semibold text-slate-900">
|
|
70
|
+
<%= t("lesli_shield.roles.statuses_#{active ? 'active' : 'inactive'}") %>
|
|
71
|
+
</span>
|
|
72
|
+
<span class="mt-1 block text-xs leading-5 text-slate-500">
|
|
73
|
+
<%= t("lesli_shield.roles.form_status_#{active ? 'active' : 'inactive'}_hint") %>
|
|
74
|
+
</span>
|
|
75
|
+
</span>
|
|
76
|
+
</label>
|
|
77
|
+
<% end %>
|
|
78
|
+
</div>
|
|
79
|
+
<%= render "field_errors", record: @role, attribute: :active %>
|
|
80
|
+
</fieldset>
|
|
81
|
+
<% end %>
|
|
82
|
+
|
|
83
|
+
<div class="space-y-5 border-t border-slate-200 pt-6">
|
|
84
|
+
<div>
|
|
85
|
+
<%= form.label :permission_level, t("lesli_shield.roles.fields_permission_level"), class: "block text-sm font-medium text-slate-700" %>
|
|
86
|
+
<%= form.number_field :permission_level,
|
|
87
|
+
min: 0,
|
|
88
|
+
max: current_user.max_level_permission,
|
|
89
|
+
step: 1,
|
|
90
|
+
required: true,
|
|
91
|
+
disabled: !editable,
|
|
92
|
+
inputmode: "numeric",
|
|
93
|
+
class: class_names(input_classes, error_input_classes => @role.errors[:permission_level].any?) %>
|
|
94
|
+
<p class="mt-1.5 text-xs leading-5 text-slate-500">
|
|
95
|
+
<%= t("lesli_shield.roles.form_permission_level_hint", maximum: current_user.max_level_permission) %>
|
|
96
|
+
</p>
|
|
97
|
+
<%= render "field_errors", record: @role, attribute: :permission_level %>
|
|
98
|
+
</div>
|
|
99
|
+
|
|
100
|
+
<div>
|
|
101
|
+
<%= form.label :path_default, t("lesli_shield.roles.fields_path_default"), class: "block text-sm font-medium text-slate-700" %>
|
|
102
|
+
<%= form.text_field :path_default,
|
|
103
|
+
disabled: !editable,
|
|
104
|
+
placeholder: "/dashboard",
|
|
105
|
+
class: class_names(input_classes, error_input_classes => @role.errors[:path_default].any?) %>
|
|
106
|
+
<p class="mt-1.5 text-xs leading-5 text-slate-500">
|
|
107
|
+
<%= t("lesli_shield.roles.form_path_default_hint") %>
|
|
108
|
+
</p>
|
|
109
|
+
<%= render "field_errors", record: @role, attribute: :path_default %>
|
|
10
110
|
</div>
|
|
11
111
|
</div>
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
112
|
+
|
|
113
|
+
<% if editable %>
|
|
114
|
+
<div class="flex flex-col gap-3 border-t border-slate-200 pt-6 sm:flex-row sm:items-center sm:justify-between">
|
|
115
|
+
<div>
|
|
116
|
+
<% if @role.persisted? %>
|
|
117
|
+
<% if @role.active? %>
|
|
118
|
+
<%= render LesliView::Elements::Button.new(t("lesli_shield.roles.detail_deactivate"),
|
|
119
|
+
type: "submit",
|
|
120
|
+
name: "role[active]",
|
|
121
|
+
value: false,
|
|
122
|
+
warning: true,
|
|
123
|
+
data: {
|
|
124
|
+
turbo_confirm: t("lesli_shield.roles.detail_confirm_deactivate_#{members_plural}", role: @role.name, count: members_count),
|
|
125
|
+
turbo_submits_with: t("lesli_shield.roles.detail_deactivating")
|
|
126
|
+
}) %>
|
|
127
|
+
<% else %>
|
|
128
|
+
<%= render LesliView::Elements::Button.new(t("lesli_shield.roles.detail_activate"),
|
|
129
|
+
type: "submit",
|
|
130
|
+
name: "role[active]",
|
|
131
|
+
value: true,
|
|
132
|
+
success: true,
|
|
133
|
+
data: { turbo_submits_with: t("lesli_shield.roles.detail_activating") }) %>
|
|
134
|
+
<% end %>
|
|
135
|
+
<% end %>
|
|
136
|
+
</div>
|
|
137
|
+
|
|
138
|
+
<div class="flex flex-col-reverse gap-3 sm:flex-row sm:justify-end">
|
|
139
|
+
<%= render LesliView::Elements::Button.new(t("lesli_shield.roles.form_cancel"),
|
|
140
|
+
url: @role.persisted? ? role_path(@role) : roles_path,
|
|
141
|
+
solid: false, data: { turbo_frame: "_top" }) %>
|
|
142
|
+
<%= render LesliView::Elements::Button.new(@role.persisted? ? t("lesli_shield.roles.action_update") : t("lesli_shield.roles.action_create"),
|
|
143
|
+
type: :submit, data: { turbo_submits_with: t("lesli_shield.roles.action_saving") }) %>
|
|
144
|
+
</div>
|
|
145
|
+
</div>
|
|
146
|
+
<% else %>
|
|
147
|
+
<div class="rounded-xl border border-amber-200 bg-amber-50 p-4 text-sm leading-6 text-amber-800">
|
|
148
|
+
<%= t("lesli_shield.roles.form_protected_notice") %>
|
|
149
|
+
</div>
|
|
150
|
+
<% end %>
|
|
151
|
+
<% end %>
|
|
152
|
+
</div>
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<details class="group inline-block text-left">
|
|
2
|
+
<summary
|
|
3
|
+
class="inline-flex h-9 w-9 cursor-pointer list-none items-center justify-center rounded-lg text-slate-500 transition hover:bg-slate-100 hover:text-slate-800 focus:outline-none focus:ring-4 focus:ring-sky-500/10 [&::-webkit-details-marker]:hidden"
|
|
4
|
+
aria-label="<%= t("lesli_shield.roles.action_menu", role: role.name) %>">
|
|
5
|
+
<span class="material-symbols" aria-hidden="true">more_vert</span>
|
|
6
|
+
</summary>
|
|
7
|
+
|
|
8
|
+
<div class="absolute right-5 z-20 mt-2 w-52 overflow-hidden rounded-xl border border-slate-200 bg-white p-1.5 text-left shadow-xl">
|
|
9
|
+
<%= link_to role_path(role),
|
|
10
|
+
class: "flex items-center gap-2 rounded-lg px-3 py-2 text-sm font-medium text-slate-700 transition hover:bg-slate-50 hover:text-slate-950",
|
|
11
|
+
data: { turbo_frame: "_top" } do %>
|
|
12
|
+
<span class="material-symbols text-lg" aria-hidden="true"><%= role.protected_role? ? "visibility" : "settings" %></span>
|
|
13
|
+
<span><%= role.protected_role? ? t("lesli_shield.roles.action_view") : t("lesli_shield.roles.action_manage") %></span>
|
|
14
|
+
<% end %>
|
|
15
|
+
|
|
16
|
+
<% unless role.protected_role? %>
|
|
17
|
+
<%= link_to role_actions_path(role),
|
|
18
|
+
class: "flex items-center gap-2 rounded-lg px-3 py-2 text-sm font-medium text-slate-700 transition hover:bg-slate-50 hover:text-slate-950",
|
|
19
|
+
data: { turbo_frame: "_top" } do %>
|
|
20
|
+
<span class="material-symbols text-lg" aria-hidden="true">key</span>
|
|
21
|
+
<span><%= t("lesli_shield.roles.action_permissions") %></span>
|
|
22
|
+
<% end %>
|
|
23
|
+
<% end %>
|
|
24
|
+
|
|
25
|
+
<% if role.deletable_by?(current_user) %>
|
|
26
|
+
<div class="my-1 border-t border-slate-100"></div>
|
|
27
|
+
<%= render LesliView::Elements::Button.new(
|
|
28
|
+
t("lesli_shield.roles.action_delete"), url: role_path(role),
|
|
29
|
+
method: :delete, icon: "delete", danger: true, solid: false,
|
|
30
|
+
data: {
|
|
31
|
+
turbo_confirm: t("lesli_shield.roles.confirm_delete", role: role.name),
|
|
32
|
+
turbo_submits_with: t("lesli_shield.roles.action_deleting")
|
|
33
|
+
}
|
|
34
|
+
) %>
|
|
35
|
+
<% end %>
|
|
36
|
+
</div>
|
|
37
|
+
</details>
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
<% if pagination[:total].positive? %>
|
|
2
|
+
<nav class="mt-6 flex flex-col gap-3 rounded-2xl border border-slate-200 bg-white px-4 py-3 shadow-sm sm:flex-row sm:items-center sm:justify-between" aria-label="<%= t("lesli_shield.roles.pagination_label") %>">
|
|
3
|
+
<p class="text-sm text-slate-600">
|
|
4
|
+
<%= t(
|
|
5
|
+
"lesli_shield.roles.pagination_summary",
|
|
6
|
+
count: pagination[:results],
|
|
7
|
+
total: pagination[:total]
|
|
8
|
+
) %>
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
<div class="flex items-center justify-between gap-3 sm:justify-end">
|
|
12
|
+
<% if pagination[:page] > 1 %>
|
|
13
|
+
<%= link_to t("lesli_shield.roles.pagination_previous"),
|
|
14
|
+
roles_path(request.query_parameters.merge(page: pagination[:page] - 1)),
|
|
15
|
+
class: "inline-flex h-9 items-center rounded-lg border border-slate-300 bg-white px-3 text-sm font-medium text-slate-700 transition hover:border-sky-300 hover:bg-sky-50 hover:text-sky-700",
|
|
16
|
+
data: { turbo_frame: "_top" } %>
|
|
17
|
+
<% else %>
|
|
18
|
+
<span class="inline-flex h-9 cursor-not-allowed items-center rounded-lg border border-slate-200 bg-slate-50 px-3 text-sm font-medium text-slate-400">
|
|
19
|
+
<%= t("lesli_shield.roles.pagination_previous") %>
|
|
20
|
+
</span>
|
|
21
|
+
<% end %>
|
|
22
|
+
|
|
23
|
+
<span class="text-sm font-medium text-slate-600">
|
|
24
|
+
<%= t(
|
|
25
|
+
"lesli_shield.roles.pagination_page",
|
|
26
|
+
page: pagination[:page],
|
|
27
|
+
pages: pagination[:pages]
|
|
28
|
+
) %>
|
|
29
|
+
</span>
|
|
30
|
+
|
|
31
|
+
<% if pagination[:page] < pagination[:pages] %>
|
|
32
|
+
<%= link_to t("lesli_shield.roles.pagination_next"),
|
|
33
|
+
roles_path(request.query_parameters.merge(page: pagination[:page] + 1)),
|
|
34
|
+
class: "inline-flex h-9 items-center rounded-lg border border-slate-300 bg-white px-3 text-sm font-medium text-slate-700 transition hover:border-sky-300 hover:bg-sky-50 hover:text-sky-700",
|
|
35
|
+
data: { turbo_frame: "_top" } %>
|
|
36
|
+
<% else %>
|
|
37
|
+
<span class="inline-flex h-9 cursor-not-allowed items-center rounded-lg border border-slate-200 bg-slate-50 px-3 text-sm font-medium text-slate-400">
|
|
38
|
+
<%= t("lesli_shield.roles.pagination_next") %>
|
|
39
|
+
</span>
|
|
40
|
+
<% end %>
|
|
41
|
+
</div>
|
|
42
|
+
</nav>
|
|
43
|
+
<% end %>
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
<div class="hidden overflow-visible rounded-2xl border border-slate-200 bg-white shadow-sm md:block">
|
|
2
|
+
<table class="min-w-full divide-y divide-slate-200">
|
|
3
|
+
<thead class="bg-slate-50">
|
|
4
|
+
<tr>
|
|
5
|
+
<% %w[role status users permissions modified_at deployment actions].each do |column| %>
|
|
6
|
+
<th scope="col" class="px-5 py-3 text-left text-xs font-semibold uppercase tracking-wide text-slate-500 <%= 'text-center' if %w[users permissions deployment actions].include?(column) %>">
|
|
7
|
+
<%= t("lesli_shield.roles.columns_#{column}") %>
|
|
8
|
+
</th>
|
|
9
|
+
<% end %>
|
|
10
|
+
</tr>
|
|
11
|
+
</thead>
|
|
12
|
+
<tbody class="divide-y divide-slate-100">
|
|
13
|
+
<% roles.each do |role| %>
|
|
14
|
+
<tr class="transition hover:bg-slate-50/80">
|
|
15
|
+
<td class="max-w-md px-5 py-4">
|
|
16
|
+
<div class="flex flex-wrap items-center gap-2">
|
|
17
|
+
<%= link_to role.name,
|
|
18
|
+
role_path(role),
|
|
19
|
+
class: "font-semibold text-slate-900 transition hover:text-sky-700",
|
|
20
|
+
data: { turbo_frame: "_top" } %>
|
|
21
|
+
<%= render "type_badge", role: role %>
|
|
22
|
+
</div>
|
|
23
|
+
<p class="mt-1 line-clamp-2 text-sm leading-5 text-slate-500">
|
|
24
|
+
<%= role.description.presence || t("lesli_shield.roles.description_missing") %>
|
|
25
|
+
</p>
|
|
26
|
+
</td>
|
|
27
|
+
<td class="whitespace-nowrap px-5 py-4">
|
|
28
|
+
<%= render "status_badge", role: role %>
|
|
29
|
+
</td>
|
|
30
|
+
<td class="whitespace-nowrap px-5 py-4 text-center text-sm font-medium text-slate-700">
|
|
31
|
+
<%= role[:users].to_i %>
|
|
32
|
+
</td>
|
|
33
|
+
<td class="whitespace-nowrap px-5 py-4 text-center text-sm font-medium text-slate-700">
|
|
34
|
+
<%= role[:actions].to_i %>
|
|
35
|
+
</td>
|
|
36
|
+
<td class="whitespace-nowrap px-5 py-4 text-sm text-slate-600">
|
|
37
|
+
<% modified_at = role.modified_at || role.updated_at %>
|
|
38
|
+
<time datetime="<%= modified_at.iso8601 %>">
|
|
39
|
+
<%= l(modified_at, format: :short) %>
|
|
40
|
+
</time>
|
|
41
|
+
</td>
|
|
42
|
+
<td class="whitespace-nowrap px-5 py-4 text-center">
|
|
43
|
+
<%= render "deployment_badge", role: role %>
|
|
44
|
+
<% if role.deployed_at.present? %>
|
|
45
|
+
<time
|
|
46
|
+
datetime="<%= role.deployed_at.iso8601 %>"
|
|
47
|
+
class="mt-1 block text-xs text-slate-500"
|
|
48
|
+
>
|
|
49
|
+
<%= l(role.deployed_at, format: :short) %>
|
|
50
|
+
</time>
|
|
51
|
+
<% end %>
|
|
52
|
+
</td>
|
|
53
|
+
<td class="relative whitespace-nowrap px-5 py-4 text-center">
|
|
54
|
+
<%= render "management_menu", role: role %>
|
|
55
|
+
</td>
|
|
56
|
+
</tr>
|
|
57
|
+
<% end %>
|
|
58
|
+
</tbody>
|
|
59
|
+
</table>
|
|
60
|
+
</div>
|
|
61
|
+
|
|
62
|
+
<div class="grid gap-4 md:hidden">
|
|
63
|
+
<% roles.each do |role| %>
|
|
64
|
+
<%
|
|
65
|
+
users_count = role[:users].to_i
|
|
66
|
+
permissions_count = role[:actions].to_i
|
|
67
|
+
users_plural = users_count == 1 ? "one" : "other"
|
|
68
|
+
permissions_plural = permissions_count == 1 ? "one" : "other"
|
|
69
|
+
%>
|
|
70
|
+
<article class="rounded-2xl border border-slate-200 bg-white p-5 shadow-sm">
|
|
71
|
+
<div class="flex items-start justify-between gap-3">
|
|
72
|
+
<div class="min-w-0">
|
|
73
|
+
<h2 class="truncate text-base font-semibold text-slate-900"><%= role.name %></h2>
|
|
74
|
+
<p class="mt-1 line-clamp-2 text-sm leading-5 text-slate-500">
|
|
75
|
+
<%= role.description.presence || t("lesli_shield.roles.description_missing") %>
|
|
76
|
+
</p>
|
|
77
|
+
</div>
|
|
78
|
+
<%= render "status_badge", role: role %>
|
|
79
|
+
</div>
|
|
80
|
+
|
|
81
|
+
<div class="mt-4 flex flex-wrap gap-2">
|
|
82
|
+
<%= render "type_badge", role: role %>
|
|
83
|
+
<span class="inline-flex items-center gap-1 rounded-full bg-slate-100 px-2.5 py-1 text-xs font-medium text-slate-600">
|
|
84
|
+
<span class="material-symbols text-base" aria-hidden="true">group</span>
|
|
85
|
+
<%= t("lesli_shield.roles.mobile_users_#{users_plural}", count: users_count) %>
|
|
86
|
+
</span>
|
|
87
|
+
<span class="inline-flex items-center gap-1 rounded-full bg-slate-100 px-2.5 py-1 text-xs font-medium text-slate-600">
|
|
88
|
+
<span class="material-symbols text-base" aria-hidden="true">key</span>
|
|
89
|
+
<%= t("lesli_shield.roles.mobile_permissions_#{permissions_plural}", count: permissions_count) %>
|
|
90
|
+
</span>
|
|
91
|
+
<%= render "deployment_badge", role: role %>
|
|
92
|
+
</div>
|
|
93
|
+
|
|
94
|
+
<% modified_at = role.modified_at || role.updated_at %>
|
|
95
|
+
<p class="mt-4 text-xs text-slate-500">
|
|
96
|
+
<%= t(
|
|
97
|
+
"lesli_shield.roles.mobile_modified_at",
|
|
98
|
+
date: l(modified_at, format: :short)
|
|
99
|
+
) %>
|
|
100
|
+
</p>
|
|
101
|
+
<% if role.deployed_at.present? %>
|
|
102
|
+
<p class="mt-1 text-xs text-slate-500">
|
|
103
|
+
<%= t(
|
|
104
|
+
"lesli_shield.roles.mobile_deployed_at",
|
|
105
|
+
date: l(role.deployed_at, format: :short)
|
|
106
|
+
) %>
|
|
107
|
+
</p>
|
|
108
|
+
<% end %>
|
|
109
|
+
|
|
110
|
+
<%= render LesliView::Elements::Button.new(
|
|
111
|
+
role.protected_role? ? t("lesli_shield.roles.action_view") : t("lesli_shield.roles.action_manage"),
|
|
112
|
+
url: role_path(role), css_class: "mt-4 w-full"
|
|
113
|
+
) %>
|
|
114
|
+
</article>
|
|
115
|
+
<% end %>
|
|
116
|
+
</div>
|