- <%= form_tag spree.clear_api_key_admin_user_path(@user), method: :put do %>
- <%= button Spree.t('clear_key', scope: 'api') %>
+
+ <%= t('.key') %>:
+ <% if @user == try_spree_current_user %>
+ <%= @user.spree_api_key %>
+ <% else %>
+ (<%= Spree.t('hidden') %>)
<% end %>
- <%= form_tag spree.generate_api_key_admin_user_path(@user), method: :put do %>
- <%= button Spree.t('regenerate_key', scope: 'api') %>
- <% end %>
+
+
+ <%= button_link_to t('.clear_key'), spree.clear_api_key_admin_user_path(@user), method: :put, data: { confirm: t('.confirm_clear_key') }, class: 'btn btn-primary' %>
+ <%= button_link_to t('.regenerate_key'), spree.generate_api_key_admin_user_path(@user), method: :put, data: { confirm: t('.confirm_regenerate_key') }, class: 'btn btn-primary' %>
<% else %>
-
<%= Spree.t('no_key', scope: 'api') %>
+
<%= t('.no_key') %>
- <%= form_tag spree.generate_api_key_admin_user_path(@user), method: :put do %>
- <%= button Spree.t('generate_key', scope: 'api') %>
- <% end %>
+ <%= button_link_to t('.generate_key'), spree.generate_api_key_admin_user_path(@user), method: :put, class: 'btn btn-primary' %>
<% end %>
diff --git a/backend/spec/features/admin/users_spec.rb b/backend/spec/features/admin/users_spec.rb
index 514517556ce..7c9794e78ef 100644
--- a/backend/spec/features/admin/users_spec.rb
+++ b/backend/spec/features/admin/users_spec.rb
@@ -238,7 +238,7 @@ def always_invalid_email
it 'can generate a new api key' do
within("#admin_user_edit_api_key") do
expect(user_a.spree_api_key).to be_blank
- click_button Spree.t('generate_key', scope: 'api')
+ click_button "Generate API key"
end
expect(user_a.reload.spree_api_key).to be_present
@@ -257,7 +257,7 @@ def always_invalid_email
it 'can clear an api key' do
expect(page).to have_css('#current-api-key')
- click_button Spree.t('clear_key', scope: 'api')
+ click_button "Clear key"
expect(page).to have_no_css('#current-api-key')
@@ -268,7 +268,7 @@ def always_invalid_email
old_key = user_a.spree_api_key
within("#admin_user_edit_api_key") do
- click_button Spree.t('regenerate_key', scope: 'api')
+ click_button "Regenerate key"
end
expect(user_a.reload.spree_api_key).to be_present
diff --git a/core/config/locales/en.yml b/core/config/locales/en.yml
index c29194f7171..938f6d6bcaf 100644
--- a/core/config/locales/en.yml
+++ b/core/config/locales/en.yml
@@ -949,6 +949,15 @@ en:
users:
user_page_actions:
create_order: Create order for this user
+ edit:
+ api_access: "API Access"
+ clear_key: "Clear key"
+ confirm_clear_key: "Are you sure you want to clear this user's API key? It will invalidate the existing key."
+ confirm_regenerate_key: "Are you sure you want to regenerate this user's API key? It will invalidate the existing key."
+ generate_key: "Generate API key"
+ key: "Key"
+ no_key: "No key"
+ regenerate_key: "Regenerate key"
variants:
table_filter:
show_deleted: Show deleted variants