fix(menu): show dashboard overview as root item
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
package gas
|
||||
package gas
|
||||
|
||||
import "git.apinb.com/heqiapp/platforms/backend/api/internal/logic/common"
|
||||
|
||||
@@ -15,9 +15,7 @@ type Menu struct {
|
||||
}
|
||||
|
||||
var adminMenus = []Menu{
|
||||
{Identity: "dashboard", GroupCode: "dashboard", Name: "数据概述", Icon: "icon-dashboard", Path: "/dashboard", SortNo: 10, Status: common.StatusEnable},
|
||||
{Identity: "dashboard_overview", ParentIdentity: "dashboard", GroupCode: "dashboard", Name: "运营概览", Path: "/dashboard/overview", SortNo: 1, Status: common.StatusEnable},
|
||||
{Identity: "dashboard_reports", ParentIdentity: "dashboard", GroupCode: "dashboard", Name: "统计报表", Path: "/dashboard/reports", SortNo: 2, Status: common.StatusEnable},
|
||||
{Identity: "dashboard_overview", GroupCode: "dashboard", Name: "数据概览", Icon: "icon-dashboard", Path: "/dashboard/overview", SortNo: 10, Status: common.StatusEnable},
|
||||
{Identity: "delivery", GroupCode: "delivery", Name: "配送点管理", Icon: "icon-storage", Path: "/delivery", SortNo: 20, Status: common.StatusEnable},
|
||||
{Identity: "delivery_basic", ParentIdentity: "delivery", GroupCode: "delivery", Name: "配送点列表", Path: "/delivery/points", SortNo: 1, Status: common.StatusEnable},
|
||||
{Identity: "staff", GroupCode: "staff", Name: "工作人员管理", Icon: "icon-user-group", Path: "/staff", SortNo: 30, Status: common.StatusEnable},
|
||||
|
||||
@@ -24,3 +24,28 @@ func TestMenuContainsContractAndDeliveryManagement(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestMenuContainsDashboardRoutes(t *testing.T) {
|
||||
want := map[string]string{
|
||||
"dashboard_overview": "/dashboard/overview",
|
||||
}
|
||||
for _, menu := range MenusForRole("admin") {
|
||||
if path, ok := want[menu.Identity]; ok {
|
||||
if menu.Path != path {
|
||||
t.Fatalf("menu %q path = %q, want %q", menu.Identity, menu.Path, path)
|
||||
}
|
||||
delete(want, menu.Identity)
|
||||
}
|
||||
}
|
||||
if len(want) != 0 {
|
||||
t.Fatalf("missing dashboard menus: %#v", want)
|
||||
}
|
||||
for _, menu := range MenusForRole("admin") {
|
||||
if menu.Identity == "dashboard_overview" && (menu.ParentIdentity != "" || menu.Icon != "icon-dashboard") {
|
||||
t.Fatalf("dashboard overview must be a first-level icon menu: %#v", menu)
|
||||
}
|
||||
if menu.Identity == "dashboard" || menu.Identity == "dashboard_reports" {
|
||||
t.Fatalf("legacy dashboard menu must not be returned: %#v", menu)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user