added display of the type creator in the list of types

This commit is contained in:
Дмитрий Пиченикин 2026-03-10 15:15:23 +03:00
parent 8596b0e7dc
commit 2006501a74
3 changed files with 13 additions and 0 deletions

View File

@ -91,6 +91,7 @@ type RevokeOwnershipRequest struct {
type TypeWithBadgeCount struct { type TypeWithBadgeCount struct {
*badgesmodel.BadgeTypeDefinition *badgesmodel.BadgeTypeDefinition
BadgeCount int `json:"badge_count"` BadgeCount int `json:"badge_count"`
CreatedByUsername string `json:"created_by_username"`
AllowlistCanCreate string `json:"allowlist_can_create"` AllowlistCanCreate string `json:"allowlist_can_create"`
AllowlistCanGrant string `json:"allowlist_can_grant"` AllowlistCanGrant string `json:"allowlist_can_grant"`
} }
@ -204,9 +205,14 @@ func (p *Plugin) getTypes(w http.ResponseWriter, r *http.Request, userID string)
result := make([]TypeWithBadgeCount, len(types)) result := make([]TypeWithBadgeCount, len(types))
for i, t := range types { for i, t := range types {
createdByUsername := t.CreatedBy
if creator, appErr := p.mm.User.Get(t.CreatedBy); appErr == nil {
createdByUsername = creator.Username
}
result[i] = TypeWithBadgeCount{ result[i] = TypeWithBadgeCount{
BadgeTypeDefinition: t, BadgeTypeDefinition: t,
BadgeCount: badgeCountByType[t.ID], BadgeCount: badgeCountByType[t.ID],
CreatedByUsername: createdByUsername,
AllowlistCanCreate: p.resolveUserIDList(t.CanCreate.AllowList), AllowlistCanCreate: p.resolveUserIDList(t.CanCreate.AllowList),
AllowlistCanGrant: p.resolveUserIDList(t.CanGrant.AllowList), AllowlistCanGrant: p.resolveUserIDList(t.CanGrant.AllowList),
} }

View File

@ -43,6 +43,12 @@ const AllTypesRow: React.FC<Props> = ({badgeType, onEdit, onDelete, onClick}: Pr
)} )}
</div> </div>
<div className='AllTypesRow__meta'> <div className='AllTypesRow__meta'>
<FormattedMessage
id='badges.label.created_by'
defaultMessage='Создал: {username}'
values={{username: badgeType.created_by_username || badgeType.created_by}}
/>
{' · '}
<FormattedMessage <FormattedMessage
id='badges.types.badge_count' id='badges.types.badge_count'
defaultMessage='{count, plural, one {# достижение} few {# достижения} many {# достижений} other {# достижений}}' defaultMessage='{count, plural, one {# достижение} few {# достижения} many {# достижений} other {# достижений}}'

View File

@ -43,6 +43,7 @@ export type BadgeTypeDefinition = {
name: string; name: string;
frame: string; frame: string;
created_by: string; created_by: string;
created_by_username: string;
can_grant: PermissionScheme; can_grant: PermissionScheme;
can_create: PermissionScheme; can_create: PermissionScheme;
badge_count: number; badge_count: number;