diff --git a/app/assets/javascripts/admin/addon/components/api-key-item.gjs b/app/assets/javascripts/admin/addon/components/api-key-item.gjs
index 7efdea2fefd..f1693074b00 100644
--- a/app/assets/javascripts/admin/addon/components/api-key-item.gjs
+++ b/app/assets/javascripts/admin/addon/components/api-key-item.gjs
@@ -73,6 +73,9 @@ export default class ApiKeysList extends Component {
{{/if}}
+
+ {{avatar this.apiKey.createdBy imageSize="small"}}
+
{{i18n
"admin.api.created"
}}
diff --git a/app/assets/javascripts/admin/addon/models/api-key.js b/app/assets/javascripts/admin/addon/models/api-key.js
index 6c64702a2c2..228682544fd 100644
--- a/app/assets/javascripts/admin/addon/models/api-key.js
+++ b/app/assets/javascripts/admin/addon/models/api-key.js
@@ -21,6 +21,19 @@ export default class ApiKey extends RestModel {
}
}
+ @computed("_created_by")
+ get createdBy() {
+ return this._created_by;
+ }
+
+ set created_by(value) {
+ if (value && !(value instanceof AdminUser)) {
+ this.set("_created_by", AdminUser.create(value));
+ } else {
+ this.set("_created_by", value);
+ }
+ }
+
@discourseComputed("description")
shortDescription(description) {
if (!description || description.length < 40) {
diff --git a/app/assets/stylesheets/common/admin/admin_table.scss b/app/assets/stylesheets/common/admin/admin_table.scss
index 5883499cf14..ea04fbad7e9 100644
--- a/app/assets/stylesheets/common/admin/admin_table.scss
+++ b/app/assets/stylesheets/common/admin/admin_table.scss
@@ -94,13 +94,14 @@
color: var(--primary-high);
font-size: var(--font-down-1);
}
- &__badge {
- background-color: var(--primary-low);
- border-radius: var(--d-border-radius);
- font-size: var(--font-down-1);
- margin-left: var(--space-1);
- padding: var(--space-2);
- }
+ }
+
+ &__badge {
+ background-color: var(--primary-low);
+ border-radius: var(--d-border-radius);
+ font-size: var(--font-down-1);
+ margin-left: var(--space-1);
+ padding: var(--space-2);
}
// Success badge
diff --git a/app/controllers/admin/api_controller.rb b/app/controllers/admin/api_controller.rb
index f02b2464bcd..04ed1684c92 100644
--- a/app/controllers/admin/api_controller.rb
+++ b/app/controllers/admin/api_controller.rb
@@ -14,6 +14,7 @@ class Admin::ApiController < Admin::AdminController
ApiKey
.where(hidden: false)
.includes(:user)
+ .includes(:created_by)
.order("revoked_at DESC NULLS FIRST, created_at DESC")
.offset(offset)
.limit(limit)
diff --git a/app/serializers/api_key_serializer.rb b/app/serializers/api_key_serializer.rb
index d1ccac58de0..f5de99ff410 100644
--- a/app/serializers/api_key_serializer.rb
+++ b/app/serializers/api_key_serializer.rb
@@ -11,6 +11,7 @@ class ApiKeySerializer < ApplicationSerializer
:revoked_at
has_one :user, serializer: BasicUserSerializer, embed: :objects
+ has_one :created_by, serializer: BasicUserSerializer, embed: :objects
has_many :api_key_scopes, serializer: ApiKeyScopeSerializer, embed: :objects
def include_user_id?
diff --git a/app/serializers/basic_api_key_serializer.rb b/app/serializers/basic_api_key_serializer.rb
index e8f194eccd3..cfecc068c8e 100644
--- a/app/serializers/basic_api_key_serializer.rb
+++ b/app/serializers/basic_api_key_serializer.rb
@@ -4,4 +4,5 @@ class BasicApiKeySerializer < ApplicationSerializer
attributes :id, :truncated_key, :description, :created_at, :last_used_at, :revoked_at
has_one :user, serializer: BasicUserSerializer, embed: :objects
+ has_one :created_by, serializer: BasicUserSerializer, embed: :objects
end
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml
index 7849cf4e621..cd15350050d 100644
--- a/config/locales/client.en.yml
+++ b/config/locales/client.en.yml
@@ -5346,10 +5346,10 @@ en:
title: "API"
key: "Key"
keys: "Keys"
- created: Created
+ created: Created by
updated: Updated
- last_used: Last Used
- never_used: (never)
+ last_used: Last used
+ never_used: Never
generate: "Generate"
undo_revoke: "Undo revoke"
revoke: "Revoke"
|