Move API keys from Account tab to Extensions tab in settings (#17862)

This commit is contained in:
Josh Puetz 2022-06-09 09:44:50 -05:00 committed by GitHub
parent 26e2e80ad1
commit 77a00d242a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 75 additions and 72 deletions

View file

@ -4,48 +4,6 @@
<%= render "users/account_providers_emails" %>
<div class="crayons-card crayons-card--content-rows">
<header>
<h2 class="mb-2"><%= t("views.settings.account.api.heading", community: community_name) %></h2>
<p><%= t("views.settings.account.api.desc_html", community: community_name, doc: link_to(t("views.settings.account.api.doc"), "https://developers.forem.com/api")) %></p>
</header>
<div>
<h3 class="mb-2"><%= t("views.settings.account.api.gen.heading") %></h3>
<%= form_tag users_api_secrets_path, method: :post do %>
<%= fields_for :api_secret do |api_secret| %>
<div class="crayons-field mb-6">
<%= api_secret.label(:description, t("views.settings.account.api.gen.label"), class: "crayons-field__label") %>
<p class="crayons-field__description"><% t("views.settings.account.api.gen.text") %></p>
<%= api_secret.text_field(:description, placeholder: t("views.settings.account.api.gen.placeholder"), required: true, class: "crayons-textfield") %>
</div>
<% end %>
<button class="crayons-btn crayon-btn--secondary" type="submit"><%= t("views.settings.account.api.gen.submit") %></button>
<% end %>
</div>
<% unless @user.api_secrets.empty? %>
<div>
<h3><%= t("views.settings.account.api.active.heading") %></h3>
<% @user.api_secrets.order(created_at: :desc).each do |api_secret| %>
<details class="p-4 mt-2 crayons-card crayons-card--secondary">
<summary class="title fw-medium"><%= api_secret.description %></summary>
<div class="flex pt-2">
<div class="flex-1 pl-4">
<p class="ff-monospace"><%= api_secret.secret %></p>
<p class="fs-s"><%== t("views.settings.account.api.active.created", time: tag.time(api_secret.created_at.to_s, datetime: api_secret.created_at.rfc3339)) %></p>
</div>
<%= form_tag users_api_secret_path(api_secret.id), class: "api__secret__revoke", method: :delete do %>
<%= button_tag t("views.settings.account.api.revoke"), class: "crayons-btn crayons-btn--danger" %>
<% end %>
</div>
</details>
<% end %>
</div>
<% end %>
</div>
<div class="crayons-card crayons-card--content-rows">
<h2 class="crayons-subtitle-1">
<%= t("views.settings.account.export.heading") %>

View file

@ -0,0 +1,43 @@
<div class="crayons-card crayons-card--content-rows">
<header>
<h2 class="mb-2"><%= t("views.settings.extensions.api.heading", community: community_name) %>
<span class="ml-2 c-indicator c-indicator--warning"><%= t("core.beta") %></span>
</h2>
<p><%= t("views.settings.extensions.api.desc_html", community: community_name, doc: link_to(t("views.settings.extensions.api.doc"), "https://developers.forem.com/api")) %></p>
</header>
<div>
<h3 class="mb-2"><%= t("views.settings.extensions.api.gen.heading") %></h3>
<%= form_tag users_api_secrets_path, method: :post do %>
<%= fields_for :api_secret do |api_secret| %>
<div class="crayons-field mb-6">
<%= api_secret.label(:description, t("views.settings.extensions.api.gen.label"), class: "crayons-field__label") %>
<p class="crayons-field__description"><% t("views.settings.extensions.api.gen.text") %></p>
<%= api_secret.text_field(:description, placeholder: t("views.settings.extensions.api.gen.placeholder"), required: true, class: "crayons-textfield") %>
</div>
<% end %>
<button class="crayons-btn crayon-btn--secondary" type="submit"><%= t("views.settings.extensions.api.gen.submit") %></button>
<% end %>
</div>
<% unless @user.api_secrets.empty? %>
<div>
<h3><%= t("views.settings.extensions.api.active.heading") %></h3>
<% @user.api_secrets.order(created_at: :desc).each do |api_secret| %>
<details class="p-4 mt-2 crayons-card crayons-card--secondary">
<summary class="title fw-medium"><%= api_secret.description %></summary>
<div class="flex pt-2">
<div class="flex-1 pl-4">
<p class="ff-monospace"><%= api_secret.secret %></p>
<p class="fs-s"><%== t("views.settings.extensions.api.active.created", time: tag.time(api_secret.created_at.to_s, datetime: api_secret.created_at.rfc3339)) %></p>
</div>
<%= form_tag users_api_secret_path(api_secret.id), class: "api__secret__revoke", method: :delete do %>
<%= button_tag t("views.settings.extensions.api.revoke"), class: "crayons-btn crayons-btn--danger" %>
<% end %>
</div>
</details>
<% end %>
</div>
<% end %>
</div>

View file

@ -5,3 +5,5 @@
<%= render partial: "web_monetization" %>
<%= render partial: "users/integrations_github_repositories", locals: { show_integration: @github_repositories_show } %>
<%= render partial: "api_keys" %>

View file

@ -10,20 +10,6 @@ en:
primary: Primary email
provider_email: "%{provider} email"
provider_profile: "%{provider} profile settings"
api:
heading: "%{community} API Keys"
desc_html: You can generate personal API keys to use for authentication with the %{community} API. The API is still in its beta stage. The %{doc} contains further information.
active:
heading: Active API keys (never share these!)
created: 'Created: %{time}'
doc: documentation
gen:
heading: Generate a new Key
label: Description
text: What's this API key for?
placeholder: My Project Name
submit: Generate API Key
revoke: Revoke
delete:
heading: Delete account
desc1: 'Deleting your account will:'
@ -118,6 +104,20 @@ en:
one: '1 error prohibited your profile from being saved:'
other: "%{count} errors prohibited your profile from being saved:"
extensions:
api:
heading: "%{community} API Keys"
desc_html: You can generate personal API keys to use for authentication with the %{community} API. The API is still in its beta stage. The %{doc} contains further information.
active:
heading: Active API keys (never share these!)
created: 'Created: %{time}'
doc: documentation
gen:
heading: Generate a new Key
label: Description
text: What's this API key for?
placeholder: My Project Name
submit: Generate API Key
revoke: Revoke
comment:
heading: Comment templates
desc_html: Create and save <strong>comment templates</strong> that you can reuse.

View file

@ -10,20 +10,6 @@ fr:
primary: Primary email
provider_email: "%{provider} email"
provider_profile: "%{provider} profile settings"
api:
heading: "%{community} API Keys"
desc_html: You can generate personal API keys to use for authentication with the %{community} API. The API is still in its beta stage. The %{doc} contains further information.
active:
heading: Active API keys (never share these!)
created: 'Created: %{time}'
doc: documentation
gen:
heading: Generate a new Key
label: Description
text: What's this API key for?
placeholder: My Project Name
submit: Generate API Key
revoke: Revoke
delete:
heading: Delete account
desc1: 'Deleting your account will:'
@ -118,6 +104,20 @@ fr:
one: '1 error prohibited your profile from being saved:'
other: "%{count} errors prohibited your profile from being saved:"
extensions:
api:
heading: "%{community} API Keys"
desc_html: You can generate personal API keys to use for authentication with the %{community} API. The API is still in its beta stage. The %{doc} contains further information.
active:
heading: Active API keys (never share these!)
created: 'Created: %{time}'
doc: documentation
gen:
heading: Generate a new Key
label: Description
text: What's this API key for?
placeholder: My Project Name
submit: Generate API Key
revoke: Revoke
comment:
heading: Comment templates
desc_html: Create and save <strong>comment templates</strong> that you can reuse.

View file

@ -64,7 +64,7 @@ RSpec.describe "UserSettings", type: :request do
it "displays content on Account tab properly" do
get user_settings_path(:account)
expect(response.body).to include("Set new password", "Account emails", "API Keys", "Danger Zone")
expect(response.body).to include("Set new password", "Account emails", "Danger Zone")
end
it "displays content on Billing tab properly" do
@ -83,7 +83,7 @@ RSpec.describe "UserSettings", type: :request do
get user_settings_path(:extensions)
feed_section = "Publishing to #{Settings::Community.community_name} from RSS"
titles = ["Comment templates", feed_section, "Web monetization"]
titles = ["Comment templates", feed_section, "Web monetization", "API Keys"]
expect(response.body).to include(*titles)
end