mirror of
https://github.com/grafana/grafana.git
synced 2024-11-22 08:56:43 -06:00
Service Accounts: Add enabled/disabled status to list (#46259)
* ServiceAccounts: improve where condition * ServiceAccounts: Add Enabled/Disabled status to list
This commit is contained in:
parent
1f3f4ebe21
commit
874ac9180b
@ -299,8 +299,6 @@ func (s *ServiceAccountsStoreImpl) UpdateServiceAccount(ctx context.Context,
|
||||
}
|
||||
|
||||
func (s *ServiceAccountsStoreImpl) SearchOrgServiceAccounts(ctx context.Context, query *models.SearchOrgUsersQuery) ([]*serviceaccounts.ServiceAccountDTO, error) {
|
||||
query.IsServiceAccount = true
|
||||
|
||||
serviceAccounts := make([]*serviceaccounts.ServiceAccountDTO, 0)
|
||||
|
||||
err := s.sqlStore.WithDbSession(ctx, func(dbSession *sqlstore.DBSession) error {
|
||||
@ -313,9 +311,10 @@ func (s *ServiceAccountsStoreImpl) SearchOrgServiceAccounts(ctx context.Context,
|
||||
whereConditions = append(whereConditions, "org_user.org_id = ?")
|
||||
whereParams = append(whereParams, query.OrgID)
|
||||
|
||||
// TODO: add to chore, for cleaning up after we have created
|
||||
// service accounts table in the modelling
|
||||
whereConditions = append(whereConditions, fmt.Sprintf("%s.is_service_account = %t", s.sqlStore.Dialect.Quote("user"), query.IsServiceAccount))
|
||||
whereConditions = append(whereConditions,
|
||||
fmt.Sprintf("%s.is_service_account = %s",
|
||||
s.sqlStore.Dialect.Quote("user"),
|
||||
s.sqlStore.Dialect.BooleanStr(true)))
|
||||
|
||||
if s.sqlStore.Cfg.IsFeatureToggleEnabled(featuremgmt.FlagAccesscontrol) {
|
||||
acFilter, err := accesscontrol.Filter(ctx, "org_user.user_id", "serviceaccounts", "serviceaccounts:read", query.User)
|
||||
@ -348,6 +347,7 @@ func (s *ServiceAccountsStoreImpl) SearchOrgServiceAccounts(ctx context.Context,
|
||||
"user.name",
|
||||
"user.login",
|
||||
"user.last_seen_at",
|
||||
"user.is_disabled",
|
||||
)
|
||||
sess.Asc("user.email", "user.login")
|
||||
if err := sess.Find(&serviceAccounts); err != nil {
|
||||
|
@ -34,6 +34,7 @@ type ServiceAccountDTO struct {
|
||||
Name string `json:"name" xorm:"name"`
|
||||
Login string `json:"login" xorm:"login"`
|
||||
OrgId int64 `json:"orgId" xorm:"org_id"`
|
||||
IsDisabled bool `json:"isDisabled" xorm:"is_disabled"`
|
||||
Role string `json:"role" xorm:"role"`
|
||||
Tokens int64 `json:"tokens"`
|
||||
AvatarUrl string `json:"avatarUrl"`
|
||||
|
@ -113,6 +113,7 @@ const ServiceAccountsListPage = ({
|
||||
<th>Display name</th>
|
||||
<th>ID</th>
|
||||
<th>Roles</th>
|
||||
<th>Status</th>
|
||||
<th>Tokens</th>
|
||||
<th style={{ width: '34px' }} />
|
||||
</tr>
|
||||
@ -174,6 +175,9 @@ type ServiceAccountListItemProps = {
|
||||
const getServiceAccountsAriaLabel = (name: string) => {
|
||||
return `Edit service account's ${name} details`;
|
||||
};
|
||||
const getServiceAccountsEnabledStatus = (disabled: boolean) => {
|
||||
return disabled ? 'Disabled' : 'Enabled';
|
||||
};
|
||||
|
||||
const ServiceAccountListItem = memo(
|
||||
({ serviceAccount, onRoleChange, roleOptions, builtInRoles, onSetToRemove }: ServiceAccountListItemProps) => {
|
||||
@ -237,7 +241,17 @@ const ServiceAccountListItem = memo(
|
||||
<a
|
||||
className="ellipsis"
|
||||
href={editUrl}
|
||||
title="tokens"
|
||||
title={getServiceAccountsEnabledStatus(serviceAccount.isDisabled)}
|
||||
aria-label={getServiceAccountsAriaLabel(serviceAccount.name)}
|
||||
>
|
||||
{getServiceAccountsEnabledStatus(serviceAccount.isDisabled)}
|
||||
</a>
|
||||
</td>
|
||||
<td className="link-td max-width-10">
|
||||
<a
|
||||
className="ellipsis"
|
||||
href={editUrl}
|
||||
title="Tokens"
|
||||
aria-label={getServiceAccountsAriaLabel(serviceAccount.name)}
|
||||
>
|
||||
<span>
|
||||
|
Loading…
Reference in New Issue
Block a user