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 {
*badgesmodel.BadgeTypeDefinition
BadgeCount int `json:"badge_count"`
CreatedByUsername string `json:"created_by_username"`
AllowlistCanCreate string `json:"allowlist_can_create"`
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))
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{
BadgeTypeDefinition: t,
BadgeCount: badgeCountByType[t.ID],
CreatedByUsername: createdByUsername,
AllowlistCanCreate: p.resolveUserIDList(t.CanCreate.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 className='AllTypesRow__meta'>
<FormattedMessage
id='badges.label.created_by'
defaultMessage='Создал: {username}'
values={{username: badgeType.created_by_username || badgeType.created_by}}
/>
{' · '}
<FormattedMessage
id='badges.types.badge_count'
defaultMessage='{count, plural, one {# достижение} few {# достижения} many {# достижений} other {# достижений}}'

View File

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