chore: change build audit log string to be clearer (#6093)

* changed bbuild string

* clean up friendly string

* using Trans component

* general cleanup

* fixed tests

* fix lint

* fixing bolding

* removing dead strings in auditLogRow

* fix tests
This commit is contained in:
Kira Pilot
2023-02-08 13:06:57 -05:00
committed by GitHub
parent d60ec3e4bf
commit 7a1731b620
14 changed files with 241 additions and 144 deletions
+2 -15
View File
@@ -244,13 +244,13 @@ func (api *API) convertAuditLog(ctx context.Context, dblog database.GetAuditLogs
StatusCode: dblog.StatusCode,
AdditionalFields: dblog.AdditionalFields,
User: user,
Description: auditLogDescription(dblog, additionalFields),
Description: auditLogDescription(dblog),
ResourceLink: resourceLink,
IsDeleted: isDeleted,
}
}
func auditLogDescription(alog database.GetAuditLogsOffsetRow, additionalFields audit.AdditionalFields) string {
func auditLogDescription(alog database.GetAuditLogsOffsetRow) string {
str := fmt.Sprintf("{user} %s",
codersdk.AuditAction(alog.Action).Friendly(),
)
@@ -261,19 +261,6 @@ func auditLogDescription(alog database.GetAuditLogsOffsetRow, additionalFields a
return str
}
// Strings for starting/stopping workspace builds follow the below format:
// "{user | 'Coder automatically'} started build #{build_number} for workspace {target}"
// where target is a workspace (name) instead of a workspace build
// passed in on the FE via AuditLog.AdditionalFields rather than derived in request.go:35
if alog.ResourceType == database.ResourceTypeWorkspaceBuild && alog.Action != database.AuditActionDelete {
if len(additionalFields.BuildNumber) == 0 {
str += " build for"
} else {
str += fmt.Sprintf(" build #%s for",
additionalFields.BuildNumber)
}
}
// We don't display the name (target) for git ssh keys. It's fairly long and doesn't
// make too much sense to display.
if alog.ResourceType == database.ResourceTypeGitSshKey {