EntityStore: Move slug+folder to summary metadata (#59620)

This commit is contained in:
Ryan McKinley
2022-12-01 14:45:08 -05:00
committed by GitHub
parent 6dbe3b555f
commit fb98a97efa
13 changed files with 468 additions and 1074 deletions
@@ -10,6 +10,8 @@ type summarySupport struct {
model *models.EntitySummary
name string
description *string // null or empty
slug *string // null or empty
folder *string // null or empty
labels *string
fields *string
errors *string // should not allow saving with this!
@@ -32,7 +34,12 @@ func newSummarySupport(summary *models.EntitySummary) (*summarySupport, error) {
if summary.Description != "" {
s.description = &summary.Description
}
if summary.Slug != "" {
s.slug = &summary.Slug
}
if summary.Folder != "" {
s.folder = &summary.Folder
}
if len(summary.Labels) > 0 {
js, err = json.Marshal(summary.Labels)
if err != nil {
@@ -71,6 +78,12 @@ func (s summarySupport) toEntitySummary() (*models.EntitySummary, error) {
if s.description != nil {
summary.Description = *s.description
}
if s.slug != nil {
summary.Slug = *s.slug
}
if s.folder != nil {
summary.Folder = *s.folder
}
if s.labels != nil {
b := []byte(*s.labels)
err = json.Unmarshal(b, &summary.Labels)