release: prepare v0.1.131
This commit is contained in:
@@ -1134,6 +1134,14 @@ func (h *SettingHandler) UpdateSettings(c *gin.Context) {
|
||||
response.BadRequest(c, "Custom menu item visibility must be 'user' or 'admin'")
|
||||
return
|
||||
}
|
||||
switch item.Placement {
|
||||
case "", "sidebar":
|
||||
items[i].Placement = "sidebar"
|
||||
case "home_header", "both":
|
||||
default:
|
||||
response.BadRequest(c, "Custom menu item placement must be 'sidebar', 'home_header' or 'both'")
|
||||
return
|
||||
}
|
||||
if len(item.IconSVG) > maxMenuItemIconSVGLen {
|
||||
response.BadRequest(c, "Custom menu item icon SVG is too large (max 10KB)")
|
||||
return
|
||||
|
||||
@@ -13,6 +13,7 @@ type CustomMenuItem struct {
|
||||
URL string `json:"url"`
|
||||
PageSlug string `json:"page_slug,omitempty"`
|
||||
Visibility string `json:"visibility"` // "user" or "admin"
|
||||
Placement string `json:"placement,omitempty"`
|
||||
SortOrder int `json:"sort_order"`
|
||||
}
|
||||
|
||||
@@ -367,9 +368,25 @@ func ParseCustomMenuItems(raw string) []CustomMenuItem {
|
||||
if err := json.Unmarshal([]byte(raw), &items); err != nil {
|
||||
return []CustomMenuItem{}
|
||||
}
|
||||
for i := range items {
|
||||
items[i].Placement = normalizeCustomMenuPlacement(items[i].Placement)
|
||||
}
|
||||
return items
|
||||
}
|
||||
|
||||
func normalizeCustomMenuPlacement(raw string) string {
|
||||
switch strings.TrimSpace(raw) {
|
||||
case "", "sidebar":
|
||||
return "sidebar"
|
||||
case "home_header":
|
||||
return "home_header"
|
||||
case "both":
|
||||
return "both"
|
||||
default:
|
||||
return "sidebar"
|
||||
}
|
||||
}
|
||||
|
||||
// ParseUserVisibleMenuItems parses custom menu items and filters out admin-only entries.
|
||||
func ParseUserVisibleMenuItems(raw string) []CustomMenuItem {
|
||||
items := ParseCustomMenuItems(raw)
|
||||
|
||||
Reference in New Issue
Block a user