From 17537b033d7a896848b3c00c5af4e638cbbcefb6 Mon Sep 17 00:00:00 2001 From: Eric Leijonmarck Date: Thu, 9 Mar 2023 14:16:42 +0000 Subject: [PATCH] API keys: Add last_used_at and docs changes for migration (#64293) * feat: last_used_at for apikeys * add: docs and copy changes * refactor: use br correctly * remove docs * removed more docs --- pkg/api/apikey.go | 1 + pkg/api/dtos/apikey.go | 1 + public/app/features/api-keys/ApiKeysTable.tsx | 9 +++++++++ .../features/api-keys/MigrateToServiceAccountsCard.tsx | 9 ++++++--- 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/pkg/api/apikey.go b/pkg/api/apikey.go index 7a3372a78f9..dcabb191f95 100644 --- a/pkg/api/apikey.go +++ b/pkg/api/apikey.go @@ -47,6 +47,7 @@ func (hs *HTTPServer) GetAPIKeys(c *contextmodel.ReqContext) response.Response { Name: t.Name, Role: t.Role, Expiration: expiration, + LastUsedAt: t.LastUsedAt, } } diff --git a/pkg/api/dtos/apikey.go b/pkg/api/dtos/apikey.go index 6540bf02dc5..eb7288771bd 100644 --- a/pkg/api/dtos/apikey.go +++ b/pkg/api/dtos/apikey.go @@ -22,5 +22,6 @@ type ApiKeyDTO struct { Name string `json:"name"` Role org.RoleType `json:"role"` Expiration *time.Time `json:"expiration,omitempty"` + LastUsedAt *time.Time `json:"lastUsedAt,omitempty"` AccessControl accesscontrol.Metadata `json:"accessControl,omitempty"` } diff --git a/public/app/features/api-keys/ApiKeysTable.tsx b/public/app/features/api-keys/ApiKeysTable.tsx index fa449cc73b4..2b39ed5edd0 100644 --- a/public/app/features/api-keys/ApiKeysTable.tsx +++ b/public/app/features/api-keys/ApiKeysTable.tsx @@ -26,6 +26,7 @@ export const ApiKeysTable: FC = ({ apiKeys, timeZone, onDelete, onMigrate Name Role Expires + Last used at @@ -47,6 +48,7 @@ export const ApiKeysTable: FC = ({ apiKeys, timeZone, onDelete, onMigrate )} + {formatLastUsedAtDate(timeZone, key.lastUsedAt)}