feat: enhance community label handling and improve UI localization across operations pages. Introduce community label mapping for better readability in job logs and update various components to reflect Russian translations, enhancing user experience and consistency in the interface.
CI / changes (push) Successful in 6s
CI / openapi (push) Has been skipped
CI / go (push) Successful in 43s
CI / docker-web (deploy/docker/evobgp-web/Dockerfile, , evobgp-web) (push) Successful in 1m8s
CI / docker-web (deploy/docker/evobgp-web/Dockerfile, evobgp-all, evobgp-web-all) (push) Successful in 1m9s
CI / docker-bird (push) Has been skipped
CI / bird2 (push) Successful in 17s
CI / docker-go-prime (push) Successful in 23s
CI / docker-go (deploy/docker/evobgp-agent/Dockerfile, , evobgp-agent) (push) Successful in 1m5s
CI / docker-go (evobgp-all, 1, deploy/docker/gobinary/Dockerfile, , evobgp-all) (push) Successful in 2m29s
CI / docker-go (evobgp-api, 1, deploy/docker/gobinary/Dockerfile, , evobgp-api) (push) Successful in 1m31s
CI / docker-go (evobgp-deploy, 0, deploy/docker/gobinary/Dockerfile, , evobgp-deploy) (push) Successful in 1m27s
CI / docker-go (evobgp-ingest, 0, deploy/docker/gobinary/Dockerfile, , evobgp-ingest) (push) Successful in 1m27s
CI / docker-go (evobgp-node, 0, deploy/docker/gobinary/Dockerfile, , evobgp-node) (push) Successful in 1m15s
CI / docker-go (evobgp-render, 0, deploy/docker/gobinary/Dockerfile, , evobgp-render) (push) Successful in 1m28s
CI / docker-go (evobgp-scheduler, 0, deploy/docker/gobinary/Dockerfile, , evobgp-scheduler) (push) Successful in 1m30s

This commit is contained in:
Denozordec
2026-04-07 00:58:15 +07:00
parent e1c4cbce93
commit 53fd527a6d
16 changed files with 338 additions and 128 deletions
+62 -21
View File
@@ -58,12 +58,13 @@ type Worker struct {
}
type revisionLogEntry struct {
Kind string `json:"kind"`
Source string `json:"source"`
Community string `json:"community"`
PrefixCount int `json:"prefix_count"`
Sample []string `json:"sample,omitempty"`
Message string `json:"message"`
Kind string `json:"kind"`
Source string `json:"source"`
Community string `json:"community"`
CommunityLabel string `json:"community_label"`
PrefixCount int `json:"prefix_count"`
Sample []string `json:"sample,omitempty"`
Message string `json:"message"`
}
var defaultWorkerHTTP = &http.Client{Timeout: 45 * time.Second}
@@ -275,17 +276,54 @@ func (w *Worker) runRollback(j *Job) {
"rollback_summary": map[string]any{
"source_revision_id": src,
"new_revision_id": newID,
"message": fmt.Sprintf("Rollback %s -> %s", shortID(src), shortID(newID)),
"message": fmt.Sprintf("Откат %s %s", shortID(src), shortID(newID)),
},
})
w.enqueueDeployAllSpeakers(j, j.TenantID, newID)
j.Succeed()
}
// buildCommunityLabelMap maps community UUID -> human-readable title (or BGP community string).
func buildCommunityLabelMap(st store.Backend, tenantID string) map[string]string {
out := make(map[string]string)
if st == nil {
return out
}
list, err := st.ListCommunities(tenantID)
if err != nil || list == nil {
return out
}
for _, c := range list {
if c == nil {
continue
}
label := strings.TrimSpace(c.Title)
if label == "" {
label = strings.TrimSpace(c.Community)
}
if label == "" {
label = c.ID
}
out[c.ID] = label
}
return out
}
func resolveCommunityLabel(commID string, byID map[string]string) string {
if commID == "" || commID == "none" {
return "без community"
}
if lbl, ok := byID[commID]; ok && strings.TrimSpace(lbl) != "" {
return strings.TrimSpace(lbl)
}
return commID
}
func (w *Worker) buildRevisionLogEntries(tenantID, revID string) ([]map[string]any, int, error) {
if w == nil || w.Store == nil {
return nil, 0, fmt.Errorf("store not configured")
}
commLabels := buildCommunityLabelMap(w.Store, tenantID)
var all []store.PrefixRow
cursor := ""
for {
@@ -333,14 +371,16 @@ func (w *Worker) buildRevisionLogEntries(tenantID, revID string) ([]map[string]a
out := make([]map[string]any, 0, len(keys))
for _, k := range keys {
g := groups[k]
msg := humanLogMessage(g.kind, g.source, g.count, g.community, g.sample)
cl := resolveCommunityLabel(g.community, commLabels)
msg := humanLogMessage(g.kind, g.source, g.count, cl, g.sample)
out = append(out, map[string]any{
"kind": g.kind,
"source": g.source,
"community": g.community,
"prefix_count": g.count,
"sample": g.sample,
"message": msg,
"kind": g.kind,
"source": g.source,
"community": g.community,
"community_label": cl,
"prefix_count": g.count,
"sample": g.sample,
"message": msg,
})
}
return out, len(all), nil
@@ -364,22 +404,23 @@ func classifySource(src string) (kind, name string) {
}
}
func humanLogMessage(kind, source string, count int, community string, sample []string) string {
// humanLogMessage builds a Russian log line; communityLabel is already resolved (title or BGP value).
func humanLogMessage(kind, source string, count int, communityLabel string, sample []string) string {
switch kind {
case "asn":
return fmt.Sprintf("AS%s -> %d префиксов добавлены в community %s", source, count, community)
return fmt.Sprintf("AS%s: добавлено %d префиксов в сообщество «%s»", source, count, communityLabel)
case "domain":
ips := strings.Join(prettyDomainSample(sample), " ")
if ips == "" {
ips = "-"
ips = ""
}
return fmt.Sprintf("%s -> ip (%s) -> добавлены в community %s", source, ips, community)
return fmt.Sprintf("%s: IP (%s) добавлено в сообщество «%s»", source, ips, communityLabel)
case "cdn":
return fmt.Sprintf("CDN source %s -> %d префиксов добавлены в community %s", source, count, community)
return fmt.Sprintf("CDN «%s»: добавлено %d префиксов в сообщество «%s»", source, count, communityLabel)
case "ip_range":
return fmt.Sprintf("IP ranges -> %d префиксов добавлены в community %s", count, community)
return fmt.Sprintf("Статические диапазоны: добавлено %d префиксов в сообщество «%s»", count, communityLabel)
default:
return fmt.Sprintf("%s -> %d префиксов добавлены в community %s", source, count, community)
return fmt.Sprintf("%s: добавлено %d префиксов в сообщество «%s»", source, count, communityLabel)
}
}