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:
Jguer
2022-06-28 14:42:40 +00:00
committed by GitHub
parent daf0e3cb4e
commit 6d0261263c
11 changed files with 60 additions and 0 deletions

View File

@@ -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';

View File

@@ -11,6 +11,7 @@ export interface ApiKey extends WithAccessControlMetadata {
secondsUntilExpiration?: number;
hasExpired?: boolean;
created?: string;
lastUsedAt?: string;
}
export interface NewApiKey {