Skip to content

Commit 30b7b0a

Browse files
authored
Merge pull request #270 from AlchemyCMS/add-edit-user-link
feat: Add edit user link to user info
2 parents 283cc9c + 4ea5e14 commit 30b7b0a

6 files changed

Lines changed: 29 additions & 13 deletions

File tree

.github/workflows/ci.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ jobs:
1313
fail-fast: false
1414
matrix:
1515
alchemy_branch:
16-
- "8.1-stable"
1716
- "8.2-stable"
1817
ruby:
1918
- "3.3"
@@ -27,9 +26,6 @@ jobs:
2726
- mysql
2827
- postgresql
2928
- sqlite
30-
exclude:
31-
- alchemy_branch: "8.0-stable"
32-
rails: "8.1"
3329

3430
env:
3531
DB: ${{ matrix.database }}

alchemy-devise.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
1515

1616
s.files = Dir["{app,config,db,lib}/**/*", "LICENSE", "CHANGELOG.md", "README.md"]
1717

18-
s.add_dependency "alchemy_cms", [">= 8.1.0.a", "< 9.0"]
18+
s.add_dependency "alchemy_cms", [">= 8.2.0", "< 9.0"]
1919
s.add_dependency "devise", ">= 4.9", "< 6.0"
2020
s.add_dependency "flickwerk", ["~> 0.3.6"]
2121

app/views/alchemy/admin/users/_fields.html.erb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<%= f.input :firstname, input_html: {autocomplete: "given-name"} %>
22
<%= f.input :lastname, input_html: {autocomplete: "family-name"} %>
3-
<%= f.input :login, autofocus: true, required: @user.login_required?, input_html: {autocomplete: "username"} %>
4-
<%= f.input :email, required: @user.email_required?, input_html: {autocomplete: "email"} %>
3+
<%= f.input :login, autofocus: true, required: f.object.login_required?, input_html: {autocomplete: "username"} %>
4+
<%= f.input :email, required: f.object.email_required?, input_html: {autocomplete: "email"} %>
55
<% if Alchemy::I18n.available_locales.many? %>
66
<div class="input select">
77
<%= f.label(:language) %>
@@ -16,9 +16,9 @@
1616
is: "alchemy-select",
1717
data: {allow_clear: true}
1818
} %>
19-
<% if can_update_role? %>
19+
<% if local_assigns[:user_roles] && can_update_role? %>
2020
<%= f.input :alchemy_roles,
21-
collection: @user_roles,
21+
collection: user_roles,
2222
input_html: {
2323
multiple: true,
2424
is: 'alchemy-select',
@@ -32,7 +32,7 @@
3232
<%= f.label :tag_list %>
3333
<%= render 'alchemy/admin/partials/autocomplete_tag_list',
3434
f: f,
35-
object: @user %>
35+
object: f.object %>
3636
</div>
3737
<% end %>
3838
<%= f.input :send_credentials, as: 'boolean' %>
Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1-
<%= alchemy_form_for [:admin, @user] do |f| %>
2-
<%= render 'fields', f: f %>
1+
<% if request.xhr? || turbo_frame_request? %>
2+
<%= alchemy_form_for [:admin, @user] do |f| %>
3+
<%= render "fields", f: f, user_roles: @user_roles %>
4+
<% end %>
5+
<% else %>
6+
<%= content_for :toolbar do %>
7+
<sl-tooltip content="<%= Alchemy.t(:back) %>">
8+
<%= link_to request.referer || alchemy.admin_dashboard_path, class: "icon_button" do %>
9+
<alchemy-icon name="arrow-left-s"></alchemy-icon>
10+
<% end %>
11+
</sl-tooltip>
12+
<% end %>
13+
14+
<div class="panel">
15+
<alchemy-message type="info">
16+
<%= Alchemy.t(:edit_user) %>
17+
</alchemy-message>
18+
<%= alchemy_form_for [:admin, @user] do |f| %>
19+
<%= render "fields", f: f, user_roles: @user_roles %>
20+
<% end %>
21+
</div>
322
<% end %>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
<%= alchemy_form_for [:admin, @user] do |f| %>
2-
<%= render 'fields', f: f %>
2+
<%= render 'fields', f: f, user_roles: @user_roles %>
33
<% end %>

config/initializers/alchemy.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,5 @@
1919
Alchemy.config.login_path = "/admin/login"
2020
Alchemy.config.logout_path = "/admin/logout"
2121
Alchemy.config.logout_method = Devise.sign_out_via.to_s
22+
Alchemy.config.edit_user_path = "/admin/users/:id/edit"
2223
end

0 commit comments

Comments
 (0)