mirror of
https://github.com/grafana/grafana.git
synced 2025-02-13 17:15:40 -06:00
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
This commit is contained in:
parent
4c0571be3a
commit
17537b033d
@ -47,6 +47,7 @@ func (hs *HTTPServer) GetAPIKeys(c *contextmodel.ReqContext) response.Response {
|
||||
Name: t.Name,
|
||||
Role: t.Role,
|
||||
Expiration: expiration,
|
||||
LastUsedAt: t.LastUsedAt,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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"`
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ export const ApiKeysTable: FC<Props> = ({ apiKeys, timeZone, onDelete, onMigrate
|
||||
<th>Name</th>
|
||||
<th>Role</th>
|
||||
<th>Expires</th>
|
||||
<th>Last used at</th>
|
||||
<th style={{ width: '34px' }} />
|
||||
</tr>
|
||||
</thead>
|
||||
@ -47,6 +48,7 @@ export const ApiKeysTable: FC<Props> = ({ apiKeys, timeZone, onDelete, onMigrate
|
||||
</span>
|
||||
)}
|
||||
</td>
|
||||
<td>{formatLastUsedAtDate(timeZone, key.lastUsedAt)}</td>
|
||||
<td>
|
||||
<HorizontalGroup justify="flex-end">
|
||||
<Button size="sm" onClick={() => onMigrate(key)}>
|
||||
@ -69,6 +71,13 @@ export const ApiKeysTable: FC<Props> = ({ apiKeys, timeZone, onDelete, onMigrate
|
||||
);
|
||||
};
|
||||
|
||||
function formatLastUsedAtDate(timeZone: TimeZone, lastUsedAt?: string): string {
|
||||
if (!lastUsedAt) {
|
||||
return 'Never';
|
||||
}
|
||||
return dateTimeFormat(lastUsedAt, { timeZone });
|
||||
}
|
||||
|
||||
function formatDate(expiration: string | undefined, timeZone: TimeZone): string {
|
||||
if (!expiration) {
|
||||
return 'No expiration date';
|
||||
|
@ -26,8 +26,11 @@ export const MigrateToServiceAccountsCard = ({ onMigrate, apikeysCount, disabled
|
||||
);
|
||||
const migrationBoxDesc = (
|
||||
<span>
|
||||
Are you sure you want to migrate all API keys to service accounts? {docsLink}
|
||||
<br>This hides the API keys tab.</br>
|
||||
Migrating all API keys will hide the API keys tab.
|
||||
<br></br>
|
||||
<br></br>
|
||||
The API keys API will remain available for you to create new API keys, but we strongly encourage you to use
|
||||
Service accounts instead.
|
||||
</span>
|
||||
);
|
||||
|
||||
@ -44,7 +47,7 @@ export const MigrateToServiceAccountsCard = ({ onMigrate, apikeysCount, disabled
|
||||
Migrate all service accounts
|
||||
</Button>
|
||||
<ConfirmModal
|
||||
title={'Migrate API keys to service accounts'}
|
||||
title={'Migrate API keys to Service accounts'}
|
||||
isOpen={isModalOpen}
|
||||
body={migrationBoxDesc}
|
||||
confirmText={'Yes, migrate now'}
|
||||
|
Loading…
Reference in New Issue
Block a user