Skip to content

Commit

Permalink
Add hidden rubygems_id input to api key forms
Browse files Browse the repository at this point in the history
  • Loading branch information
jenshenny committed Jun 7, 2022
1 parent b79b863 commit a87eb85
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/assets/javascripts/api_key_form.js
Expand Up @@ -17,7 +17,11 @@ $(function() {
} else {
gemScopeSelector.val("");
gemScopeSelector.prop("disabled", true);
addHiddenRubygemField();
if (!hiddenRubygemFieldExists()) addHiddenRubygemField();
}

function hiddenRubygemFieldExists() {
return $("#" + hiddenRubygemId).length
}
}

Expand Down
1 change: 1 addition & 0 deletions app/views/api_keys/edit.html.erb
Expand Up @@ -20,6 +20,7 @@
<p><%= t(".rubygem_scope_info") %></p>
<%= f.collection_select :rubygem_id, current_user.rubygems.by_name, :id, :name, { include_blank: t(".all_gems") }, selected: :rubygem_id, class: "form__input form__select" %>
</div>
<%= f.text_field :rubygem_id, { id: "hidden_api_key_rubygem_id", type: "hidden", value: "" } %>
<% unless current_user.mfa_disabled? || current_user.mfa_ui_and_api? %>
<div class="form__group">
Expand Down
1 change: 1 addition & 0 deletions app/views/api_keys/new.html.erb
Expand Up @@ -20,6 +20,7 @@
<p><%= t(".rubygem_scope_info") %></p>
<%= f.collection_select :rubygem_id, current_user.rubygems.by_name, :id, :name, { include_blank: t(".all_gems") }, selected: :rubygem_id, class: "form__input form__select" %>
</div>
<%= f.text_field :rubygem_id, { id: "hidden_api_key_rubygem_id", type: "hidden", value: "" } %>
<% unless current_user.mfa_disabled? || current_user.mfa_ui_and_api? %>
<div class="form__group">
Expand Down

0 comments on commit a87eb85

Please sign in to comment.