-
Notifications
You must be signed in to change notification settings - Fork 11
fix responsive issue in settings/api_key route page #1566
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 2 commits
a47fefa
dd3dd4e
cc38286
def934a
6a100ea
f9bb4e6
e2f3b60
06df713
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,28 +1,17 @@ | ||
| import { Controller } from "@hotwired/stimulus"; | ||
|
|
||
| export default class extends Controller { | ||
| static targets = ["source", "iconDefault", "iconSuccess"]; | ||
| static targets = ["source"]; | ||
|
|
||
| copy(event) { | ||
| event.preventDefault(); | ||
| if (this.sourceTarget?.textContent) { | ||
| navigator.clipboard | ||
| .writeText(this.sourceTarget.textContent) | ||
| .then(() => { | ||
| this.showSuccess(); | ||
| }) | ||
| .then(() => {}) | ||
| .catch((error) => { | ||
| console.error("Failed to copy text: ", error); | ||
| }); | ||
| } | ||
| } | ||
|
|
||
| showSuccess() { | ||
| this.iconDefaultTarget.classList.add("hidden"); | ||
| this.iconSuccessTarget.classList.remove("hidden"); | ||
| setTimeout(() => { | ||
| this.iconDefaultTarget.classList.remove("hidden"); | ||
| this.iconSuccessTarget.classList.add("hidden"); | ||
| }, 3000); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -23,23 +23,35 @@ | |||||
| <p class="text-secondary text-sm mb-3">Copy and store this key securely. You'll need it to authenticate your API requests.</p> | ||||||
|
|
||||||
| <div class="bg-container rounded-lg p-3 border border-primary" data-controller="clipboard"> | ||||||
| <div class="flex items-center justify-between gap-3"> | ||||||
| <code id="api-key-display" class="font-mono text-sm text-primary break-all" data-clipboard-target="source"><%= @current_api_key.plain_key %></code> | ||||||
| <%= render DS::Button.new( | ||||||
| text: "Copy API Key", | ||||||
| variant: "ghost", | ||||||
| icon: "copy", | ||||||
| data: { action: "clipboard#copy" } | ||||||
| ) %> | ||||||
| <div class="w-full overflow-hidden"> | ||||||
| <code id="api-key-display" class="block w-full min-w-0 overflow-x-auto font-mono text-sm text-primary break-all whitespace-pre-wrap" data-clipboard-target="source"><%= @current_api_key.plain_key %></code> | ||||||
| <div class="mt-2 flex justify-end"> | ||||||
| <%= render DS::Button.new( | ||||||
| text: "Copy API Key", | ||||||
| variant: "ghost", | ||||||
| icon: "copy", | ||||||
| class: "shrink-0", | ||||||
| data: { action: "clipboard#copy" } | ||||||
| ) %> | ||||||
| </div> | ||||||
| </div> | ||||||
| </div> | ||||||
| </div> | ||||||
|
|
||||||
| <div class="bg-surface-inset rounded-xl p-4"> | ||||||
| <h4 class="font-medium text-primary mb-3">How to use your API key</h4> | ||||||
| <p class="text-secondary text-sm mb-3"><%= t(".current_api_key.usage_instructions", product_name: product_name) %></p> | ||||||
| <div class="bg-container rounded-lg p-3 font-mono text-sm text-primary border border-primary"> | ||||||
| curl -H "X-Api-Key: <%= @current_api_key.plain_key %>" <%= request.base_url %>/api/v1/accounts | ||||||
| <div class="bg-container rounded-lg p-3 font-mono text-sm text-primary border border-primary max-w-full overflow-hidden" data-controller="clipboard"> | ||||||
| <div class="flex items-start gap-2 min-w-0"> | ||||||
| <code class="block flex-1 min-w-0 overflow-x-auto break-all whitespace-pre-wrap" data-clipboard-target="source">curl -H "X-Api-Key: <%= @current_api_key.plain_key %>" <%= request.base_url %>/api/v1/accounts</code> | ||||||
| <%= render DS::Button.new( | ||||||
| text: "Copy", | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Localize the new “Copy” button label. Line 47 hardcodes user-facing text, which breaks localization in non-English locales. Proposed fix- text: "Copy",
+ text: t(".current_api_key.copy_key"),As per coding guidelines, "All user-facing strings MUST use the 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
| variant: "ghost", | ||||||
| icon: "copy", | ||||||
| class: "shrink-0", | ||||||
| data: { action: "clipboard#copy" } | ||||||
| ) %> | ||||||
| </div> | ||||||
| </div> | ||||||
| </div> | ||||||
|
|
||||||
|
|
@@ -111,23 +123,35 @@ | |||||
| <p class="text-secondary text-sm mb-3">Copy and store this key securely. You'll need it to authenticate your API requests.</p> | ||||||
|
|
||||||
| <div class="bg-container rounded-lg p-3 border border-primary" data-controller="clipboard"> | ||||||
| <div class="flex items-center justify-between gap-3"> | ||||||
| <code id="api-key-display" class="font-mono text-sm text-primary break-all" data-clipboard-target="source"><%= @current_api_key.plain_key %></code> | ||||||
| <%= render DS::Button.new( | ||||||
| text: "Copy API Key", | ||||||
| variant: "ghost", | ||||||
| icon: "copy", | ||||||
| data: { action: "clipboard#copy" } | ||||||
| ) %> | ||||||
| <div class="w-full overflow-hidden"> | ||||||
| <code id="api-key-display" class="block w-full min-w-0 overflow-x-auto font-mono text-sm text-primary break-all whitespace-pre-wrap" data-clipboard-target="source"><%= @current_api_key.plain_key %></code> | ||||||
| <div class="mt-2 flex justify-end"> | ||||||
| <%= render DS::Button.new( | ||||||
| text: "Copy API Key", | ||||||
| variant: "ghost", | ||||||
| icon: "copy", | ||||||
| class: "shrink-0", | ||||||
| data: { action: "clipboard#copy" } | ||||||
| ) %> | ||||||
| </div> | ||||||
| </div> | ||||||
| </div> | ||||||
| </div> | ||||||
|
|
||||||
| <div class="bg-surface-inset rounded-xl p-4"> | ||||||
| <h4 class="font-medium text-primary mb-3">How to use your API key</h4> | ||||||
| <p class="text-secondary text-sm mb-3"><%= t(".current_api_key.usage_instructions", product_name: product_name) %></p> | ||||||
| <div class="bg-container rounded-lg p-3 font-mono text-sm text-primary border border-primary"> | ||||||
| curl -H "X-Api-Key: <%= @current_api_key.plain_key %>" <%= request.base_url %>/api/v1/accounts | ||||||
| <div class="bg-container rounded-lg p-3 font-mono text-sm text-primary border border-primary max-w-full overflow-hidden" data-controller="clipboard"> | ||||||
| <div class="flex items-start gap-2 min-w-0"> | ||||||
| <code class="block flex-1 min-w-0 overflow-x-auto break-all whitespace-pre-wrap" data-clipboard-target="source">curl -H "X-Api-Key: <%= @current_api_key.plain_key %>" <%= request.base_url %>/api/v1/accounts</code> | ||||||
| <%= render DS::Button.new( | ||||||
| text: "Copy", | ||||||
| variant: "ghost", | ||||||
| icon: "copy", | ||||||
| class: "shrink-0", | ||||||
| data: { action: "clipboard#copy" } | ||||||
| ) %> | ||||||
| </div> | ||||||
| </div> | ||||||
| </div> | ||||||
|
|
||||||
|
|
||||||
Uh oh!
There was an error while loading. Please reload this page.