mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
ServiceAccounts: Add Service Account Token last used at date (#51446)
* ServiceAccounts Add api key last used at * ServiceAccounts: LastUpdateAt tests
This commit is contained in:
@@ -23,6 +23,7 @@ export const ServiceAccountTokensTable = ({ tokens, timeZone, tokenActionsDisabl
|
||||
<th>Name</th>
|
||||
<th>Expires</th>
|
||||
<th>Created</th>
|
||||
<th>Last used at</th>
|
||||
<th />
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -35,6 +36,7 @@ export const ServiceAccountTokensTable = ({ tokens, timeZone, tokenActionsDisabl
|
||||
<TokenExpiration timeZone={timeZone} token={key} />
|
||||
</td>
|
||||
<td>{formatDate(timeZone, key.created)}</td>
|
||||
<td>{formatLastUsedAtDate(timeZone, key.lastUsedAt)}</td>
|
||||
<td>
|
||||
<DeleteButton
|
||||
aria-label={`Delete service account token ${key.name}`}
|
||||
@@ -51,6 +53,13 @@ export const ServiceAccountTokensTable = ({ tokens, timeZone, tokenActionsDisabl
|
||||
);
|
||||
};
|
||||
|
||||
function formatLastUsedAtDate(timeZone: TimeZone, lastUsedAt?: string): string {
|
||||
if (!lastUsedAt) {
|
||||
return 'Never';
|
||||
}
|
||||
return dateTimeFormat(lastUsedAt, { timeZone });
|
||||
}
|
||||
|
||||
function formatDate(timeZone: TimeZone, expiration?: string): string {
|
||||
if (!expiration) {
|
||||
return 'No expiration date';
|
||||
|
||||
@@ -11,6 +11,7 @@ export interface ApiKey extends WithAccessControlMetadata {
|
||||
secondsUntilExpiration?: number;
|
||||
hasExpired?: boolean;
|
||||
created?: string;
|
||||
lastUsedAt?: string;
|
||||
}
|
||||
|
||||
export interface NewApiKey {
|
||||
|
||||
Reference in New Issue
Block a user