discourse/app/views/user_api_keys/show.html.erb
Penar Musaraj 82c182ddb9
UX: Minor improvements to user api key flow (#39640)
Two changes:

- shows a more prominent warning when the "write" scope is requested
- shows the application name when displaying the key

<img width="600" alt="image"
src="https://github.com/user-attachments/assets/79a6d906-532f-4f2d-bd7b-54bd70362728"
/>

<img width="600" alt="image"
src="https://github.com/user-attachments/assets/08eec177-f43b-4280-8144-267b178bef7f"
/>
2026-04-29 10:44:47 -04:00

23 lines
826 B
Text
Vendored

<p><%= t("user_api_key.instructions", application_name: @client.application_name) %></p>
<div class="user-api-key-display">
<code id="user-api-key-payload"><%= @payload %></code>
</div>
<div>
<button class="btn btn-primary" id="copy-api-key-btn">
<%= t("user_api_key.copy_key") %>
</button>
</div>
<script nonce="<%= csp_nonce_placeholder %>">
document.getElementById('copy-api-key-btn').addEventListener('click', function() {
const btn = this;
const payload = document.getElementById('user-api-key-payload').textContent.replace(/\s/g, '');
navigator.clipboard.writeText(payload).then(() => {
const originalText = btn.textContent;
btn.textContent = '<%= t("user_api_key.copied") %>';
setTimeout(() => {
btn.textContent = originalText;
}, 2000);
});
});
</script>